From daeb3be93e6540a451894edb2dc557bd0fcc8b88 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 3 May 2024 14:44:13 -0300 Subject: [PATCH 1/2] Setup steps after release-please to automate gem version syncing This is an attempt to automatically sync our gem versions after release-please detects the need to bump the version. It will open up a PR with that new version bump to judoscale-ruby and changelog added, and these extra steps should follow-up that with syncing the new version across the other libraries. I have done some manual testing on this using a separate branch, by commenting out the release-please and "if" statements, and only triggering these actual steps that sync versions and push a new commit. By bumping the judoscale-ruby version myself in a commit, the automated steps here would generate a new follow-up commit automatically syncing the other gems versions, so I'm hopeful this will work as expected. (famous last words) The git user name/email and commands in general are based on examples: https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token https://github.com/google-github-actions/release-please-action/tree/v3.7.13?tab=readme-ov-file#creating-majorminor-tags --- .github/workflows/release.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86f1e34a..8d5a31f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,26 @@ jobs: bump-minor-pre-major: true version-file: "judoscale-ruby/lib/judoscale/version.rb" + - name: Sync versions - checkout code + if: ${{ steps.release.outputs.release_created }} + uses: actions/checkout@v4 + + - name: Sync versions - setup Ruby + if: ${{ steps.release.outputs.release_created }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + + - name: Sync versions + if: ${{ steps.release.outputs.release_created }} + run: | + bin/sync-versions + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git add . + git commit -m "Sync versions" + git push + publish: name: Publish to Rubygems needs: release-please @@ -29,12 +49,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 3.3 - name: Publish gems env: From 4c069777c6ce816507709a1823b9dbe3bc99e7c2 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 6 May 2024 09:42:52 -0300 Subject: [PATCH 2/2] Checkout the PR head branch name where we need to sync We need to checkout the release PR to sync versions, otherwise it might use `main` which is where this workflow is running. It seems the "outputs" object has access to a PR object if one was created (which it'd have been in this case): https://github.com/google-github-actions/release-please-action?tab=readme-ov-file#outputs and that PR object has access to both head & base branch names: https://github.com/googleapis/release-please/blob/cb106cd0b5ae5c3e2a3b015487dc615eba72b842/src/pull-request.ts#L15-L17 so I believe we can checkout the right branch for that PR and run the sync/commit there, with this change. It's hard to test all of this without actually running a release though, so we might have to wait and see! (and hope!) --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d5a31f9..e166b1c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,8 @@ jobs: - name: Sync versions - checkout code if: ${{ steps.release.outputs.release_created }} uses: actions/checkout@v4 + with: + ref: ${{ steps.release.outputs.pr.headBranchName }} - name: Sync versions - setup Ruby if: ${{ steps.release.outputs.release_created }}