-
-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (47 loc) · 1.63 KB
/
Copy pathrelease.yml
File metadata and controls
56 lines (47 loc) · 1.63 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
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get previous tag
id: prev-tag
run: |
# Get the previous tag (second most recent)
PREV_TAG=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
echo "Previous tag: $PREV_TAG"
- name: Generate Changelog
id: changelog
run: |
echo "## What's Changed" > changelog.md
echo "" >> changelog.md
# Get commits between previous tag and current tag
if [ -n "${{ steps.prev-tag.outputs.prev_tag }}" ]; then
COMMITS=$(git log ${{ steps.prev-tag.outputs.prev_tag }}..HEAD --pretty=format:"- %s (%h)" --no-merges 2>/dev/null || echo "")
else
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -10)
fi
if [ -n "$COMMITS" ]; then
echo "$COMMITS" >> changelog.md
else
echo "- Initial release" >> changelog.md
fi
echo "" >> changelog.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prev-tag.outputs.prev_tag }}...${{ github.ref_name }}" >> changelog.md
cat changelog.md
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: changelog.md
make_latest: true