From 16c87f2e1738482e974b1211dca7c41edd3847e3 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 6 May 2020 00:31:46 +0200 Subject: [PATCH] Bring back support for Windows --- .github/workflows/ci.yml | 1 + .github/workflows/test.yml | 1 + README.md | 2 +- dist/index.js | 14 +++++--------- src/gpg.ts | 6 +++++- src/main.ts | 6 ------ 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87fb962..bcc3ff5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: os: - ubuntu-latest - macOS-latest + - windows-latest steps: - name: Checkout diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1134300..4aa0cb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ jobs: os: - ubuntu-latest - macOS-latest + - windows-latest steps: - # https://github.com/actions/checkout diff --git a/README.md b/README.md index d4d6cbd..65ddacb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitH ## Features -* Works on Linux and MacOS [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources) +* Works on Linux, MacOS and Windows [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources) * Allow to seed the internal cache of `gpg-agent` with provided passphrase * Enable signing for Git commits and tags * Configure and check committer info against GPG key diff --git a/dist/index.js b/dist/index.js index cd7e515..42876ae 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1010,23 +1010,15 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const git = __importStar(__webpack_require__(453)); const gpg = __importStar(__webpack_require__(207)); const openpgp = __importStar(__webpack_require__(781)); const stateHelper = __importStar(__webpack_require__(153)); -const os_1 = __importDefault(__webpack_require__(87)); function run() { return __awaiter(this, void 0, void 0, function* () { try { - if (os_1.default.platform() == 'win32') { - core.setFailed('Windows platform not supported'); - return; - } if (!process.env.SIGNING_KEY) { core.setFailed('Signing key required'); return; @@ -1145,7 +1137,11 @@ const getGnupgHome = () => __awaiter(void 0, void 0, void 0, function* () { if (process.env.GNUPGHOME) { return process.env.GNUPGHOME; } - return path.join(process.env.HOME || '', '.gnupg'); + let homedir = path.join(process.env.HOME || '', '.gnupg'); + if (os.platform() == 'win32' && !process.env.HOME) { + homedir = path.join(process.env.USERPROFILE || '', '.gnupg'); + } + return homedir; }); const gpgConnectAgent = (command) => __awaiter(void 0, void 0, void 0, function* () { return yield exec.exec(`gpg-connect-agent "${command}" /bye`, [], true).then(res => { diff --git a/src/gpg.ts b/src/gpg.ts index f0134d3..77d2fe0 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -23,7 +23,11 @@ const getGnupgHome = async (): Promise => { if (process.env.GNUPGHOME) { return process.env.GNUPGHOME; } - return path.join(process.env.HOME || '', '.gnupg'); + let homedir: string = path.join(process.env.HOME || '', '.gnupg'); + if (os.platform() == 'win32' && !process.env.HOME) { + homedir = path.join(process.env.USERPROFILE || '', '.gnupg'); + } + return homedir; }; const gpgConnectAgent = async (command: string): Promise => { diff --git a/src/main.ts b/src/main.ts index 41039f6..9ec5168 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,15 +3,9 @@ import * as git from './git'; import * as gpg from './gpg'; import * as openpgp from './openpgp'; import * as stateHelper from './state-helper'; -import os from 'os'; async function run(): Promise { try { - if (os.platform() == 'win32') { - core.setFailed('Windows platform not supported'); - return; - } - if (!process.env.SIGNING_KEY) { core.setFailed('Signing key required'); return;