From 4e5d934ed6e21425ca0ed838c2dc26cbeb023be4 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:12:14 +0900 Subject: [PATCH 1/7] gha: Add Pull Request to stale target --- .github/workflows/stale.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index daa507b5..651b92fe 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: "Close stale issues" +name: Stale on: schedule: @@ -12,5 +12,6 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.' days-before-stale: 21 days-before-close: 7 From 876c3e1bbf2e019bee09a0ec4def7f12b5cb156c Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:20:26 +0900 Subject: [PATCH 2/7] gha: Add ncc check step --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2a64a4bd..8410c146 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,11 @@ jobs: - run: npm test + - name: Check ncc + run: | + npm run build + test -z "$(git status --short)" + - name: Upload test coverage uses: actions/upload-artifact@v1 with: From 2b2ecc2dd17051e279547fda01783c3d42ad66ed Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:21:57 +0900 Subject: [PATCH 3/7] src: Rename showVersion() --- src/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index b597dd15..3b3925dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,8 +5,7 @@ import installer from './installer'; // most @actions toolkit packages have async methods async function run() { - const dump = async () => { - // Show version + const showVersion = async () => { await exec.exec('hugo version'); }; @@ -18,7 +17,7 @@ async function run() { async function(latestVersion): Promise { console.log(`Hugo version: ${latestVersion} (${hugoVersion})`); await installer(latestVersion); - await dump(); + await showVersion(); }, function(error) { core.setFailed(error); @@ -27,7 +26,7 @@ async function run() { } else { console.log(`Hugo version: ${hugoVersion}`); await installer(hugoVersion); - await dump(); + await showVersion(); } } catch (error) { core.setFailed(error.message); From 7c7d22c0dec147e541b465beadfb844539d84d04 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:31:20 +0900 Subject: [PATCH 4/7] test: Add not to be cases --- __tests__/get-os.test.ts | 3 --- __tests__/get-url.test.ts | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/__tests__/get-os.test.ts b/__tests__/get-os.test.ts index d30e9395..da4dad95 100644 --- a/__tests__/get-os.test.ts +++ b/__tests__/get-os.test.ts @@ -8,9 +8,6 @@ describe('getOS', () => { }); test('test exception', () => { - // expect(() => { - // getOS("win32"); - // }).toThrowError("Windows is not supported"); expect(() => { getOS('centos'); }).toThrowError('centos is not supported'); diff --git a/__tests__/get-url.test.ts b/__tests__/get-url.test.ts index 118a8f24..09bffe0d 100644 --- a/__tests__/get-url.test.ts +++ b/__tests__/get-url.test.ts @@ -9,14 +9,11 @@ describe('getURL()', () => { const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`; const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`; expect(getURL('Linux', 'false', '0.58.2')).toBe(urlLinux); + expect(getURL('Linux', 'true', '0.58.2')).not.toBe(urlLinux); + expect(getURL('MyOS', 'false', '0.58.2')).not.toBe(urlLinux); + expect(getURL('Linux', 'false', '0.58.1')).not.toBe(urlLinux); expect(getURL('Linux', 'true', '0.58.2')).toBe(urlLinuxExtended); expect(getURL('macOS', 'false', '0.58.2')).toBe(urlMacOS); expect(getURL('Windows', 'false', '0.58.2')).toBe(urlWindows); }); - - // test("test exception", () => { - // expect(() => { - // getURL("Linux", "hoge", "0.58.2"); - // }).toThrowError("Invalid input (extended): hoge"); - // }); }); From a5d2cec8b874957403a8ac189fad32d587da8659 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:32:16 +0900 Subject: [PATCH 5/7] Remove old comment --- src/get-os.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/get-os.ts b/src/get-os.ts index ef9d50de..b94917af 100644 --- a/src/get-os.ts +++ b/src/get-os.ts @@ -5,7 +5,6 @@ export default function getOS(platform: string) { return 'macOS'; } else if (platform === 'win32') { return 'Windows'; - // throw new Error("Windows is not supported"); } else { throw new Error(`${platform} is not supported`); } From c8c7069f3729ff74fa434f04c5a225d2e155e593 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:38:59 +0900 Subject: [PATCH 6/7] Run ncc --- lib/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6ca74b30..4f3b3a5e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1907,7 +1907,7 @@ const get_latest_version_1 = __importDefault(__webpack_require__(307)); const installer_1 = __importDefault(__webpack_require__(923)); function run() { return __awaiter(this, void 0, void 0, function* () { - const dump = () => __awaiter(this, void 0, void 0, function* () { + const showVersion = () => __awaiter(this, void 0, void 0, function* () { yield exec.exec('hugo version'); }); try { @@ -1917,7 +1917,7 @@ function run() { return __awaiter(this, void 0, void 0, function* () { console.log(`Hugo version: ${latestVersion} (${hugoVersion})`); yield installer_1.default(latestVersion); - yield dump(); + yield showVersion(); }); }, function (error) { core.setFailed(error); @@ -1926,7 +1926,7 @@ function run() { else { console.log(`Hugo version: ${hugoVersion}`); yield installer_1.default(hugoVersion); - yield dump(); + yield showVersion(); } } catch (error) { From 4aabce898966835743a5364f7f6980aa79e1e959 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 8 Dec 2019 15:39:21 +0900 Subject: [PATCH 7/7] gha: Add update major tag workflow --- .github/workflows/update-major-tag.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/update-major-tag.yml diff --git a/.github/workflows/update-major-tag.yml b/.github/workflows/update-major-tag.yml new file mode 100644 index 00000000..58554f0c --- /dev/null +++ b/.github/workflows/update-major-tag.yml @@ -0,0 +1,24 @@ +name: Update major tag + +on: + release: + types: [published] + +jobs: + update: + runs-on: ubuntu-18.04 + steps: + + - uses: actions/checkout@v1 + + - name: Update major tag + if: github.event.release.prerelease == false + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" + export TAG_NAME="${GITHUB_REF##refs/tags/}" + export TAG_MAJOR="${TAG_NAME%%.*}" + git tag "${TAG_MAJOR}" || git tag -d "${TAG_MAJOR}" ; git push origin ":refs/tags/${TAG_MAJOR}" + git tag "${TAG_MAJOR}" || true + git push --tags origin