-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.14 KB
/
release.yml
File metadata and controls
45 lines (38 loc) · 1.14 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
name: Create Release
run-name: Create release for ${{ github.ref_name }}
on:
push:
tags:
- 'v*'
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREVIOUS_TAG=$(git tag --sort=-v:refname | sed -n '2p')
if [ -z "$PREVIOUS_TAG" ]; then
# If no previous tag, get all commits
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
# Get commits since previous tag
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
# Save changelog to file
echo "$CHANGELOG" > /tmp/changelog.txt
- name: Create Release
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--notes-file /tmp/changelog.txt