Compare commits

...

19 Commits

Author SHA1 Message Date
Shohei Ueda
739a95f1e7 gha: Enhance workflows (#102)
* gha: Add Pull Request to stale target
* gha: Add ncc check step (Close #98 )
* src: Rename showVersion()
* test: Add not to be cases
* Remove old comment
* gha: Add update major tag workflow (Close #97 )
2019-12-08 15:45:59 +09:00
Shohei Ueda
bc6f48c683 deps: update (#101) 2019-12-08 13:07:31 +09:00
Shohei Ueda
cf07920706 docs: Pin peaceiris/actions-gh-pages to v2 2019-12-08 07:57:55 +09:00
peaceiris
3e0ab3eb25 gha: Pin version actions/upload-artifact to v1 2019-12-05 19:42:03 +09:00
Shohei Ueda
c5ea31b9d7 Create stale.yml 2019-12-05 17:06:35 +09:00
Shohei Ueda
bc06efb2e0 docs: Pin action version 2019-12-01 03:56:39 +09:00
Shohei Ueda
3b3c59db47 docs: Add stable tag v2 2019-11-28 20:47:38 +09:00
Shohei Ueda
b51e0ae5b4 Update README.md 2019-11-28 20:43:56 +09:00
peaceiris
8b813b0c62 deps: update 2019-11-28 00:11:39 +09:00
Shohei Ueda
638f751056 Update test.yml (#96) 2019-11-27 22:05:49 +09:00
Shohei Ueda
d04830441a Delete feature_request.md 2019-11-27 21:52:43 +09:00
Shohei Ueda
5dc353210f Update issue templates 2019-11-27 21:52:09 +09:00
peaceiris
129fcc86a6 docs: Update tag 2019-11-22 12:22:33 +09:00
Shohei Ueda
34e697e615 docs: Add Back to TOC link 2019-11-22 12:19:08 +09:00
Shohei Ueda
608a9dce06 Update README.md 2019-11-22 12:17:04 +09:00
peaceiris
bcfd41e8b4 docs: update 2019-11-22 12:15:00 +09:00
Shohei Ueda
0a102fbbed docs: Add tips section (Read Hugo version from file) (#89) 2019-11-22 12:12:20 +09:00
Shohei Ueda
ef869fb22f Path join (#92) 2019-11-22 11:14:44 +09:00
peaceiris
1490c6e417 deps: update 2019-11-22 09:38:27 +09:00
13 changed files with 402 additions and 171 deletions

View File

@@ -1,8 +1,8 @@
---
name: Feature request
name: Proposal
about: Suggest an idea for this project
title: 'feat: This is a sample title'
labels: request
title: 'proposal: This is a sample title'
labels: proposal
assignees: peaceiris
---

17
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Stale
on:
schedule:
- cron: "6 6 * * *"
jobs:
stale:
runs-on: ubuntu-18.04
steps:
- uses: actions/stale@v1
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

View File

@@ -30,7 +30,7 @@ jobs:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: Cache
uses: actions/cache@v1.0.1
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -45,8 +45,13 @@ jobs:
- run: npm test
- name: Check ncc
run: |
npm run build
test -z "$(git status --short)"
- name: Upload test coverage
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v1
with:
name: coverage
path: coverage

24
.github/workflows/update-major-tag.yml vendored Normal file
View File

@@ -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

View File

@@ -8,13 +8,13 @@
## GitHub Actions for Hugo extended and Modules
## GitHub Actions for Hugo
- [gohugoio/hugo: The worlds fastest framework for building websites.](https://github.com/gohugoio/hugo)
We can run Hugo on a virtual machine of GitHub Actions by this Hugo action. Hugo extended version and Hugo Modules are supported.
We can run **Hugo** on a virtual machine of **GitHub Actions** by this Hugo action. **Hugo extended** version and **Hugo Modules** are supported.
From `v2.0.0`, this Hugo action migrated to a JavaScript (TypeScript) action. We no longer build or pull a Hugo docker image. Thanks to this change, we can complete this action less than **4 sec**. (A docker base action was taking about 1 min or more execution time to build or pull.)
From `v2`, this Hugo action migrated to a JavaScript (TypeScript) action. We no longer build or pull a Hugo docker image. Thanks to this change, we can complete this action less than **4 sec**. (A docker base action was taking about 1 min or more execution time to build or pull.)
| OS (runs-on) | ubuntu-18.04 | macos-latest | windows-2019 |
|---|:---:|:---:|:---:|
@@ -24,15 +24,21 @@ From `v2.0.0`, this Hugo action migrated to a JavaScript (TypeScript) action. W
|---|:---:|:---:|:---:|
| Support | ✅️ | ✅️ | ✅️ |
## Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
*Table of Contents*
- [Getting started](#getting-started)
- [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow)
- [Options](#options)
- [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended)
- [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo)
- [Tips](#tips)
- [⭐️ Read Hugo version from file](#%EF%B8%8F-read-hugo-version-from-file)
- [License](#license)
- [About the author](#about-the-author)
@@ -65,27 +71,31 @@ jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
# with:
# submodules: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.58.3'
hugo-version: '0.59.1'
# extended: true
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.0
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
```
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>
## Options
@@ -96,9 +106,9 @@ Set `extended: true` to use a Hugo extended version.
```yaml
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.58.3'
hugo-version: '0.59.1'
extended: true
```
@@ -108,13 +118,67 @@ Set `hugo-version: 'latest'` to use the latest version of Hugo.
```yaml
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
```
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo)
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>
## Tips
### ⭐️ Read Hugo version from file
How to sync a Hugo version between a Docker Compose and a GitHub Actions workflow via `.env` file.
Write a `HUGO_VERSION` to the `.env` file like the following and push it to a remote branch.
```sh
HUGO_VERSION=0.59.1
```
Next, add a step to read a Hugo version from the `.env` file.
```yaml
- name: Read .env
id: hugo-version
run: |
. ./.env
echo "::set-output name=HUGO_VERSION::${HUGO_VERSION}"
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'
extended: true
```
Here is a `docker-compose.yml` example.
```yaml
version: '3'
services:
hugo:
container_name: hugo
image: "peaceiris/hugo:v${HUGO_VERSION}"
# image: peaceiris/hugo:v${HUGO_VERSION}-mod # Hugo Modules
ports:
- 1313:1313
volumes:
- ${PWD}:/src
command:
- server
- --bind=0.0.0.0
- --buildDrafts
```
## License
@@ -128,3 +192,9 @@ This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](htt
## About the author
- [peaceiris's homepage](https://peaceiris.com/)
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>

View File

@@ -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');

View File

@@ -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");
// });
});

View File

@@ -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) {
@@ -5153,6 +5153,18 @@ const tc = __importStar(__webpack_require__(533));
const io = __importStar(__webpack_require__(1));
const get_os_1 = __importDefault(__webpack_require__(443));
const get_url_1 = __importDefault(__webpack_require__(901));
const path = __importStar(__webpack_require__(622));
let tempDir = process.env['RUNNER_TEMPDIRECTORY'] || '';
if (!tempDir) {
let baseTempLocation;
if (process.platform === 'win32') {
baseTempLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
baseTempLocation = `${process.env.HOME}`;
}
tempDir = path.join(baseTempLocation, 'tmp');
}
function installer(version) {
return __awaiter(this, void 0, void 0, function* () {
try {
@@ -5162,17 +5174,25 @@ function installer(version) {
console.log(`Operating System: ${osName}`);
const hugoURL = get_url_1.default(osName, extended, version);
core.debug(`hugoURL: ${hugoURL}`);
const hugoPath = `${process.env.HOME}/bin`;
let baseLocation;
if (process.platform === 'win32') {
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
baseLocation = `${process.env.HOME}`;
}
const hugoPath = path.join(baseLocation, 'hugobin');
yield io.mkdirP(hugoPath);
core.addPath(hugoPath);
yield io.mkdirP(tempDir);
const hugoAssets = yield tc.downloadTool(hugoURL);
let hugoBin = '';
if (osName === 'Windows') {
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, '/tmp');
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, tempDir);
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
}
else {
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, '/tmp');
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, tempDir);
hugoBin = `${hugoExtractedFolder}/hugo`;
}
yield io.mv(hugoBin, hugoPath);

334
package-lock.json generated
View File

@@ -566,9 +566,9 @@
"dev": true
},
"@types/node": {
"version": "12.12.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.8.tgz",
"integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w==",
"version": "12.12.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz",
"integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==",
"dev": true
},
"@types/normalize-package-data": {
@@ -599,36 +599,37 @@
"dev": true
},
"@typescript-eslint/experimental-utils": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.7.0.tgz",
"integrity": "sha512-9/L/OJh2a5G2ltgBWJpHRfGnt61AgDeH6rsdg59BH0naQseSwR7abwHq3D5/op0KYD/zFT4LS5gGvWcMmegTEg==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.10.0.tgz",
"integrity": "sha512-FZhWq6hWWZBP76aZ7bkrfzTMP31CCefVIImrwP3giPLcoXocmLTmr92NLZxuIcTL4GTEOE33jQMWy9PwelL+yQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.7.0",
"@typescript-eslint/typescript-estree": "2.10.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/parser": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.7.0.tgz",
"integrity": "sha512-ctC0g0ZvYclxMh/xI+tyqP0EC2fAo6KicN9Wm2EIao+8OppLfxji7KAGJosQHSGBj3TcqUrA96AjgXuKa5ob2g==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.10.0.tgz",
"integrity": "sha512-wQNiBokcP5ZsTuB+i4BlmVWq6o+oAhd8en2eSm/EE9m7BgZUIfEeYFd6z3S+T7bgNuloeiHA1/cevvbBDLr98g==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "2.7.0",
"@typescript-eslint/typescript-estree": "2.7.0",
"@typescript-eslint/experimental-utils": "2.10.0",
"@typescript-eslint/typescript-estree": "2.10.0",
"eslint-visitor-keys": "^1.1.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.7.0.tgz",
"integrity": "sha512-vVCE/DY72N4RiJ/2f10PTyYekX2OLaltuSIBqeHYI44GQ940VCYioInIb8jKMrK9u855OEJdFC+HmWAZTnC+Ag==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.10.0.tgz",
"integrity": "sha512-oOYnplddQNm/LGVkqbkAwx4TIBuuZ36cAQq9v3nFIU9FmhemHuVzAesMSXNQDdAzCa5bFgCrfD3JWhYVKlRN2g==",
"dev": true,
"requires": {
"debug": "^4.1.1",
"glob": "^7.1.4",
"eslint-visitor-keys": "^1.1.0",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"lodash.unescape": "4.0.1",
"semver": "^6.3.0",
@@ -644,6 +645,20 @@
"ms": "^2.1.1"
}
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -1192,12 +1207,12 @@
"dev": true
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
"integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==",
"dev": true,
"requires": {
"restore-cursor": "^2.0.0"
"restore-cursor": "^3.1.0"
}
},
"cli-truncate": {
@@ -1704,9 +1719,9 @@
}
},
"eslint": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.6.0.tgz",
"integrity": "sha512-PpEBq7b6qY/qrOmpYQ/jTMDYfuQMELR4g4WI1M/NaSDDD/bdcMb+dj4Hgks7p41kW2caXsPsEZAEAyAgjVVC0g==",
"version": "6.7.2",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.2.tgz",
"integrity": "sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
@@ -1724,7 +1739,7 @@
"file-entry-cache": "^5.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^5.0.0",
"globals": "^11.7.0",
"globals": "^12.1.0",
"ignore": "^4.0.6",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
@@ -1737,7 +1752,7 @@
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
"optionator": "^0.8.2",
"optionator": "^0.8.3",
"progress": "^2.0.0",
"regexpp": "^2.0.1",
"semver": "^6.1.2",
@@ -1757,17 +1772,46 @@
"ms": "^2.1.1"
}
},
"globals": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz",
"integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==",
"dev": true,
"requires": {
"type-fest": "^0.8.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"optionator": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
"integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
"dev": true,
"requires": {
"deep-is": "~0.1.3",
"fast-levenshtein": "~2.0.6",
"levn": "~0.3.0",
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2",
"word-wrap": "~1.2.3"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
},
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
}
}
},
@@ -2131,13 +2175,12 @@
}
},
"figures": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz",
"integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz",
"integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5",
"object-assign": "^4.1.0"
"escape-string-regexp": "^1.0.5"
}
},
"file-entry-cache": {
@@ -3045,9 +3088,9 @@
}
},
"husky": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/husky/-/husky-3.0.9.tgz",
"integrity": "sha512-Yolhupm7le2/MqC1VYLk/cNmYxsSsqKkTyBhzQHhPK1jFnC89mmmNVuGtLNabjDI6Aj8UNIr0KpRNuBkiC4+sg==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/husky/-/husky-3.1.0.tgz",
"integrity": "sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
@@ -3154,9 +3197,9 @@
"dev": true
},
"import-fresh": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz",
"integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
"integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
"dev": true,
"requires": {
"parent-module": "^1.0.0",
@@ -3231,22 +3274,19 @@
},
"dependencies": {
"ansi-escapes": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.2.1.tgz",
"integrity": "sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q==",
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz",
"integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==",
"dev": true,
"requires": {
"type-fest": "^0.5.2"
"type-fest": "^0.8.1"
}
},
"cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
"integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==",
"dev": true,
"requires": {
"restore-cursor": "^3.1.0"
}
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
},
"emoji-regex": {
"version": "8.0.0",
@@ -3254,61 +3294,38 @@
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
},
"figures": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz",
"integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
}
},
"is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true
},
"mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
"dev": true
},
"onetime": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz",
"integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==",
"dev": true,
"requires": {
"mimic-fn": "^2.1.0"
}
},
"restore-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",
"integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==",
"dev": true,
"requires": {
"onetime": "^5.1.0",
"signal-exit": "^3.0.2"
}
},
"string-width": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz",
"integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
"integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
"dev": true,
"requires": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^5.2.0"
"strip-ansi": "^6.0.0"
},
"dependencies": {
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"dev": true,
"requires": {
"ansi-regex": "^5.0.0"
}
}
}
},
"type-fest": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz",
"integrity": "sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==",
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
}
}
@@ -4289,9 +4306,9 @@
"dev": true
},
"lint-staged": {
"version": "9.4.3",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.4.3.tgz",
"integrity": "sha512-PejnI+rwOAmKAIO+5UuAZU9gxdej/ovSEOAY34yMfC3OS4Ac82vCBPzAWLReR9zCPOMqeVwQRaZ3bUBpAsaL2Q==",
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.5.0.tgz",
"integrity": "sha512-nawMob9cb/G1J98nb8v3VC/E8rcX1rryUYXVZ69aT9kde6YWX+uvNOEHY5yf2gcWcTJGiD0kqXmCnS3oD75GIA==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
@@ -4424,9 +4441,9 @@
"dev": true
},
"path-key": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.0.tgz",
"integrity": "sha512-8cChqz0RP6SHJkMt48FW0A7+qUOn+OsnOsVtzI59tZ8m+5bCSk7hzwET0pulwOM2YMn9J1efb07KB9l9f30SGg==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"shebang-command": {
@@ -4454,9 +4471,9 @@
}
},
"which": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.1.tgz",
"integrity": "sha512-N7GBZOTswtB9lkQBZA4+zAXrjEIWAUOB93AvzUiudRzRxhUdLURQ7D/gAIMY1gatT/LTbmbcv8SiYazy3eYB7w==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
@@ -4536,6 +4553,16 @@
"supports-color": "^2.0.0"
}
},
"figures": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz",
"integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5",
"object-assign": "^4.1.0"
}
},
"indent-string": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz",
@@ -4580,6 +4607,15 @@
"figures": "^2.0.0"
},
"dependencies": {
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"dev": true,
"requires": {
"restore-cursor": "^2.0.0"
}
},
"figures": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
@@ -4588,6 +4624,31 @@
"requires": {
"escape-string-regexp": "^1.0.5"
}
},
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"onetime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"dev": true,
"requires": {
"mimic-fn": "^1.0.0"
}
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"dev": true,
"requires": {
"onetime": "^2.0.0",
"signal-exit": "^3.0.2"
}
}
}
},
@@ -4663,6 +4724,40 @@
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"dev": true,
"requires": {
"restore-cursor": "^2.0.0"
}
},
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"onetime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"dev": true,
"requires": {
"mimic-fn": "^1.0.0"
}
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"dev": true,
"requires": {
"onetime": "^2.0.0",
"signal-exit": "^3.0.2"
}
},
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
@@ -5556,30 +5651,13 @@
"dev": true
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",
"integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==",
"dev": true,
"requires": {
"onetime": "^2.0.0",
"onetime": "^5.1.0",
"signal-exit": "^3.0.2"
},
"dependencies": {
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"onetime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"dev": true,
"requires": {
"mimic-fn": "^1.0.0"
}
}
}
},
"ret": {
@@ -6279,9 +6357,9 @@
"dev": true
},
"ts-jest": {
"version": "24.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.1.0.tgz",
"integrity": "sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==",
"version": "24.2.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.2.0.tgz",
"integrity": "sha512-Yc+HLyldlIC9iIK8xEN7tV960Or56N49MDP7hubCZUeI7EbIOTsas6rXCMB4kQjLACJ7eDOF4xWEO5qumpKsag==",
"dev": true,
"requires": {
"bs-logger": "0.x",
@@ -6373,9 +6451,9 @@
}
},
"typescript": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz",
"integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==",
"version": "3.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz",
"integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==",
"dev": true
},
"uglify-js": {
@@ -6574,6 +6652,12 @@
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
"dev": true
},
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true
},
"wordwrap": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",

View File

@@ -54,16 +54,16 @@
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.12.8",
"@typescript-eslint/parser": "^2.7.0",
"@types/node": "^12.12.14",
"@typescript-eslint/parser": "^2.10.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^6.6.0",
"husky": "^3.0.9",
"eslint": "^6.7.2",
"husky": "^3.1.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"lint-staged": "^9.4.3",
"lint-staged": "^9.5.0",
"prettier": "1.19.1",
"ts-jest": "^24.1.0",
"typescript": "^3.7.2"
"ts-jest": "^24.2.0",
"typescript": "^3.7.3"
}
}

View File

@@ -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`);
}

View File

@@ -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<void> {
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);

View File

@@ -3,6 +3,18 @@ import * as tc from '@actions/tool-cache';
import * as io from '@actions/io';
import getOS from './get-os';
import getURL from './get-url';
import * as path from 'path';
let tempDir: string = process.env['RUNNER_TEMPDIRECTORY'] || '';
if (!tempDir) {
let baseTempLocation: string;
if (process.platform === 'win32') {
baseTempLocation = process.env['USERPROFILE'] || 'C:\\';
} else {
baseTempLocation = `${process.env.HOME}`;
}
tempDir = path.join(baseTempLocation, 'tmp');
}
export default async function installer(version: string) {
try {
@@ -15,23 +27,30 @@ export default async function installer(version: string) {
const hugoURL: string = getURL(osName, extended, version);
core.debug(`hugoURL: ${hugoURL}`);
const hugoPath: string = `${process.env.HOME}/bin`;
let baseLocation: string;
if (process.platform === 'win32') {
baseLocation = process.env['USERPROFILE'] || 'C:\\';
} else {
baseLocation = `${process.env.HOME}`;
}
const hugoPath: string = path.join(baseLocation, 'hugobin');
await io.mkdirP(hugoPath);
core.addPath(hugoPath);
// Download and extract Hugo binary
await io.mkdirP(tempDir);
const hugoAssets: string = await tc.downloadTool(hugoURL);
let hugoBin: string = '';
if (osName === 'Windows') {
const hugoExtractedFolder: string = await tc.extractZip(
hugoAssets,
'/tmp'
tempDir
);
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
} else {
const hugoExtractedFolder: string = await tc.extractTar(
hugoAssets,
'/tmp'
tempDir
);
hugoBin = `${hugoExtractedFolder}/hugo`;
}