Skip to content

Commit 55a6b9d

Browse files
Add GitHub Actions workflow for release management
Add GitHub Actions workflow for release management
1 parent 6e73f24 commit 55a6b9d

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Version bump type"
8+
required: true
9+
default: "patch"
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
permissions:
17+
contents: write # Required for commits, tags, and releases
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Full history for version detection
28+
29+
- name: Read current version and bump
30+
id: version
31+
run: |
32+
# Read version from VERSION file
33+
CURRENT=$(cat VERSION | tr -d '\n')
34+
echo "Current version: $CURRENT"
35+
36+
# Parse version components
37+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
38+
39+
# Bump based on input selection
40+
case "${{ inputs.bump }}" in
41+
major)
42+
NEW_VERSION="$((MAJOR + 1)).0.0"
43+
;;
44+
minor)
45+
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
46+
;;
47+
patch)
48+
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
49+
;;
50+
esac
51+
52+
echo "New version: $NEW_VERSION"
53+
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
54+
55+
- name: Update VERSION file
56+
run: |
57+
echo "${{ steps.version.outputs.new }}" > VERSION
58+
59+
- name: Commit version bump
60+
run: |
61+
git config user.name "github-actions[bot]"
62+
git config user.email "github-actions[bot]@users.noreply.github.com"
63+
git add VERSION
64+
git commit -m "bump up version"
65+
git push
66+
67+
- name: Create and push tag
68+
run: |
69+
NEW_VERSION="${{ steps.version.outputs.new }}"
70+
git tag "$NEW_VERSION"
71+
git push origin "$NEW_VERSION"
72+
73+
- name: Create GitHub Release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
tag_name: ${{ steps.version.outputs.new }}
77+
name: ${{ steps.version.outputs.new }}
78+
generate_release_notes: true

0 commit comments

Comments
 (0)