From bfeef0583aaeda7b0f3576ea81d873b6ac634d88 Mon Sep 17 00:00:00 2001 From: jamiecobbett Date: Tue, 3 Mar 2026 17:36:30 +0000 Subject: [PATCH] Automatically release when a version bump is merged We set the version in client-library-templates --- .github/workflows/auto-release.yml | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 00000000..b1da17af --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,45 @@ +name: Create Release + +on: + push: + branches: [master] + +permissions: + contents: write + +jobs: + create_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Get version from build.gradle + id: version + run: | + VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Check if tag exists + id: check + run: | + VERSION="${{ steps.version.outputs.version }}" + if git rev-parse "v${VERSION}" >/dev/null 2>&1; then + echo "Tag v${VERSION} already exists, skipping release" + echo "should_release=false" >> $GITHUB_OUTPUT + else + echo "Tag v${VERSION} does not exist, will create release" + echo "should_release=true" >> $GITHUB_OUTPUT + fi + + - name: Create tag and release + if: steps.check.outputs.should_release == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag v${{ steps.version.outputs.version }} + git push origin v${{ steps.version.outputs.version }} + gh release create v${{ steps.version.outputs.version }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}