From cce9078a4b9750f50ea059d70bf7a73ee90a7916 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 18 Jun 2024 10:04:51 +0100 Subject: [PATCH] Add workflow to enforce gem version bumps This workflow will run when opening a pull request on gem repositories. It checks if there are changes to the CHANGELOG.md and version.rb/*.gemspec files. If those files have not been changed the workflow will fail. Code changes are often merged into gems without the gem version being bumped. This leads to changes not being released quickly and sometimes piling up. Enforcing all PRs include a gem version bump will eliminate the problem and allow us to remove all the checks and alerts we have for unreleased gem changes. https://trello.com/c/R1kkdVjt/3560-re-evaluate-effectiveness-of-gem-auto-release-workflow-3 --- .github/workflows/gem-bump-checker.yml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/gem-bump-checker.yml diff --git a/.github/workflows/gem-bump-checker.yml b/.github/workflows/gem-bump-checker.yml new file mode 100644 index 000000000..050497dd1 --- /dev/null +++ b/.github/workflows/gem-bump-checker.yml @@ -0,0 +1,37 @@ +name: Check Bump Checker + +on: + workflow_call: + secrets: + GH_TOKEN: + required: true + +jobs: + check-files: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + show-progress: false + token: ${{ secrets.GH_TOKEN }} + + - name: Check for version and changelog updates + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + BASE_REF: ${{ github.base_ref }} + HEAD_REF: ${{ github.head_ref }}) + run: | + MODIFIED_FILES=$(git diff --name-only "$BASE_REF".."$HEAD_REF") + + if ! echo "$MODIFIED_FILES" | grep -q 'version.rb' && \ + ! echo "$MODIFIED_FILES" | grep -q '\.gemspec$'; then + echo "Error: Either version.rb or a .gemspec file must be modified with each pull request to bump the gem version." + exit 1 + fi + + if ! echo "$MODIFIED_FILES" | grep -q 'CHANGELOG.md'; then + echo "Error: CHANGELOG.md must be updated with each pull request." + exit 1 + fi