Skip to content

Commit e8631a1

Browse files
authored
Merge pull request #10 from foundry-rs/zerosnacks/add-release-flow
chore: add release flow
2 parents c072792 + bca1606 commit e8631a1

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
with:
5959
name: dist
6060
path: dist
61+
if-no-files-found: error
62+
retention-days: 7
6163

6264
codeql:
6365
name: analyze (${{ matrix.language }})

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: release
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "Tag to release (e.g. v1.3.0)"
13+
required: true
14+
type: string
15+
prerelease:
16+
description: "Mark as prerelease"
17+
type: boolean
18+
default: false
19+
required: true
20+
draft:
21+
description: "Create as draft"
22+
type: boolean
23+
default: false
24+
required: true
25+
26+
jobs:
27+
release:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
steps:
32+
- uses: actions/checkout@v5
33+
with:
34+
fetch-depth: 0
35+
persist-credentials: true
36+
37+
- if: github.event_name == 'workflow_dispatch'
38+
run: |
39+
tag="${{ inputs.tag }}"
40+
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
41+
echo "Tag $tag exists"
42+
else
43+
git config user.name "github-actions[bot]"
44+
git config user.email "github-actions[bot]@users.noreply.github.com"
45+
git tag -a "$tag" -m "Release $tag"
46+
git push origin "$tag"
47+
fi
48+
49+
- uses: pnpm/action-setup@v4
50+
with:
51+
version: latest
52+
run_install: false
53+
54+
- uses: actions/setup-node@v6
55+
with:
56+
node-version-file: ".nvmrc"
57+
cache: "pnpm"
58+
59+
- run: pnpm install --frozen-lockfile
60+
- run: pnpm run fmt:check
61+
- run: pnpm run lint:check
62+
- run: pnpm run build
63+
64+
- run: |
65+
tar -czf dist.tar.gz -C dist .
66+
sha256sum dist.tar.gz | tee dist.tar.gz.sha256
67+
68+
- id: meta
69+
run: |
70+
if [ "${{ github.event_name }}" = "push" ]; then
71+
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
72+
else
73+
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
74+
fi
75+
76+
- uses: softprops/action-gh-release@v2
77+
with:
78+
tag_name: ${{ steps.meta.outputs.tag }}
79+
name: ${{ steps.meta.outputs.tag }}
80+
draft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft || false }}
81+
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}
82+
files: |
83+
dist.tar.gz
84+
dist.tar.gz.sha256
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)