-
Notifications
You must be signed in to change notification settings - Fork 2
51 lines (44 loc) · 1.5 KB
/
release.yml
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
name: Release Management
on:
push:
branches:
- main
paths:
- 'CHANGELOG.md'
permissions:
contents: write
pull-requests: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from CHANGELOG
id: changelog
run: |
VERSION=$(grep -m 1 "## \[.*\]" CHANGELOG.md | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
if: steps.changelog.outputs.version != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.changelog.outputs.version }}
run: |
if ! git tag | grep -q "^v$VERSION$"; then
# Extract changelog content for this version
CHANGELOG_CONTENTS=$(awk "/## \[$VERSION\]/,/## \[/{ if (!/## \[$VERSION\]/ && !/## \[/) print }" CHANGELOG.md)
# Create and push tag
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
# Create GitHub release
gh release create "v$VERSION" \
--title "Release v$VERSION" \
--notes "$CHANGELOG_CONTENTS" \
--draft=false \
--prerelease=false
fi