Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Node.js package | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
target: | |
- aarch64-unknown-linux-gnu | |
- x86_64-unknown-linux-gnu | |
- aarch64-apple-darwin | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
include: | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-20.04 | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-20.04 | |
- target: aarch64-apple-darwin | |
os: macos-11.0 | |
- target: x86_64-apple-darwin | |
os: macos-11.0 | |
- target: x86_64-pc-windows-msvc | |
os: windows-2019 | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Set up Node.js | |
uses: actions/setup-node@master | |
with: | |
node-version: 17.x | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Set up cross compiler | |
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} | |
working-directory: ./minify-html-nodejs | |
run: | | |
sudo apt install -y gcc-aarch64-linux-gnu | |
- name: Build native module | |
working-directory: ./minify-html-nodejs | |
shell: bash | |
run: | | |
npm install | |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc | |
npm run build-release -- --target ${{ matrix.target }} | |
mv -v index.node plat-pkg/. | |
TARGET=${{ matrix.target }} node plat-pkg/package.json.gen.js | |
- name: Create and publish native package | |
uses: JS-DevTools/npm-publish@v3 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
access: public | |
token: ${{ secrets.NPM_AUTH_TOKEN }} | |
package: ./minify-html-nodejs/plat-pkg | |
package: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Prepare package | |
working-directory: ./minify-html-nodejs | |
run: | | |
# npm refuses to work with symlinks. | |
cp ../README.md . | |
- name: Pack and publish package | |
uses: JS-DevTools/npm-publish@v3 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
access: public | |
token: ${{ secrets.NPM_AUTH_TOKEN }} | |
package: ./minify-html-nodejs |