-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 1.61 KB
/
create-draft.yml
File metadata and controls
65 lines (54 loc) · 1.61 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
63
64
65
name: Create Draft Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
create-draft:
name: Create Draft Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag info
id: tag_info
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "version=${TAG_NAME#v}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
echo "Getting changes since $PREV_TAG"
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD)
else
echo "Getting all commits"
CHANGELOG=$(git log --pretty=format:"- %s (%h)")
fi
# Save changelog to file
cat << EOF > changelog.md
## What's Changed
$CHANGELOG
EOF
# Output for use in release
{
echo 'CHANGELOG<<EOF'
cat changelog.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Create Draft Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_info.outputs.tag_name }}
name: Release ${{ steps.tag_info.outputs.tag_name }}
body: ${{ steps.changelog.outputs.CHANGELOG }}
draft: true
prerelease: false
generate_release_notes: true