103 lines
2.9 KiB
YAML
103 lines
2.9 KiB
YAML
name: Build and publish Node.js package
|
|
|
|
on:
|
|
create:
|
|
tags:
|
|
- 'v*'
|
|
repository_dispatch:
|
|
types: [wf-nodejs]
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
feature: [core, js]
|
|
os: [macos-11.0, ubuntu-18.04, windows-2019]
|
|
include:
|
|
- os: macos-11.0
|
|
ARCH: macos-x86_64
|
|
- os: ubuntu-18.04
|
|
ARCH: linux-x86_64
|
|
- os: windows-2019
|
|
ARCH: windows-x86_64
|
|
runs-on: ${{ matrix.os }}
|
|
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: 15.x
|
|
|
|
- name: Set up Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
default: true
|
|
|
|
- name: Set up GCC (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: .\.github\workflows\gcc.ps1
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.14.0'
|
|
|
|
- name: Run prebuild steps
|
|
shell: bash
|
|
run: bash ./prebuild.sh
|
|
|
|
- name: Build native module
|
|
working-directory: ./nodejs
|
|
shell: bash
|
|
run: |
|
|
node package.json.gen.js ${{ matrix.feature }}
|
|
npm install
|
|
npm run build
|
|
node compress.js
|
|
|
|
- name: Set up Backblaze B2 CLI
|
|
uses: wilsonzlin/setup-b2@v3
|
|
|
|
- name: Upload to B2
|
|
shell: bash
|
|
run: |
|
|
binary_name="$(node -e 'console.log([process.platform, process.arch].join("__"))')"
|
|
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/index.node.gz "minify-html/bin/nodejs/${{ steps.version.outputs.VERSION }}/${{ matrix.feature }}/$binary_name.node.gz"
|
|
package:
|
|
strategy:
|
|
matrix:
|
|
feature: [core, js]
|
|
runs-on: ubuntu-18.04
|
|
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: 15.x
|
|
- name: Pack and publish package
|
|
working-directory: ./nodejs
|
|
run: |
|
|
cat << 'EOF' > .npmrc
|
|
package-lock=false
|
|
//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
|
|
EOF
|
|
cp ../README.md .
|
|
node package.json.gen.js ${{ matrix.feature }}
|
|
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
|
|
npm publish --access public
|
|
fi
|