minify-html/.github/workflows/nodejs.yml

82 lines
2.4 KiB
YAML
Raw Normal View History

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