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

95 lines
2.9 KiB
YAML
Raw Normal View History

name: Build and publish Node.js package
on:
create:
tags:
- 'v*'
2020-06-18 21:06:22 -04:00
repository_dispatch:
types: [wf-nodejs]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
2020-06-18 19:49:48 -04:00
node: [8, 9, 10, 11, 12, 13, 14]
include:
- os: macos-latest
ARCH: macos-x86_64
- os: ubuntu-latest
ARCH: linux-x86_64
- os: windows-latest
ARCH: windows-x86_64
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: ${{ matrix.node }}.x
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- 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: |
npm install
npm run build
2020-07-12 02:17:43 -04:00
node compress.js
2020-06-18 19:49:48 -04:00
- 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
shell: bash
2020-06-18 19:49:48 -04:00
run: |
2020-07-03 10:00:10 -04:00
binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')"
2020-06-18 19:49:48 -04:00
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 }}/$binary_name.node.gz"
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')"
- name: Set up Node.js
uses: actions/setup-node@master
with:
2020-06-18 19:49:48 -04:00
node-version: 14.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
npm install
npm run build
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