-
Notifications
You must be signed in to change notification settings - Fork 54
146 lines (130 loc) Β· 5 KB
/
github_release.yml
File metadata and controls
146 lines (130 loc) Β· 5 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: "Create GitHub release with automatic changelog"
on:
workflow_dispatch: # Manual trigger via GitHub UI
jobs:
# First, build the stable release
build:
name: Build stable release
uses: ./.github/workflows/one_job.yml
with:
unstable: 'false'
secrets: inherit
tag:
name: Push new tag
needs: build # Wait for build to complete successfully
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Get previous tag from current branch
id: get-previous-tag
run: |
# Get the latest release tag (semantic version) that's reachable from the current commit
# Match tags like: 1.2.3 (without 'v' prefix)
# Exclude current version to support hotfix re-runs
CURRENT_VERSION="$(cat VERSION)"
PREV_TAG=$(git tag --merged HEAD^ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${CURRENT_VERSION}$" | sort -V | tail -1)
if [ -z "$PREV_TAG" ]; then
echo "Error: No previous release tag found in current branch history"
echo "This is unexpected - there should be previous releases in the history"
exit 1
fi
echo "tag=${PREV_TAG}" >> "${GITHUB_OUTPUT}"
echo "Found previous tag: ${PREV_TAG}"
- name: Get version
id: get-version
run: |
VERSION="$(cat VERSION)"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- name: Push new tag (force update if exists)
run: |
VERSION="${{ steps.get-version.outputs.version }}"
git tag -f "${VERSION}"
git push -f origin "${VERSION}"
outputs:
previous-tag: ${{ steps.get-previous-tag.outputs.tag }}
new-tag: ${{ steps.get-version.outputs.version }}
release:
name: Create release
needs: tag
permissions:
pull-requests: read
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@6faf020194b7c8853f9e55c4fd92e40b02122a04 # v5
with:
mode: "PR"
fromTag: ${{ needs.tag.outputs.previous-tag }}
toTag: ${{ needs.tag.outputs.new-tag }}
configurationJson: |
{
"template": "#{{CHANGELOG}}\n\nContributors:\n#{{CONTRIBUTORS}}",
"categories": [
{
"key": "features",
"title": "## π Features",
"labels": ["feat", "feature"]
},
{
"key": "tests",
"title": "## π§ͺ Tests",
"labels": ["test"]
},
{
"key": "fixes",
"title": "## π Fixes",
"labels": ["fix", "bug"]
},
{
"key": "dependencies",
"title": "## π¦ Dependencies",
"labels": ["dependencies", "deps"]
},
{
"key": "docs",
"title": "## πDocs",
"labels": ["doc", "docs", "documentation"]
},
{
"key": "other",
"title": "## Other",
"labels": []
}
],
"ignore_labels": [
"ignore-for-release"
],
"label_extractor": [
{
"pattern": "^(other|docs|doc|dependencies|deps|feat|feature|fix|bug|test|.*)",
"target": "$1"
}
]
}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release with changelog
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.tag.outputs.new-tag }}
name: ${{ needs.tag.outputs.new-tag }}
draft: false
prerelease: false
body: |
Changes made since version `${{ steps.changelog.outputs.fromTag }}` prior to version `${{ steps.changelog.outputs.toTag }}`:
${{ steps.changelog.outputs.changelog }}
| π **Categorized PRs** | π **Uncategorized PRs** | π₯ **Commits** | β **Lines added** | β **Lines deleted** |
| :---: | :---: | :---: | :---: | :---: |
| ${{ steps.changelog.outputs.categorized_prs }} | ${{ steps.changelog.outputs.uncategorized_prs }} | ${{ steps.changelog.outputs.commits }} | ${{ steps.changelog.outputs.additions }} | ${{ steps.changelog.outputs.deletions }} |