Skip to content

Commit 2f18516

Browse files
release-workflow
1 parent b006275 commit 2f18516

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Get latest tag
19+
id: get_tag
20+
run: |
21+
# Get the latest tag, or set to 0.0.0 if no tags exist
22+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
23+
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
24+
echo "Latest tag: $LATEST_TAG"
25+
26+
- name: Calculate next version
27+
id: next_version
28+
run: |
29+
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
30+
31+
# Remove 'v' prefix if present
32+
VERSION=${LATEST_TAG#v}
33+
34+
# Split version into components
35+
IFS='.' read -ra VERSION_PARTS <<< "$VERSION"
36+
MAJOR=${VERSION_PARTS[0]:-0}
37+
MINOR=${VERSION_PARTS[1]:-0}
38+
PATCH=${VERSION_PARTS[2]:-0}
39+
40+
# Increment patch version
41+
PATCH=$((PATCH + 1))
42+
43+
# Create new version
44+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
45+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
46+
echo "New version: $NEW_VERSION"
47+
48+
- name: Create tag
49+
run: |
50+
NEW_VERSION="${{ steps.next_version.outputs.new_version }}"
51+
git config user.name github-actions
52+
git config user.email [email protected]
53+
git tag -a "$NEW_VERSION" -m "Release version $NEW_VERSION"
54+
git push origin "$NEW_VERSION"
55+
56+
- name: Create Release
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
tag_name: ${{ steps.next_version.outputs.new_version }}
62+
release_name: Release ${{ steps.next_version.outputs.new_version }}
63+
body: |
64+
## Changes in this release
65+
66+
Auto-generated release for version ${{ steps.next_version.outputs.new_version }}
67+
68+
### What's Changed
69+
See the [commit history](https://github.com/${{ github.repository }}/compare/${{ steps.get_tag.outputs.latest_tag }}...${{ steps.next_version.outputs.new_version }}) for a full list of changes.
70+
draft: false
71+
prerelease: false

0 commit comments

Comments
 (0)