Build and publish Node.js package #9
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: | |
os: [ubuntu-20.04, macos-12, macos-14, windows-2019] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version | |
id: version | |
shell: bash | |
run: | | |
echo "VERSION=$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')" >> $GITHUB_OUTPUT | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
- name: Build native module | |
id: module | |
shell: bash | |
run: | | |
npm install | |
npm run build-release | |
npm test | |
echo "BINARY_NAME=$(node -e 'console.log([process.platform, process.arch].join("__"))')" >> $GITHUB_OUTPUT | |
- name: Upload to R2 | |
run: | | |
node .github/workflows/deploy.js index.node hexo-word-counter/bin/nodejs/${{ steps.version.outputs.VERSION }}/${{ steps.module.outputs.BINARY_NAME }}.node | |
env: | |
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }} | |
SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS_KEY }} | |
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} |