Skip to content

Commit bfeef05

Browse files
committed
Automatically release when a version bump is merged
We set the version in client-library-templates
1 parent 008fac3 commit bfeef05

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
create_release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Get version from build.gradle
19+
id: version
20+
run: |
21+
VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/")
22+
echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
24+
- name: Check if tag exists
25+
id: check
26+
run: |
27+
VERSION="${{ steps.version.outputs.version }}"
28+
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
29+
echo "Tag v${VERSION} already exists, skipping release"
30+
echo "should_release=false" >> $GITHUB_OUTPUT
31+
else
32+
echo "Tag v${VERSION} does not exist, will create release"
33+
echo "should_release=true" >> $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Create tag and release
37+
if: steps.check.outputs.should_release == 'true'
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git tag v${{ steps.version.outputs.version }}
42+
git push origin v${{ steps.version.outputs.version }}
43+
gh release create v${{ steps.version.outputs.version }} --generate-notes
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)