Skip to content

Commit

Permalink
ci: rework release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Oct 26, 2024
1 parent 0034491 commit 003dcf5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
44 changes: 10 additions & 34 deletions .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
name: build
name: Build

on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
workflow_call:

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true


jobs:
test:
strategy:
matrix:
os:
- windows-2022
- macos-14
- ubuntu-20.04
- windows-latest
- macos-latest
- ubuntu-latest
node:
- 18
- 20
- 22
fail-fast: false
name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -37,38 +36,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- run: npm install
- run: npm run build -- --arch x64
- run: npm run build -- --arch arm64
- run: npm run build_x64
- run: npm run build_arm64
- run: npm test

- uses: actions/upload-artifact@v4
if: github.ref_type == 'tag' && matrix.node == 20
with:
path: prebuilds/**
name: prebuilds-${{matrix.os}}
retention-days: 2

publish:
if: github.ref_type == 'tag'
name: Publish to npm
runs-on: ubuntu-20.04
needs: [test]
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v4
with:
path: prebuilds
pattern: prebuilds-*
merge-multiple: true
- run: tree prebuilds
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
build:
uses: "./.github/workflows/ci.yml"

publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v4
with:
path: prebuilds
pattern: prebuilds-*
merge-multiple: true
- run: tree prebuilds
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"scripts": {
"install": "node-gyp-build",
"build": "prebuildify --napi --strip",
"build_x64": "prebuildify --napi --strip --arch x64",
"build_arm64": "prebuildify --napi --strip --arch arm64",
"rebuild": "node-gyp rebuild",
"test": "node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\""
},
Expand Down

0 comments on commit 003dcf5

Please sign in to comment.