Skip to content

Commit 8e5b47e

Browse files
feat: add release github job
Resolves #5 on GitHub Co-Authored-by: Sam Clusker <9279784+samclusker@users.noreply.github.com>
1 parent 8663b36 commit 8e5b47e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Check if stable release
20+
id: check
21+
run: |
22+
# align with build-docker.yml: stable only for strict semver tags
23+
if [[ "${{ github.ref_name }}" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
24+
echo "stable=true" >> "$GITHUB_OUTPUT"
25+
else
26+
echo "stable=false" >> "$GITHUB_OUTPUT"
27+
fi
28+
29+
- name: Extract changelog
30+
id: changelog
31+
run: |
32+
tag="${{ github.ref_name }}"
33+
body=$(sed -n "/^\# .*\[${tag}\]/,/^\# .*\[v/{/^\# .*\[v/!p}" CHANGELOG.md || true)
34+
cat >> "$GITHUB_OUTPUT" <<DELIM
35+
body<<EOF
36+
${body}
37+
38+
**Full Changelog**: https://github.com/${{ github.repository }}/blob/${tag}/CHANGELOG.md
39+
EOF
40+
DELIM
41+
42+
- name: Create release
43+
uses: softprops/action-gh-release@v2
44+
with:
45+
body: ${{ steps.changelog.outputs.body }}
46+
draft: false
47+
prerelease: ${{ steps.check.outputs.stable != 'true' }}
48+
make_latest: ${{ steps.check.outputs.stable == 'true' }}

0 commit comments

Comments
 (0)