Skip to content

Commit ac25cf5

Browse files
authored
Create draft_release.yml
1 parent 6b75f15 commit ac25cf5

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/draft_release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: 'Which part of the version to bump (major, minor, patch)'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- major
13+
- minor
14+
- patch
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout selected branch
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.ref_name }}
25+
26+
- name: Get latest tag
27+
id: get_tag
28+
run: |
29+
latest_tag=$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
30+
echo "Latest tag: $latest_tag"
31+
if [[ -z "$latest_tag" ]]; then
32+
echo "tag=0.0.0" >> $GITHUB_OUTPUT
33+
else
34+
echo "tag=${latest_tag#v}" >> $GITHUB_OUTPUT
35+
fi
36+
37+
- name: Calculate next version
38+
id: bump_version
39+
run: |
40+
IFS='.' read -r major minor patch <<< "${{ steps.get_tag.outputs.tag }}"
41+
case "${{ github.event.inputs.version_bump }}" in
42+
major)
43+
((major+=1)); minor=0; patch=0;;
44+
minor)
45+
((minor+=1)); patch=0;;
46+
patch)
47+
((patch+=1));;
48+
esac
49+
new_version="v$major.$minor.$patch"
50+
echo "New version: $new_version"
51+
echo "new_tag=$new_version" >> $GITHUB_OUTPUT
52+
53+
- name: Create Release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
tag_name: ${{ steps.bump_version.outputs.new_tag }}
57+
target_commitish: ${{ github.ref_name }}
58+
generate_release_notes: true
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)