-
Notifications
You must be signed in to change notification settings - Fork 11
62 lines (53 loc) · 1.94 KB
/
Copy pathrelease.yml
File metadata and controls
62 lines (53 loc) · 1.94 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
name: Create GitHub Release
on:
push:
tags:
- 'v*.*.*'
- '!v*.*.*-dev' # Exclude dev tags
- '!v*.*.*-beta*' # Exclude beta tags
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Load changelog
id: changelog
run: |
VERSION=${{ steps.version.outputs.version }}
CHANGELOG_FILE="Changelog/v${VERSION}.md"
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed -n '2p' || echo "")
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
if [ -f "$CHANGELOG_FILE" ]; then
# Read the changelog file, skip the first line (# Changelog X.Y.Z header)
BODY=$(tail -n +2 "$CHANGELOG_FILE")
else
echo "Warning: No changelog file found at $CHANGELOG_FILE, falling back to git log"
if [ -n "$PREVIOUS_TAG" ]; then
BODY=$(git log $PREVIOUS_TAG..HEAD --pretty=format:"- %s")
else
BODY=$(git log --pretty=format:"- %s")
fi
fi
echo "body<<CHANGELOG_EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "CHANGELOG_EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: BugPin ${{ steps.version.outputs.version }}
body: |
${{ steps.changelog.outputs.body }}
---
**Compare**: https://github.com/${{ github.repository }}/compare/${{ steps.changelog.outputs.previous_tag }}...${{ github.ref_name }}
draft: false
prerelease: false