-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 2.08 KB
/
release.yml
File metadata and controls
57 lines (49 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Release
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ── Release artefact ─────────────────────────────────────────────────────
- name: Build release tarball
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
VERSION="${{ github.ref_name }}"
tar --xform="s%^%${REPO_NAME}-${VERSION}/%" -czf "${REPO_NAME}-${VERSION}.tar.gz" \
--exclude='.git' \
--exclude='docs/node_modules' \
--exclude='docs/.vitepress/dist' \
--exclude='docs/.vitepress/cache' \
--exclude='exe' --exclude='obj' --exclude='mod' \
*
echo "TARBALL=${REPO_NAME}-${VERSION}.tar.gz" >> $GITHUB_ENV
# ── Release notes from CHANGELOG.md ─────────────────────────────────────
- name: Extract release notes from CHANGELOG.md
run: |
python3 - "${{ github.ref_name }}" CHANGELOG.md > release_notes.md <<'PYEOF'
import sys, re
tag, path = sys.argv[1], sys.argv[2]
with open(path) as f:
content = f.read()
pattern = rf'(## \[{re.escape(tag)}\].*?)(?=\n## |\Z)'
match = re.search(pattern, content, re.DOTALL)
print(match.group(1).strip() if match else f"Release {tag}\n\nSee CHANGELOG.md for details.")
PYEOF
# ── Publish GitHub release ───────────────────────────────────────────────
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: release_notes.md
files: |
${{ env.TARBALL }}
scripts/install.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}