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

92 lines
3.1 KiB
YAML

name: Build and publish Node.js package
on:
create:
tags:
- 'v*'
repository_dispatch:
types: [wf-nodejs]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Use windows-2016 as windows-2019 has LNK1181 error when building Neon module.
os: [ubuntu-latest, windows-2016, macos-latest]
node: [8, 9, 10, 11, 12, 13, 14]
include:
- os: ubuntu-latest
ARCH: linux-x86_64
- os: windows-2016
ARCH: windows-x86_64
- os: macos-latest
ARCH: macos-x86_64
steps:
- uses: actions/checkout@v1
- name: Get version
id: version
shell: bash
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: ${{ matrix.node }}.x
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build native module
working-directory: ./nodejs
run: |
npm install
node node_modules/neon-cli/bin/cli.js build --release
- name: Install B2 CLI (macOS, Linux)
if: runner.os != 'Windows'
run: |
sudo pip install setuptools
sudo pip install --upgrade b2
- name: Install B2 CLI (Windows)
if: runner.os == 'Windows'
run: |
pip install --upgrade b2
- name: Upload to B2
run: |
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/native/index.node hyperbuild/bin/nodejs/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}-node${{ matrix.node }}.node
package:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v1
- name: Get version
id: version
shell: bash
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: 14.x
- name: Install B2 CLI
run: |
sudo pip install setuptools
sudo pip install --upgrade b2
- name: Pack and publish package
working-directory: ./nodejs
run: |
cat << 'EOF' > .npmrc
package-lock=false
//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
EOF
npm install
rm -rf dist
node node_modules/typescript/bin/tsc
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
b2 sync b2://${{ secrets.CICD_CLI_B2_BUCKET_NAME }}/hyperbuild/bin/nodejs/${{ steps.version.outputs.VERSION }}/ ./dist/.
cp ../README.md .
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
npm publish
fi