mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-25 20:32:19 +01:00
Compare commits
183 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92ca1cb5bb | ||
|
|
1b689687f3 | ||
|
|
76e22f1114 | ||
|
|
490ab9b0a4 | ||
|
|
3d1e811264 | ||
|
|
6a39a0f0e5 | ||
|
|
fbf2ba3b8b | ||
|
|
9d8553d36d | ||
|
|
7d9bfa0c1d | ||
|
|
5ce129c278 | ||
|
|
7496c44053 | ||
|
|
dc9576430f | ||
|
|
3b68672699 | ||
|
|
6a7231ef83 | ||
|
|
4331a62207 | ||
|
|
7dc067063b | ||
|
|
57168bc2bc | ||
|
|
cca78d865e | ||
|
|
bad8e7f80f | ||
|
|
ca3c62d21c | ||
|
|
25520f73cd | ||
|
|
5e6d8b50e2 | ||
|
|
d006b81d18 | ||
|
|
1fa5fb2f2e | ||
|
|
f21cef4446 | ||
|
|
754a1d28dd | ||
|
|
ae65d5c8e9 | ||
|
|
10f36c7c91 | ||
|
|
236e039b5f | ||
|
|
2f904a6aa6 | ||
|
|
2b3acb31e4 | ||
|
|
f14d276121 | ||
|
|
9eb8f9e108 | ||
|
|
69200f8579 | ||
|
|
3cf50c6d11 | ||
|
|
900499cd1c | ||
|
|
da7c321b3b | ||
|
|
739a95f1e7 | ||
|
|
bc6f48c683 | ||
|
|
cf07920706 | ||
|
|
3e0ab3eb25 | ||
|
|
c5ea31b9d7 | ||
|
|
bc06efb2e0 | ||
|
|
3b3c59db47 | ||
|
|
b51e0ae5b4 | ||
|
|
8b813b0c62 | ||
|
|
638f751056 | ||
|
|
d04830441a | ||
|
|
5dc353210f | ||
|
|
129fcc86a6 | ||
|
|
34e697e615 | ||
|
|
608a9dce06 | ||
|
|
bcfd41e8b4 | ||
|
|
0a102fbbed | ||
|
|
ef869fb22f | ||
|
|
1490c6e417 | ||
|
|
ab3f21340f | ||
|
|
3ab6d78f1e | ||
|
|
007cfe211d | ||
|
|
1d2fa2a9c3 | ||
|
|
10b88ee9bf | ||
|
|
b93236ba6f | ||
|
|
535d0e0aa9 | ||
|
|
90fbf33ad8 | ||
|
|
d3401a30a3 | ||
|
|
eb85852ce3 | ||
|
|
3c10f8d88a | ||
|
|
0de12a826f | ||
|
|
5bb02a4a7d | ||
|
|
9aa9bf7c5a | ||
|
|
3be578e3c5 | ||
|
|
ec916d70ad | ||
|
|
d88559854c | ||
|
|
2965e59bb8 | ||
|
|
f0004ebb52 | ||
|
|
0101f0a550 | ||
|
|
c31a671975 | ||
|
|
78c603eb60 | ||
|
|
bbc02a7bb6 | ||
|
|
8e53828e04 | ||
|
|
3fe8ef06d5 | ||
|
|
3e1caf266f | ||
|
|
827a8f8ea5 | ||
|
|
7ed9704167 | ||
|
|
967e91f479 | ||
|
|
46f4f706ee | ||
|
|
5d81587f8c | ||
|
|
71b8a771a4 | ||
|
|
432b4df64a | ||
|
|
199ebd1829 | ||
|
|
9582ca51e5 | ||
|
|
79ff7701be | ||
|
|
ed1ba0af60 | ||
|
|
c57482c110 | ||
|
|
4e9981b947 | ||
|
|
7082e0fbec | ||
|
|
3e55082b3f | ||
|
|
839eb279b0 | ||
|
|
a02eaa1734 | ||
|
|
fa565fb82d | ||
|
|
7404f29555 | ||
|
|
7b66ed001b | ||
|
|
64951c5a73 | ||
|
|
35c74b6a6a | ||
|
|
b5fb138703 | ||
|
|
6f6a564fad | ||
|
|
cd3751ce70 | ||
|
|
07e434d37c | ||
|
|
1405de8b20 | ||
|
|
7346c7bdad | ||
|
|
f1ac6bf271 | ||
|
|
c7b570bed5 | ||
|
|
3ae7dd1270 | ||
|
|
9fdb1cb749 | ||
|
|
e2b52b7b4d | ||
|
|
8e97852759 | ||
|
|
b46070141b | ||
|
|
a1adb3bb7b | ||
|
|
fbb67a3359 | ||
|
|
2e5b1b84d6 | ||
|
|
6d819cab4c | ||
|
|
a6d33f08ac | ||
|
|
71663ea875 | ||
|
|
d7d48e3009 | ||
|
|
39aa1b7d04 | ||
|
|
b10091c0dc | ||
|
|
824187d952 | ||
|
|
e194c83989 | ||
|
|
c3970dfbdd | ||
|
|
082748017c | ||
|
|
79d6bc5f6e | ||
|
|
8f1aef7e73 | ||
|
|
dc8541739a | ||
|
|
4d54b90c0e | ||
|
|
25a3456032 | ||
|
|
4f371785be | ||
|
|
3bbd6d1917 | ||
|
|
d46d0aa12e | ||
|
|
85171ece4e | ||
|
|
624c2a083b | ||
|
|
7a9975a8b1 | ||
|
|
c635fd9746 | ||
|
|
19661a5c56 | ||
|
|
c4f3b85a0d | ||
|
|
68358aa004 | ||
|
|
ded0a1ada3 | ||
|
|
b7618725f9 | ||
|
|
38f4938bc6 | ||
|
|
d8740dd53b | ||
|
|
2d9de755b5 | ||
|
|
eb817c8e92 | ||
|
|
672bb33daa | ||
|
|
26378c050c | ||
|
|
dd1c91caf4 | ||
|
|
db1611bb0d | ||
|
|
03083c655e | ||
|
|
3439246b4a | ||
|
|
b2c2768a0c | ||
|
|
ff9b678d15 | ||
|
|
a2e4fdca67 | ||
|
|
55565fc0f6 | ||
|
|
79fb16c8e4 | ||
|
|
d08dcd0297 | ||
|
|
1daa8a255f | ||
|
|
46fbb349ce | ||
|
|
d079faea7e | ||
|
|
b9842008ed | ||
|
|
021efbc871 | ||
|
|
b8232e8a2c | ||
|
|
b101526f7f | ||
|
|
f7fd45cb9e | ||
|
|
09ca2911f5 | ||
|
|
105e2e8ee3 | ||
|
|
8b3fa9ae0a | ||
|
|
436e91ba84 | ||
|
|
89821efd90 | ||
|
|
6c2c819571 | ||
|
|
2245725e24 | ||
|
|
4c383b0116 | ||
|
|
3bb910b746 | ||
|
|
439a9e3bd9 | ||
|
|
08e26ca0cf | ||
|
|
ef0630bb4c |
9
.dependabot/config.yml
Normal file
9
.dependabot/config.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
version: 1
|
||||
update_configs:
|
||||
- package_manager: "javascript"
|
||||
directory: "/"
|
||||
update_schedule: "weekly"
|
||||
default_labels:
|
||||
- "dependencies"
|
||||
commit_message:
|
||||
prefix: "deps"
|
||||
@@ -1,5 +1,7 @@
|
||||
.git
|
||||
.github
|
||||
LICENSE
|
||||
README.md
|
||||
images
|
||||
.*
|
||||
|
||||
!.eslintrc.json
|
||||
!.prettierrc.json
|
||||
|
||||
coverage
|
||||
node_modules
|
||||
|
||||
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2019
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
3
.github/CODEOWNERS
vendored
Normal file
3
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
|
||||
|
||||
* @peaceiris
|
||||
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: 'Bug: This is a sample issue title'
|
||||
labels: bug
|
||||
assignees: peaceiris
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Your YAML file**
|
||||
- A link to your repository
|
||||
- A link to your YAML file
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: GitHub Actions Community Forum
|
||||
url: https://github.community/t5/GitHub-Actions/bd-p/actions
|
||||
about: Please ask questions about GitHub Actions here.
|
||||
- name: Hugo Community Forum
|
||||
url: https://discourse.gohugo.io/
|
||||
about: Please ask questions about Hugo here.
|
||||
20
.github/ISSUE_TEMPLATE/proposal.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/proposal.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Proposal
|
||||
about: Suggest an idea for this project
|
||||
title: 'proposal: This is a sample title'
|
||||
labels: proposal
|
||||
assignees: peaceiris
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
9
.github/main.workflow
vendored
9
.github/main.workflow
vendored
@@ -1,9 +0,0 @@
|
||||
workflow "Main workflow" {
|
||||
on = "push"
|
||||
resolves = ["docker-build"]
|
||||
}
|
||||
|
||||
action "docker-build" {
|
||||
uses = "actions/docker/cli@master"
|
||||
args = "build -t peaceiris/actions-hugo ."
|
||||
}
|
||||
16
.github/workflows/purge-readme-image-cache.yml
vendored
Normal file
16
.github/workflows/purge-readme-image-cache.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Purge image cache
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '4 18 * * */7'
|
||||
|
||||
jobs:
|
||||
purge:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
|
||||
- run: >
|
||||
curl -sL https://github.com/${GITHUB_REPOSITORY} |
|
||||
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
|
||||
sed -e 's/<img src="//' |
|
||||
xargs -I % curl -sX PURGE %
|
||||
43
.github/workflows/release.yml
vendored
Normal file
43
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "${GITHUB_CONTEXT}"
|
||||
|
||||
- name: Install hub
|
||||
run: |
|
||||
HUB_VERSION="2.13.0"
|
||||
HUB_NAME="hub-linux-amd64-${HUB_VERSION}"
|
||||
HUB_TARBALL="${HUB_NAME}.tgz"
|
||||
wget -q "https://github.com/github/hub/releases/download/v${HUB_VERSION}/${HUB_TARBALL}"
|
||||
tar -zxvf "./${HUB_TARBALL}"
|
||||
mkdir ~/bin
|
||||
cp "./${HUB_NAME}/bin/hub" ~/bin/
|
||||
echo "::add-path::~/bin/"
|
||||
rm -rf "./${HUB_NAME}" "./${HUB_TARBALL}"
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG_NAME="${GITHUB_REF##refs/tags/}"
|
||||
echo "See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/${TAG_NAME}/CHANGELOG.md) for more details." > ./release_notes.md
|
||||
sed -i "1iRelease ${TAG_NAME}\n" ./release_notes.md
|
||||
hub release create \
|
||||
--draft \
|
||||
--prerelease \
|
||||
--file ./release_notes.md \
|
||||
"${TAG_NAME}"
|
||||
17
.github/workflows/stale.yml
vendored
Normal file
17
.github/workflows/stale.yml
vendored
Normal 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
|
||||
89
.github/workflows/test.yml
vendored
Normal file
89
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
name: 'Test'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
skipci:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}"
|
||||
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: contains(github.event.head_commit.message, '[skip ci]') == false
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- 'ubuntu-18.04'
|
||||
- 'macos-latest'
|
||||
- 'windows-latest'
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Read .nvmrc
|
||||
run: echo "::set-output name=NVMRC::$(cat .nvmrc)"
|
||||
id: nvm
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '${{ steps.nvm.outputs.NVMRC }}'
|
||||
|
||||
- name: Get npm cache directory
|
||||
id: npm-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(npm config get cache)"
|
||||
|
||||
- name: Cache npm
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.npm-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Run prettier
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: npm run format:check
|
||||
|
||||
- name: Run eslint
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: npm run lint
|
||||
|
||||
- name: Run ncc
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: npm run build
|
||||
|
||||
- run: npm test
|
||||
|
||||
- name: Upload test coverage as artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
|
||||
# - name: Upload test coverage to Coveralls
|
||||
# uses: coverallsapp/github-action@v1.0.1
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel: true
|
||||
#
|
||||
# - name: Coveralls Finished
|
||||
# uses: coverallsapp/github-action@v1.0.1
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel-finished: true
|
||||
23
.github/workflows/update-major-tag.yml
vendored
Normal file
23
.github/workflows/update-major-tag.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Update major tag
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- 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 --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
|
||||
git push --force origin "${TAG_MAJOR}"
|
||||
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
coverage
|
||||
.npm
|
||||
.eslintcache
|
||||
.env
|
||||
node_modules
|
||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid",
|
||||
"parser": "typescript"
|
||||
}
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
54
CHANGELOG.md
Normal file
54
CHANGELOG.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
# [2.4.0](https://github.com/peaceiris/actions-hugo/compare/v2.3.2...v2.4.0) (2020-01-17)
|
||||
|
||||
|
||||
### chore
|
||||
|
||||
* Add .DS_Store [skip ci] ([5ce129c](https://github.com/peaceiris/actions-hugo/commit/5ce129c278027bbd0b3d4fb967ea86543f719c7a))
|
||||
* Add .gitattributes ([754a1d2](https://github.com/peaceiris/actions-hugo/commit/754a1d28dd8649e5a1151164c990298f36a093d4))
|
||||
* Add standard-version [skip ci] ([dc95764](https://github.com/peaceiris/actions-hugo/commit/dc9576430f57dfabaa663af12d5dcd1210c1b155))
|
||||
* Add task to autorun npm ci [skip ci] (#128) ([4331a62](https://github.com/peaceiris/actions-hugo/commit/4331a62207ee1604966b28fa32ba5d1ae1b30c6a)), closes [#128](https://github.com/peaceiris/actions-hugo/issues/128)
|
||||
* Disable branch execution (#125) ([7dc0670](https://github.com/peaceiris/actions-hugo/commit/7dc067063bb67b1e59949161e3be905ed40e3c31)), closes [#125](https://github.com/peaceiris/actions-hugo/issues/125)
|
||||
* fix tag push ([f21cef4](https://github.com/peaceiris/actions-hugo/commit/f21cef4446db8a2c47e78208d14acc25c3f5cf51))
|
||||
* Remove .gitattributes [skip ci] ([3b68672](https://github.com/peaceiris/actions-hugo/commit/3b6867269979eef7d5bdd6de65470678a7e33604))
|
||||
* Update LICENSE year ([57168bc](https://github.com/peaceiris/actions-hugo/commit/57168bc2bc3981bfabde15282e9c81dd9f5300ac))
|
||||
|
||||
### ci
|
||||
|
||||
* Add [skip ci] ([fbf2ba3](https://github.com/peaceiris/actions-hugo/commit/fbf2ba3b8ba09038d81bcd17fe9dfe0e4d7190ff))
|
||||
* Add release workflow [skip ci] ([9d8553d](https://github.com/peaceiris/actions-hugo/commit/9d8553d36d52e040d2bcdd9092544fe6df5bcb91))
|
||||
* Enhance tag creation ([7d9bfa0](https://github.com/peaceiris/actions-hugo/commit/7d9bfa0c1d5a9fe98246cf06033890d624a717f0))
|
||||
|
||||
### deps
|
||||
|
||||
* update (#118) ([bad8e7f](https://github.com/peaceiris/actions-hugo/commit/bad8e7f80f8fb90e4fc8297535d1c5c8102240d4)), closes [#118](https://github.com/peaceiris/actions-hugo/issues/118)
|
||||
* update (#126) ([6a7231e](https://github.com/peaceiris/actions-hugo/commit/6a7231ef834e01c9eb84b15f1432d42804f7c69a)), closes [#126](https://github.com/peaceiris/actions-hugo/issues/126)
|
||||
* upgrade node v12.14.1 (#119) ([cca78d8](https://github.com/peaceiris/actions-hugo/commit/cca78d865e24a18ed38b19dfc4bf0c7130c4c232)), closes [#119](https://github.com/peaceiris/actions-hugo/issues/119)
|
||||
|
||||
### docs
|
||||
|
||||
* Add back to TOC link ([490ab9b](https://github.com/peaceiris/actions-hugo/commit/490ab9b0a4d95458b58203661788d6499f27d573))
|
||||
* add link to peaceiris/hugo-extended-docker ([1fa5fb2](https://github.com/peaceiris/actions-hugo/commit/1fa5fb2f2eda35bda254f126aa066972de95cfbd))
|
||||
* Add new sections ([3d1e811](https://github.com/peaceiris/actions-hugo/commit/3d1e8112641c5fafdd12e5e4cf4f359ac289ce71))
|
||||
* Bump Hugo version v0.62.2 ([6a39a0f](https://github.com/peaceiris/actions-hugo/commit/6a39a0f0e57bc115c411920fe91ae0144ff26b7e))
|
||||
* Reindent [skip ci] ([76e22f1](https://github.com/peaceiris/actions-hugo/commit/76e22f1114f4fdfe2db25ff96bf65b4c513a942c))
|
||||
* update hugo-version to v0.61.0 ([d006b81](https://github.com/peaceiris/actions-hugo/commit/d006b81d1845f59bb755a221aff0b61bbff15375))
|
||||
|
||||
### feat
|
||||
|
||||
* update deps (#104) ([5e6d8b5](https://github.com/peaceiris/actions-hugo/commit/5e6d8b50e242b4f27b9794f002a74032f4abb8f1)), closes [#104](https://github.com/peaceiris/actions-hugo/issues/104)
|
||||
* update deps (#110) ([ca3c62d](https://github.com/peaceiris/actions-hugo/commit/ca3c62d21c77504550e4eba47456f9001d2c64ab)), closes [#110](https://github.com/peaceiris/actions-hugo/issues/110)
|
||||
* update node 12.14.0 (#105) ([25520f7](https://github.com/peaceiris/actions-hugo/commit/25520f73cde6077d55cce09381b4121d83264fff)), closes [#105](https://github.com/peaceiris/actions-hugo/issues/105)
|
||||
|
||||
### test
|
||||
|
||||
* Add Docker container for testing [skip ci] ([7496c44](https://github.com/peaceiris/actions-hugo/commit/7496c44053ad339cde271140b13a6c3e5385f596))
|
||||
|
||||
|
||||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
27
Dockerfile
27
Dockerfile
@@ -1,27 +0,0 @@
|
||||
FROM debian:9-slim
|
||||
|
||||
LABEL "com.github.actions.name"="Hugo extended action"
|
||||
LABEL "com.github.actions.description"="GitHub Actions for Hugo extended version"
|
||||
LABEL "com.github.actions.icon"="package"
|
||||
LABEL "com.github.actions.color"="yellow"
|
||||
|
||||
LABEL "repository"="https://github.com/peaceiris/actions-hugo"
|
||||
LABEL "homepage"="https://github.com/peaceiris/actions-hugo"
|
||||
LABEL "maintainer"="peaceiris"
|
||||
|
||||
ENV HUGO_VERSION='0.55.6'
|
||||
ENV HUGO_NAME="hugo_extended_${HUGO_VERSION}_Linux-64bit"
|
||||
ENV HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_NAME}.deb"
|
||||
ENV BUILD_DEPS="wget"
|
||||
|
||||
RUN apt-get update && apt-get upgrade -y && \
|
||||
apt-get install -y git "${BUILD_DEPS}" && \
|
||||
wget "${HUGO_URL}" && \
|
||||
apt-get install "./${HUGO_NAME}.deb" && \
|
||||
rm -rf "./${HUGO_NAME}.deb" "${HUGO_NAME}" && \
|
||||
apt-get remove -y "${BUILD_DEPS}" && \
|
||||
apt-get autoremove -y && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/hugo" ]
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Shohei Ueda (peaceiris)
|
||||
Copyright (c) 2020 Shohei Ueda (peaceiris)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
22
Makefile
Normal file
22
Makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
cmd := "bash"
|
||||
msg := ""
|
||||
IMAGE_NAME := actions-hugo-dev:latest
|
||||
DOCKER_BUILD := docker build . -t $(IMAGE_NAME) --file ./__tests__/Dockerfile
|
||||
DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/etc/gitconfig $(IMAGE_NAME)
|
||||
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
$(DOCKER_BUILD)
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
$(DOCKER_RUN) $(cmd)
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
$(DOCKER_RUN) npm test
|
||||
|
||||
.PHONY: commit
|
||||
commit:
|
||||
$(DOCKER_RUN) git commit -m "$(msg)"
|
||||
223
README.md
223
README.md
@@ -1,43 +1,236 @@
|
||||
[](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE)
|
||||
[](https://github.com/peaceiris/actions-hugo/releases/latest)
|
||||
[](https://github.com/peaceiris/actions-hugo/releases)
|
||||

|
||||
[](https://www.codefactor.io/repository/github/peaceiris/actions-hugo)
|
||||
|
||||
<img width="400" alt="GitHub Actions for Hugo extended" src="./images/ogp.svg">
|
||||
<img width="400" alt="GitHub Actions for Hugo" src="./images/ogp.svg">
|
||||
|
||||
|
||||
|
||||
## GitHub Actions for Hugo extended
|
||||
## GitHub Actions for Hugo
|
||||
|
||||
- [gohugoio/hugo: The world’s 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.
|
||||
|
||||
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 |
|
||||
|---|:---:|:---:|:---:|
|
||||
| Support | ✅️ | ✅️ | ✅️ |
|
||||
|
||||
| Hugo type | Hugo Extended | Hugo Modules | Latest Hugo |
|
||||
|---|:---:|:---:|:---:|
|
||||
| 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 -->
|
||||
|
||||
|
||||
- [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)
|
||||
- [CHANGELOG](#changelog)
|
||||
- [License](#license)
|
||||
- [About Maintainer](#about-maintainer)
|
||||
- [Maintainer Notes](#maintainer-notes)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
### Create `main.workflow`
|
||||
### ⭐️ Create your workflow
|
||||
|
||||
```hcl
|
||||
workflow "Main workflow" {
|
||||
on = "push"
|
||||
resolves = ["hugo"]
|
||||
}
|
||||
An example workflow `.github/workflows/gh-pages.yml` with [GitHub Actions for GitHub Pages]
|
||||
|
||||
action "hugo" {
|
||||
uses = "peaceiris/actions-hugo@v0.55.6"
|
||||
args = ["--gc", "--minify", "--cleanDestinationDir"]
|
||||
}
|
||||
[GitHub Actions for GitHub Pages]: https://github.com/peaceiris/actions-gh-pages
|
||||
|
||||
[](https://github.com/peaceiris/actions-gh-pages)
|
||||
|
||||

|
||||

|
||||
|
||||
```yaml
|
||||
name: github pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
# with:
|
||||
# submodules: true
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: '0.62.2'
|
||||
# extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --minify
|
||||
|
||||
- name: Deploy
|
||||
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
|
||||
|
||||
### ⭐️ Use Hugo extended
|
||||
|
||||
Set `extended: true` to use a Hugo extended version.
|
||||
|
||||
```yaml
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: '0.62.2'
|
||||
extended: true
|
||||
```
|
||||
|
||||
### ⭐️ Use the latest version of Hugo
|
||||
|
||||
Set `hugo-version: 'latest'` to use the latest version of Hugo.
|
||||
|
||||
```yaml
|
||||
- name: Setup Hugo
|
||||
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.62.2
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
The alpine base Hugo Docker image is provided on the following repository.
|
||||
|
||||
> [peaceiris/hugo-extended-docker: Hugo alpine base Docker image (Hugo extended and Hugo Modules)](https://github.com/peaceiris/hugo-extended-docker)
|
||||
|
||||
<div align="right">
|
||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
## CHANGELOG
|
||||
|
||||
- [CHANGELOG.md](CHANGELOG.md)
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT License - peaceiris/actions-hugo]
|
||||
- [MIT License - peaceiris/actions-hugo]
|
||||
|
||||
[MIT License - peaceiris/actions-hugo]: https://github.com/peaceiris/actions-hugo/blob/master/LICENSE
|
||||
|
||||
|
||||
|
||||
## Supprt author
|
||||
## About Maintainer
|
||||
|
||||
<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a>
|
||||
- [peaceiris homepage](https://peaceiris.com/)
|
||||
|
||||
|
||||
|
||||
## Maintainer Notes
|
||||
|
||||
Run `npm` and `git commit` commands on a container.
|
||||
|
||||
**On Host**
|
||||
|
||||
```sh
|
||||
# Docker
|
||||
make build
|
||||
make run
|
||||
make run cmd="env"
|
||||
make test
|
||||
make commit msg="chore: Add Makefile"
|
||||
|
||||
# Release
|
||||
./release.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
<div align="right">
|
||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||
</div>
|
||||
|
||||
11
__tests__/Dockerfile
Normal file
11
__tests__/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM node:12-slim
|
||||
|
||||
WORKDIR /repo
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install --no-install-recommends \
|
||||
git \
|
||||
bash && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
CMD [ "bash" ]
|
||||
15
__tests__/get-os.test.ts
Normal file
15
__tests__/get-os.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import getOS from '../src/get-os';
|
||||
|
||||
describe('getOS', () => {
|
||||
test('test', () => {
|
||||
expect(getOS('linux')).toBe('Linux');
|
||||
expect(getOS('darwin')).toBe('macOS');
|
||||
expect(getOS('win32')).toBe('Windows');
|
||||
});
|
||||
|
||||
test('test exception', () => {
|
||||
expect(() => {
|
||||
getOS('centos');
|
||||
}).toThrowError('centos is not supported');
|
||||
});
|
||||
});
|
||||
19
__tests__/get-url.test.ts
Normal file
19
__tests__/get-url.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import getURL from '../src/get-url';
|
||||
|
||||
describe('getURL()', () => {
|
||||
test('test', () => {
|
||||
const baseURL =
|
||||
'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
||||
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
|
||||
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
|
||||
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);
|
||||
});
|
||||
});
|
||||
18
action.yml
Normal file
18
action.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
name: 'Hugo setup'
|
||||
description: 'GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended and Hugo Modules are supported.'
|
||||
author: 'peaceiris'
|
||||
inputs:
|
||||
hugo-version:
|
||||
description: 'The Hugo version to download (if necessary) and use. Example: 0.58.2'
|
||||
required: false
|
||||
default: 'latest'
|
||||
extended:
|
||||
description: 'Download (if necessary) and use Hugo extended version. Example: true'
|
||||
required: false
|
||||
default: 'false'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/index.js'
|
||||
branding:
|
||||
icon: 'package'
|
||||
color: 'yellow'
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 258 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB |
11
jest.config.js
Normal file
11
jest.config.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
4994
lib/index.js
Normal file
4994
lib/index.js
Normal file
File diff suppressed because it is too large
Load Diff
8320
package-lock.json
generated
Normal file
8320
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
72
package.json
Normal file
72
package.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "hugo-action",
|
||||
"version": "2.4.0",
|
||||
"description": "Hugo setup action",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint ./src/**/*.ts",
|
||||
"lint:fix": "eslint --fix ./src/**/*.ts",
|
||||
"test": "jest --coverage --verbose",
|
||||
"build": "ncc build ./src/index.ts -o lib",
|
||||
"tsc": "tsc",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format:check": "prettier --check **/*.ts",
|
||||
"release": "standard-version",
|
||||
"update-deps": "(git diff 'HEAD@{1}' --name-only | grep 'package-lock.json' > /dev/null) && npm ci || :"
|
||||
},
|
||||
"husky": {
|
||||
"skipCI": true,
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"post-merge": "npm run update-deps; git remote prune origin"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.ts": [
|
||||
"prettier --check",
|
||||
"eslint",
|
||||
"jest --bail --findRelatedTests",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/peaceiris/actions-hugo.git"
|
||||
},
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
"Actions",
|
||||
"JavaScript",
|
||||
"TypeScript",
|
||||
"Hugo",
|
||||
"Setup"
|
||||
],
|
||||
"author": "peaceiris",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/peaceiris/actions-hugo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/peaceiris/actions-hugo#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.1",
|
||||
"@actions/exec": "^1.0.3",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.3.0",
|
||||
"xmlhttprequest": "^1.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.9.0",
|
||||
"@types/node": "^13.1.7",
|
||||
"@typescript-eslint/parser": "^2.16.0",
|
||||
"@zeit/ncc": "^0.21.0",
|
||||
"eslint": "^6.8.0",
|
||||
"husky": "^4.0.10",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^24.9.0",
|
||||
"lint-staged": "^9.5.0",
|
||||
"prettier": "1.19.1",
|
||||
"standard-version": "^7.0.1",
|
||||
"ts-jest": "^24.3.0",
|
||||
"typescript": "^3.7.5"
|
||||
}
|
||||
}
|
||||
48
release.sh
Executable file
48
release.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# fail on unset variables and command errors
|
||||
set -eu -o pipefail # -x: is for debugging
|
||||
|
||||
if [ "$(git branch --show-current)" != "master" ]; then
|
||||
echo "$0: Current branch is not master" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_TYPE_LIST="prerelease prepatch patch preminor minor major premajor"
|
||||
if command -v fzf; then
|
||||
RELEASE_TYPE=$(echo "${RELEASE_TYPE_LIST}" | tr ' ' '\n' | fzf --layout=reverse)
|
||||
else
|
||||
select sel in ${RELEASE_TYPE_LIST}; do
|
||||
RELEASE_TYPE="${sel}"
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$0: Create ${RELEASE_TYPE} release, continue? (y/n)"
|
||||
read -r res
|
||||
if [ "${res}" = "n" ]; then
|
||||
echo "$0: Stop script"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git fetch origin
|
||||
git pull origin master
|
||||
git tag -d v2
|
||||
git pull origin --tags
|
||||
|
||||
npm ci
|
||||
|
||||
mkdir ./lib
|
||||
npm run build
|
||||
git add ./lib/index.js
|
||||
git commit -m "chore(release): Add build assets"
|
||||
|
||||
npm run release -- --release-as "${RELEASE_TYPE}" --preset eslint
|
||||
|
||||
git rm ./lib/index.js
|
||||
rm -rf ./lib
|
||||
git commit -m "chore(release): Remove build assets [skip ci]"
|
||||
|
||||
TAG_NAME="v$(jq -r '.version' ./package.json)"
|
||||
git push origin master
|
||||
git push origin "${TAG_NAME}"
|
||||
19
src/get-latest-version.ts
Normal file
19
src/get-latest-version.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
|
||||
|
||||
export default function getLatestVersion(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const url: string = 'https://formulae.brew.sh/api/formula/hugo.json';
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
const result = JSON.parse(xhr.responseText);
|
||||
const latestVersion: string = result.versions.stable;
|
||||
resolve(latestVersion);
|
||||
} else if (xhr.readyState === 4 && xhr.status !== 200) {
|
||||
reject(`ERROR: got status ${xhr.status} of ${url}`);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
11
src/get-os.ts
Normal file
11
src/get-os.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function getOS(platform: string) {
|
||||
if (platform === 'linux') {
|
||||
return 'Linux';
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macOS';
|
||||
} else if (platform === 'win32') {
|
||||
return 'Windows';
|
||||
} else {
|
||||
throw new Error(`${platform} is not supported`);
|
||||
}
|
||||
}
|
||||
31
src/get-url.ts
Normal file
31
src/get-url.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export default function getURL(
|
||||
os: string,
|
||||
extended: string,
|
||||
version: string
|
||||
): string {
|
||||
const extendedStr = (extended: string) => {
|
||||
if (extended === 'true') {
|
||||
return 'extended_';
|
||||
} else {
|
||||
return '';
|
||||
// } else {
|
||||
// throw new Error(`Invalid input (extended): ${extended}`);
|
||||
}
|
||||
};
|
||||
|
||||
const ext = (os: string) => {
|
||||
if (os === 'Windows') {
|
||||
return 'zip';
|
||||
} else {
|
||||
return 'tar.gz';
|
||||
}
|
||||
};
|
||||
|
||||
const hugoName: string = `hugo_${extendedStr(
|
||||
extended
|
||||
)}${version}_${os}-64bit`;
|
||||
const baseURL: string = 'https://github.com/gohugoio/hugo/releases/download';
|
||||
const url: string = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
|
||||
|
||||
return url;
|
||||
}
|
||||
36
src/index.ts
Normal file
36
src/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import getLatestVersion from './get-latest-version';
|
||||
import installer from './installer';
|
||||
|
||||
// most @actions toolkit packages have async methods
|
||||
async function run() {
|
||||
const showVersion = async () => {
|
||||
await exec.exec('hugo version');
|
||||
};
|
||||
|
||||
try {
|
||||
const hugoVersion: string = core.getInput('hugo-version');
|
||||
|
||||
if (hugoVersion === '' || hugoVersion === 'latest') {
|
||||
getLatestVersion().then(
|
||||
async function(latestVersion): Promise<void> {
|
||||
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
|
||||
await installer(latestVersion);
|
||||
await showVersion();
|
||||
},
|
||||
function(error) {
|
||||
core.setFailed(error);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
console.log(`Hugo version: ${hugoVersion}`);
|
||||
await installer(hugoVersion);
|
||||
await showVersion();
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
61
src/installer.ts
Normal file
61
src/installer.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import * as core from '@actions/core';
|
||||
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 {
|
||||
const extended: string = core.getInput('extended');
|
||||
console.log(`Hugo extended: ${extended}`);
|
||||
|
||||
const osName: string = getOS(process.platform);
|
||||
console.log(`Operating System: ${osName}`);
|
||||
|
||||
const hugoURL: string = getURL(osName, extended, version);
|
||||
core.debug(`hugoURL: ${hugoURL}`);
|
||||
|
||||
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,
|
||||
tempDir
|
||||
);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
} else {
|
||||
const hugoExtractedFolder: string = await tc.extractTar(
|
||||
hugoAssets,
|
||||
tempDir
|
||||
);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
}
|
||||
await io.mv(hugoBin, hugoPath);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
63
tsconfig.json
Normal file
63
tsconfig.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
"removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user