2020-01-20 19:42:45 +11:00
name : Build and publish Node.js package
2020-01-01 20:47:49 +11:00
on :
2021-08-06 12:22:24 +10:00
push :
2020-01-01 20:47:49 +11:00
tags :
- 'v*'
2021-07-27 02:14:31 +10:00
workflow_dispatch :
2020-01-01 20:47:49 +11:00
jobs :
2020-01-20 00:23:57 +11:00
build :
2021-08-08 01:48:52 +10:00
runs-on : ${{ matrix.os }}
2020-01-01 20:47:49 +11:00
strategy :
matrix :
2022-08-09 13:47:38 +10:00
os : [ macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64]
2020-01-01 20:47:49 +11:00
steps :
- uses : actions/checkout@v1
2020-07-22 21:56:07 +10:00
2020-01-01 20:47:49 +11:00
- name : Get version
id : version
2020-01-01 23:39:45 +11:00
shell : bash
2020-06-19 13:00:25 +10:00
run : echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
2020-07-22 21:56:07 +10:00
2020-01-01 20:47:49 +11:00
- name : Set up Node.js
uses : actions/setup-node@master
with :
2021-11-12 15:30:37 +11:00
node-version : 17. x
2020-07-22 21:56:07 +10:00
2020-07-22 21:52:54 +10:00
- name : Set up Rust
2020-01-01 20:47:49 +11:00
uses : actions-rs/toolchain@v1
with :
2020-07-03 20:42:10 +10:00
toolchain : stable
2020-01-01 20:47:49 +11:00
profile : minimal
default : true
2020-07-22 21:56:07 +10:00
2020-07-11 23:25:36 +10:00
- name : Run prebuild steps
shell : bash
run : bash ./prebuild.sh
2020-07-22 21:56:07 +10:00
2020-01-01 20:47:49 +11:00
- name : Build native module
working-directory : ./nodejs
2021-08-08 12:54:56 +10:00
id : module
2020-07-11 23:25:36 +10:00
shell : bash
2020-01-01 20:47:49 +11:00
run : |
2020-01-20 00:23:57 +11:00
npm install
2022-06-21 23:03:35 +10:00
npm run build-release
2021-08-08 12:54:56 +10:00
echo ::set-output name=BINARY_NAME::"$(node -e 'console.log([process.platform, process.arch].join("__"))')"
2020-07-22 21:56:07 +10:00
2020-06-19 09:49:48 +10:00
- name : Upload to B2
2021-08-08 12:54:56 +10:00
uses : wilsonzlin/b2-upload-action@v1.0.0
with :
bucket : ${{ secrets.CICD_CLI_B2_BUCKET_NAME }}
2022-06-21 23:03:35 +10:00
uploadKey : minify-html/bin/nodejs/${{ steps.version.outputs.VERSION }}/${{ steps.module.outputs.BINARY_NAME }}.node
2021-08-08 12:54:56 +10:00
keyId : ${{ secrets.CICD_CLI_B2_KEY_ID }}
applicationKey : ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
2022-06-21 23:03:35 +10:00
file : ./nodejs/index.node
2021-08-08 12:54:56 +10:00
2020-01-20 00:23:57 +11:00
package :
2021-04-06 18:50:24 +10:00
runs-on : ubuntu-18.04
2020-01-20 00:23:57 +11:00
needs : build
steps :
- uses : actions/checkout@v1
- name : Get version
id : version
shell : bash
2020-06-19 13:00:25 +10:00
run : echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
2020-01-20 00:23:57 +11:00
- name : Set up Node.js
uses : actions/setup-node@master
with :
2021-11-12 15:30:37 +11:00
node-version : 17. x
2020-01-20 00:23:57 +11:00
- name : Pack and publish package
working-directory : ./nodejs
run : |
2020-01-20 15:10:34 +11:00
cat << 'EOF' > .npmrc
package-lock=false
//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
EOF
2022-06-21 23:03:35 +10:00
# npm refuses to work with symlinks.
2020-01-20 01:13:21 +11:00
cp ../README.md .
2020-06-19 11:44:54 +10:00
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
2020-07-12 01:34:49 +10:00
npm publish --access public
2020-06-19 11:44:54 +10:00
fi