2020-01-20 03:42:45 -05:00
|
|
|
name: Build and publish Node.js package
|
2020-01-01 04:47:49 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
create:
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
2020-06-18 21:06:22 -04:00
|
|
|
repository_dispatch:
|
|
|
|
types: [wf-nodejs]
|
2020-01-01 04:47:49 -05:00
|
|
|
|
|
|
|
jobs:
|
2020-01-19 08:23:57 -05:00
|
|
|
build:
|
2020-01-01 04:47:49 -05:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-01-05 23:59:40 -05:00
|
|
|
os: [macos-11.0, ubuntu-latest, windows-latest]
|
2020-01-01 04:47:49 -05:00
|
|
|
include:
|
2021-01-05 23:59:40 -05:00
|
|
|
- os: macos-11.0
|
2020-01-01 04:47:49 -05:00
|
|
|
ARCH: macos-x86_64
|
2020-07-22 07:52:54 -04:00
|
|
|
- os: ubuntu-latest
|
|
|
|
ARCH: linux-x86_64
|
2020-07-24 02:09:15 -04:00
|
|
|
- os: windows-latest
|
2020-07-22 07:52:54 -04:00
|
|
|
ARCH: windows-x86_64
|
2020-01-01 04:47:49 -05:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-01-01 04:47:49 -05:00
|
|
|
- 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')"
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-01-01 04:47:49 -05:00
|
|
|
- name: Set up Node.js
|
|
|
|
uses: actions/setup-node@master
|
|
|
|
with:
|
2020-07-24 02:09:15 -04:00
|
|
|
node-version: 14.x
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-07-22 07:52:54 -04:00
|
|
|
- name: Set up Rust
|
2020-01-01 04:47:49 -05:00
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2020-07-03 06:42:10 -04:00
|
|
|
toolchain: stable
|
2020-01-01 04:47:49 -05:00
|
|
|
profile: minimal
|
|
|
|
default: true
|
2020-07-22 07:56:07 -04:00
|
|
|
|
|
|
|
- name: Set up GCC (Windows)
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
run: .\.github\workflows\gcc.ps1
|
|
|
|
|
2020-07-10 11:33:38 -04:00
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: '^1.14.0'
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-07-11 09:25:36 -04:00
|
|
|
- name: Run prebuild steps
|
|
|
|
shell: bash
|
|
|
|
run: bash ./prebuild.sh
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-01-01 04:47:49 -05:00
|
|
|
- name: Build native module
|
|
|
|
working-directory: ./nodejs
|
2020-07-11 09:25:36 -04:00
|
|
|
shell: bash
|
2020-01-01 04:47:49 -05:00
|
|
|
run: |
|
2020-01-19 08:23:57 -05:00
|
|
|
npm install
|
2020-07-22 07:52:54 -04:00
|
|
|
npm run build
|
2020-07-12 02:17:43 -04:00
|
|
|
node compress.js
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-11-13 06:15:51 -05:00
|
|
|
- name: Set up Backblaze B2 CLI
|
|
|
|
uses: wilsonzlin/setup-b2@v3
|
2020-07-22 07:56:07 -04:00
|
|
|
|
2020-06-18 19:49:48 -04:00
|
|
|
- name: Upload to B2
|
2020-07-04 06:35:48 -04:00
|
|
|
shell: bash
|
2020-06-18 19:49:48 -04:00
|
|
|
run: |
|
2020-07-24 02:08:14 -04:00
|
|
|
binary_name="$(node -e 'console.log([process.platform, process.arch].join("__"))')"
|
2020-06-18 19:49:48 -04:00
|
|
|
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
|
2020-07-22 07:52:54 -04:00
|
|
|
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/index.node.gz "minify-html/bin/nodejs/${{ steps.version.outputs.VERSION }}/$binary_name.node.gz"
|
2020-01-19 08:23:57 -05:00
|
|
|
package:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
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')"
|
2020-01-19 08:23:57 -05:00
|
|
|
- name: Set up Node.js
|
|
|
|
uses: actions/setup-node@master
|
|
|
|
with:
|
2020-06-18 19:49:48 -04:00
|
|
|
node-version: 14.x
|
2020-01-19 08:23:57 -05:00
|
|
|
- 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
|
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
|