Skip to content

Commit 7a809b0

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

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/auto-release.yml

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

0 commit comments

Comments
 (0)