Skip to content

Commit 4d5ef5f

Browse files
authored
Add CI workflow for multi-OS build and release
1 parent ff89cd2 commit 4d5ef5f

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI / Multi-OS Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ] # push a version tag to publish a release
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
name: Build (${{ matrix.os }} / Node ${{ matrix.node }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
node: [20] # add more versions if you want to test multiple
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node }}
24+
cache: npm # npm|yarn|pnpm
25+
26+
- name: Install deps
27+
run: npm ci
28+
29+
- name: Test
30+
run: npm test --if-present
31+
32+
- name: Build
33+
run: npm run build --if-present
34+
35+
- name: Package
36+
run: npm run package --if-present
37+
# e.g. produce ./dist/<platform> files
38+
39+
- name: Upload build artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: ${{ runner.os }}-build
43+
path: |
44+
dist/**
45+
!**/*.map
46+
retention-days: 14
47+
48+
release:
49+
name: Release (attach all builds)
50+
needs: build
51+
if: startsWith(github.ref, 'refs/tags/v')
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: write
55+
steps:
56+
- uses: actions/download-artifact@v4
57+
with:
58+
path: ./artifacts
59+
60+
- name: Create GitHub Release and upload assets
61+
uses: ncipollo/release-action@v1
62+
with:
63+
tag: ${{ github.ref_name }}
64+
generateReleaseNotes: true
65+
artifacts: "artifacts/**/*"

0 commit comments

Comments
 (0)