-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (51 loc) · 1.77 KB
/
Copy pathrelease.yml
File metadata and controls
60 lines (51 loc) · 1.77 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check tag matches package.json version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Tag version: $TAG_VERSION"
echo "Package version: $PACKAGE_VERSION"
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "❌ Tag ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
- name: Extract changelog section
id: changelog
run: |
TAG="$GITHUB_REF_NAME"
# Grab the CHANGELOG.md section for this tag, i.e. everything between
# its own '## vX.Y.Z' heading and the next '## ' heading
NOTES=$(awk -v tag="$TAG" '
$0 ~ "^## " tag "([^0-9.]|$)" { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md)
if [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
echo "No changelog entry found for $TAG, falling back to autogenerated notes"
echo "found=false" >> $GITHUB_OUTPUT
else
echo "found=true" >> $GITHUB_OUTPUT
{
echo 'notes<<CHANGELOG_EOF'
echo "$NOTES"
echo 'CHANGELOG_EOF'
} >> $GITHUB_OUTPUT
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.notes }}
generate_release_notes: ${{ steps.changelog.outputs.found == 'false' }}