From 19b7184b6ccc200bbb1f1a4a043023a83678a6d3 Mon Sep 17 00:00:00 2001 From: jamiecobbett Date: Thu, 2 Apr 2026 10:13:47 +0100 Subject: [PATCH 1/2] Automatically create GitHub release on publish --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8bc6e1b..425bf2b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,3 +48,12 @@ jobs: printf -- "---\n:rubygems_api_key: $RUBYGEM_PUBLISH_API_KEY\n" > $HOME/.gem/credentials gem build *.gemspec gem push *.gem + - name: Create GitHub Release + if: steps.version_check.outputs.already_published == 'false' + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION=${{ steps.version_check.outputs.version }} + gh release create "v$VERSION" \ + --title "v$VERSION" \ + --generate-notes From 2769e945a1133bae8990c5173976c7d68430368c Mon Sep 17 00:00:00 2001 From: jamiecobbett Date: Thu, 2 Apr 2026 10:15:30 +0100 Subject: [PATCH 2/2] Only attempt to publish if not already published Currently every time we merge to master without a version bump, the build fails because rubygems.org won't let us re-publish the current version. --- .github/workflows/ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 425bf2b2..5f67269f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,21 @@ jobs: with: ruby-version: '4.0' bundler-cache: true - - run: | + - name: Check if version is already released + id: version_check + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION=$(ruby -r ./lib/gocardless_pro/version.rb -e 'puts GoCardlessPro::VERSION') + echo "version=$VERSION" >> $GITHUB_OUTPUT + if gh release view "v$VERSION" >/dev/null 2>&1; then + echo "already_published=true" >> $GITHUB_OUTPUT + else + echo "already_published=false" >> $GITHUB_OUTPUT + fi + - name: Build and publish gem + if: steps.version_check.outputs.already_published == 'false' + run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials