diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index daa507b..651b92f 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2a64a4b..8410c14 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: diff --git a/.github/workflows/update-major-tag.yml b/.github/workflows/update-major-tag.yml new file mode 100644 index 0000000..58554f0 --- /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 diff --git a/__tests__/get-os.test.ts b/__tests__/get-os.test.ts index d30e939..da4dad9 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 118a8f2..09bffe0 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"); - // }); }); diff --git a/lib/index.js b/lib/index.js index 6ca74b3..4f3b3a5 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) { diff --git a/src/get-os.ts b/src/get-os.ts index ef9d50d..b94917a 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`); } diff --git a/src/index.ts b/src/index.ts index b597dd1..3b3925d 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);