-
Notifications
You must be signed in to change notification settings - Fork 7
68 lines (58 loc) · 2.38 KB
/
release.yml
File metadata and controls
68 lines (58 loc) · 2.38 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
name: Create GitHub Release
# Creates a GitHub Release when a version tag is pushed.
#
# If a release notes file exists at docs/release-notes/vX.Y.Z.md,
# it is used as the release body (published immediately).
# If no notes file exists, a draft release is created instead —
# someone must write the notes and publish manually.
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
# Detect pre-releases (alpha, beta, rc)
if [[ "$TAG_NAME" =~ (a|b|rc)[0-9]+ ]]; then
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
else
echo "IS_PRERELEASE=false" >> $GITHUB_ENV
fi
- name: Check for release notes file
id: notes
run: |
NOTES_FILE="docs/release-notes/${TAG_NAME}.md"
if [ -f "$NOTES_FILE" ]; then
echo "found=true" >> $GITHUB_OUTPUT
echo "path=${NOTES_FILE}" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: Create release (with notes)
if: steps.notes.outputs.found == 'true'
run: |
gh release create "$TAG_NAME" \
--title "Underworld3 ${TAG_NAME}" \
--notes-file "${{ steps.notes.outputs.path }}" \
${{ env.IS_PRERELEASE == 'true' && '--prerelease' || '' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create draft release (no notes file)
if: steps.notes.outputs.found == 'false'
run: |
gh release create "$TAG_NAME" \
--title "Underworld3 ${TAG_NAME}" \
--draft \
--generate-notes \
--notes "$(printf '> **Release notes not yet written.**\n>\n> No file found at `docs/release-notes/%s.md`.\n> Please add release notes and publish this draft.\n\n---\n\n## Auto-generated commit log\n\n' "$TAG_NAME")$(gh api repos/${{ github.repository }}/releases/generate-notes -f tag_name="$TAG_NAME" --jq '.body' 2>/dev/null || echo 'See commit history for changes.')" \
${{ env.IS_PRERELEASE == 'true' && '--prerelease' || '' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}