Skip to content

Commit 33520ec

Browse files
committed
Fix release workflow
1 parent faf3b70 commit 33520ec

1 file changed

Lines changed: 53 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'v*.*.*'
6+
- 'v*'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
build-and-package:
1114
strategy:
@@ -74,9 +77,47 @@ jobs:
7477
path: slick-socket-*.zip
7578
retention-days: 30
7679

80+
extract-changelog:
81+
runs-on: ubuntu-latest
82+
outputs:
83+
version: ${{ steps.get_version.outputs.VERSION }}
84+
changelog: ${{ steps.changelog.outputs.CHANGELOG_CONTENT }}
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v4
88+
89+
- name: Extract version from tag
90+
id: get_version
91+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
92+
93+
- name: Extract changelog for this version
94+
id: changelog
95+
run: |
96+
if [ -f CHANGELOG ]; then
97+
# Extract the section for this version from CHANGELOG
98+
VERSION="${{ github.ref_name }}"
99+
# Remove any suffix after the version (e.g., -test, -rc1)
100+
VERSION_CLEAN=$(echo "$VERSION" | sed 's/-.*$//')
101+
# Escape dots in version for regex
102+
VERSION_ESCAPED=$(echo "$VERSION_CLEAN" | sed 's/\./\\./g')
103+
# Use awk to extract content: start at version header (format: v1.5.2 - [date]), stop at next version header
104+
CHANGES=$(awk "BEGIN{p=0} /^#$VERSION_ESCAPED/{p=1;next} /^#/{p=0} p" CHANGELOG | sed '/^$/d')
105+
106+
if [ -z "$CHANGES" ]; then
107+
echo "CHANGELOG_CONTENT=No changelog entry found for this version." >> $GITHUB_OUTPUT
108+
else
109+
# Escape newlines for GitHub output
110+
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_OUTPUT
111+
echo "$CHANGES" >> $GITHUB_OUTPUT
112+
echo "EOF" >> $GITHUB_OUTPUT
113+
fi
114+
else
115+
echo "CHANGELOG_CONTENT=CHANGELOG not found." >> $GITHUB_OUTPUT
116+
fi
117+
77118
create-release:
78-
needs: build-and-package
79119
runs-on: ubuntu-latest
120+
needs: [extract-changelog, build-and-package]
80121
if: startsWith(github.ref, 'refs/tags/')
81122

82123
steps:
@@ -87,7 +128,13 @@ jobs:
87128
- name: Create Release
88129
uses: softprops/action-gh-release@v1
89130
with:
90-
files: artifacts/**/*.zip
91-
generate_release_notes: true
92-
env:
93-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
name: Release ${{ github.ref_name }}
132+
body: |
133+
## Changes
134+
135+
${{ needs.extract-changelog.outputs.changelog }}
136+
137+
draft: true
138+
prerelease: false
139+
generate_release_notes: false
140+
files: artifacts/**/*.zip

0 commit comments

Comments
 (0)