Skip to content

Commit aeb4d6f

Browse files
committed
ci: update release action
1 parent 29208d4 commit aeb4d6f

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

.github/workflows/create-release.yml

-21
This file was deleted.

.github/workflows/release.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release On Tag
14+
if: startsWith(github.ref, 'refs/tags/')
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout the repository
18+
uses: actions/checkout@v4
19+
20+
- name: Extract the changelog
21+
id: changelog
22+
run: |
23+
TAG_NAME=${GITHUB_REF/refs\/tags\//}
24+
READ_SECTION=false
25+
CHANGELOG=""
26+
while IFS= read -r line; do
27+
if [[ "$line" =~ ^#+\ +(.*) ]]; then
28+
if [[ "${BASH_REMATCH[1]}" == "$TAG_NAME" ]]; then
29+
READ_SECTION=true
30+
elif [[ "$READ_SECTION" == true ]]; then
31+
break
32+
fi
33+
elif [[ "$READ_SECTION" == true ]]; then
34+
CHANGELOG+="$line"$'\n'
35+
fi
36+
done < "CHANGELOG.md"
37+
CHANGELOG=$(echo "$CHANGELOG" | awk '/./ {$1=$1;print}')
38+
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
39+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
40+
echo "EOF" >> $GITHUB_OUTPUT
41+
42+
- name: Create the release
43+
if: steps.changelog.outputs.changelog_content != ''
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
name: ${{ github.ref_name }}
47+
body: '${{ steps.changelog.outputs.changelog_content }}'
48+
draft: false
49+
prerelease: false

0 commit comments

Comments
 (0)