Skip to content

Commit 9eb56f0

Browse files
authored
Add release github action (#3)
* Add release github action * add -dev versions support
1 parent c716694 commit 9eb56f0

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/release.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Versioned Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
version_check:
10+
name: Release version
11+
runs-on: ubuntu-24.04
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Read and validate VERSION
17+
id: version
18+
run: |
19+
VERSION=$(cat VERSION)
20+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then
21+
echo "Invalid version format in VERSION file: $VERSION"
22+
exit 1
23+
fi
24+
echo "New version: $VERSION"
25+
echo "version=$VERSION" >> $GITHUB_ENV
26+
27+
- name: Skip release if version is a dev version
28+
if: contains(env.version, '-dev')
29+
run: |
30+
echo "Skipping development version release: ${{ env.version }}"
31+
exit 0
32+
33+
- name: Check if VERSION is already tagged
34+
id: check_tag
35+
run: |
36+
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
37+
echo "Tag ${{ env.version }} already exists. Skipping release."
38+
exit 0
39+
fi
40+
41+
- name: Create Git tag
42+
run: |
43+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
44+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
45+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
46+
47+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
48+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
49+
50+
git config user.name "$AUTHOR_NAME"
51+
git config user.email "$AUTHOR_EMAIL"
52+
53+
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
54+
git push origin "${{ env.version }}"
55+
56+
- name: Create GitHub release
57+
uses: softprops/action-gh-release@v2
58+
with:
59+
tag_name: ${{ env.version }}
60+
name: Release ${{ env.version }}
61+
body: "Automated release for version ${{ env.version }}"
62+
draft: false
63+
prerelease: false
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Push dev VERSION
68+
run: |
69+
echo "${{ env.version }}-dev" > VERSION
70+
git config user.name "${{ env.AUTHOR_NAME }}"
71+
git config user.email "${{ env.AUTHOR_EMAIL }}"
72+
git add VERSION
73+
git commit -m "Update VERSION to ${{ env.version }}-dev"
74+
git push origin main

0 commit comments

Comments
 (0)