-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (81 loc) · 2.65 KB
/
Copy pathrelease.yml
File metadata and controls
87 lines (81 loc) · 2.65 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- run: uv build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # full history + tags so we can find the previous tag
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Build release notes from CHANGELOG
env:
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
# Extract the "## <tag> (date)" section up to (but not including) the
# next "## v" heading. CHANGELOG headings look like:
# ## v26.06.101 (2026-06-14)
awk -v tag="$TAG_NAME" '
index($0, "## " tag " ") == 1 { capture = 1; print; next }
capture && /^## v/ { exit }
capture { print }
' CHANGELOG.md > RELEASE_NOTES.md
# Append GitHub-style "Full Changelog" compare link when a prior tag exists.
PREV="$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)"
if [ -n "$PREV" ]; then
{
echo ""
echo "**Full Changelog**: https://github.com/${REPO}/compare/${PREV}...${TAG_NAME}"
} >> RELEASE_NOTES.md
fi
# Fallback to auto-generated notes if the CHANGELOG had no matching section.
if [ -s RELEASE_NOTES.md ]; then
echo "USE_NOTES_FILE=1" >> "$GITHUB_ENV"
else
echo "USE_NOTES_FILE=0" >> "$GITHUB_ENV"
fi
- name: Create release with assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
if [ "${USE_NOTES_FILE}" = "1" ]; then
gh release create "$TAG_NAME" dist/* book/dist/*.epub book/dist/*.pdf \
--repo "$REPO" \
--title "$TAG_NAME" \
--notes-file RELEASE_NOTES.md
else
gh release create "$TAG_NAME" dist/* book/dist/*.epub book/dist/*.pdf \
--repo "$REPO" \
--title "$TAG_NAME" \
--generate-notes
fi