Skip to content

Commit 6b91ec6

Browse files
authored
Add GitHub Actions workflow for release artifacts
1 parent 25882f5 commit 6b91ec6

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and attach artifacts on release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-and-attach:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js and pnpm
18+
uses: pnpm/action-setup@v2
19+
with:
20+
node-version: '18'
21+
# optional: pin pnpm-version: '8'
22+
23+
- name: Install dependencies
24+
run: pnpm install --frozen-lockfile
25+
26+
- name: Build
27+
run: pnpm run build --if-present
28+
29+
- name: Prepare artifact directory
30+
run: |
31+
set -e
32+
mkdir -p artifacts
33+
if [ -d "dist" ]; then
34+
cp -r dist artifacts/
35+
else
36+
echo "Error: dist folder not found. Check your build output or build script." >&2
37+
exit 1
38+
fi
39+
tar -czf artifacts/${{ github.ref_name }}-dist.tar.gz -C artifacts .
40+
41+
- name: Upload workflow artifact (keeps a copy in the run)
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: build-${{ github.ref_name }}
45+
path: artifacts/${{ github.ref_name }}-dist.tar.gz
46+
47+
- name: Attach artifact to GitHub Release
48+
uses: softprops/action-gh-release@v1
49+
with:
50+
files: artifacts/${{ github.ref_name }}-dist.tar.gz
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)