From 29d1d13222209adf19b415551744fbb55200f585 Mon Sep 17 00:00:00 2001 From: KC Berg Date: Wed, 9 Jul 2025 06:52:17 -0600 Subject: [PATCH 1/4] ci: add commit message filter to prevent workflow loops on bumpver commits --- .github/workflows/ci.yml | 5 +++-- .github/workflows/prepare-release.yml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19a736c..2d7867e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: jobs: test: + if: !contains(github.event.head_commit.message, 'bump: version') runs-on: ubuntu-latest strategy: matrix: @@ -30,7 +31,7 @@ jobs: pytest --maxfail=1 --disable-warnings tag-version: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + if: !contains(github.event.head_commit.message, 'bump: version') && github.ref == 'refs/heads/main' && github.event_name == 'push' needs: test runs-on: ubuntu-latest steps: @@ -64,7 +65,7 @@ jobs: GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin v${{ steps.get_version.outputs.version }} bump-version: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + if: !contains(github.event.head_commit.message, 'bump: version') && github.ref == 'refs/heads/main' && github.event_name == 'push' needs: [test, tag-version] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index bc01b06..c16502b 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -10,6 +10,7 @@ jobs: bump-minor-version: name: Bump Minor Version runs-on: ubuntu-latest + if: !contains(github.event.head_commit.message, 'bump: version') steps: - uses: actions/checkout@v4 with: From 87582e59808b055e19bda04b67f6422f7da3835c Mon Sep 17 00:00:00 2001 From: KC Berg Date: Wed, 9 Jul 2025 06:54:34 -0600 Subject: [PATCH 2/4] ci: use step-based skip for bumpver commit filter (fix YAML syntax error) --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++-- .github/workflows/prepare-release.yml | 19 +++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d7867e..aafabab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,56 +8,78 @@ on: jobs: test: - if: !contains(github.event.head_commit.message, 'bump: version') runs-on: ubuntu-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] steps: + - name: Check for bumpver commit + id: skip_bumpver + run: | + if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then + echo "Bumpver commit detected, skipping job." + exit 0 + fi - uses: actions/checkout@v4 + if: steps.skip_bumpver.outcome == 'success' with: persist-credentials: 'false' - name: Set up Python ${{ matrix.python-version }} + if: steps.skip_bumpver.outcome == 'success' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies + if: steps.skip_bumpver.outcome == 'success' run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install . - name: Run tests + if: steps.skip_bumpver.outcome == 'success' run: | pytest --maxfail=1 --disable-warnings tag-version: - if: !contains(github.event.head_commit.message, 'bump: version') && github.ref == 'refs/heads/main' && github.event_name == 'push' needs: test runs-on: ubuntu-latest steps: + - name: Check for bumpver commit + id: skip_bumpver + run: | + if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then + echo "Bumpver commit detected, skipping job." + exit 0 + fi - uses: actions/checkout@v4 + if: steps.skip_bumpver.outcome == 'success' with: persist-credentials: 'false' - name: Generate GitHub App token + if: steps.skip_bumpver.outcome == 'success' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing + if: steps.skip_bumpver.outcome == 'success' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Show current branch and HEAD + if: steps.skip_bumpver.outcome == 'success' run: | git branch -a git status git rev-parse --abbrev-ref HEAD - name: Get version from pyproject.toml + if: steps.skip_bumpver.outcome == 'success' id: get_version run: | VERSION=$(grep '^version =' pyproject.toml | head -1 | cut -d '"' -f2) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Create and push tag for current version (with verbose logging) + if: steps.skip_bumpver.outcome == 'success' run: | git remote -v git tag v${{ steps.get_version.outputs.version }} @@ -65,33 +87,46 @@ jobs: GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin v${{ steps.get_version.outputs.version }} bump-version: - if: !contains(github.event.head_commit.message, 'bump: version') && github.ref == 'refs/heads/main' && github.event_name == 'push' needs: [test, tag-version] runs-on: ubuntu-latest steps: + - name: Check for bumpver commit + id: skip_bumpver + run: | + if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then + echo "Bumpver commit detected, skipping job." + exit 0 + fi - uses: actions/checkout@v4 + if: steps.skip_bumpver.outcome == 'success' with: persist-credentials: 'false' - name: Generate GitHub App token + if: steps.skip_bumpver.outcome == 'success' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing + if: steps.skip_bumpver.outcome == 'success' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Install dependencies + if: steps.skip_bumpver.outcome == 'success' run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install . - name: Set git user for HawkyMcBuilderFace bot + if: steps.skip_bumpver.outcome == 'success' run: | git config user.name "HawkyMcBuilderFace[bot]" git config user.email "hawkymcbuilderface[bot]@users.noreply.github.com" - name: Bump patch version with bumpver + if: steps.skip_bumpver.outcome == 'success' run: bumpver update --patch --commit - name: Push version bump commit + if: steps.skip_bumpver.outcome == 'success' run: | git push diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index c16502b..ab13c8b 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -10,36 +10,51 @@ jobs: bump-minor-version: name: Bump Minor Version runs-on: ubuntu-latest - if: !contains(github.event.head_commit.message, 'bump: version') steps: - - uses: actions/checkout@v4 + - name: Check for bumpver commit + id: skip_bumpver + run: | + if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then + echo "Bumpver commit detected, skipping job." + exit 0 + fi + - name: Checkout code + if: steps.skip_bumpver.outcome == 'success' + uses: actions/checkout@v4 with: ref: main fetch-depth: 0 - name: Set up Python + if: steps.skip_bumpver.outcome == 'success' uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies + if: steps.skip_bumpver.outcome == 'success' run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install . - name: Generate GitHub App token + if: steps.skip_bumpver.outcome == 'success' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing + if: steps.skip_bumpver.outcome == 'success' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Set git user for HawkyMcBuilderFace bot + if: steps.skip_bumpver.outcome == 'success' run: | git config user.name "HawkyMcBuilderFace[bot]" git config user.email "hawkymcbuilderface[bot]@users.noreply.github.com" - name: Bump minor version with bumpver + if: steps.skip_bumpver.outcome == 'success' run: bumpver update --minor --commit - name: Push version bump commit + if: steps.skip_bumpver.outcome == 'success' run: | git push origin HEAD:main \ No newline at end of file From ad570704d275cb31bc764353a752df8d0d01616f Mon Sep 17 00:00:00 2001 From: KC Berg Date: Wed, 9 Jul 2025 06:57:42 -0600 Subject: [PATCH 3/4] ci: ensure tag-version and bump-version jobs only run on push to main --- .github/workflows/ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aafabab..d2d8932 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,34 +52,34 @@ jobs: exit 0 fi - uses: actions/checkout@v4 - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' with: persist-credentials: 'false' - name: Generate GitHub App token - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Show current branch and HEAD - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git branch -a git status git rev-parse --abbrev-ref HEAD - name: Get version from pyproject.toml - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' id: get_version run: | VERSION=$(grep '^version =' pyproject.toml | head -1 | cut -d '"' -f2) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Create and push tag for current version (with verbose logging) - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git remote -v git tag v${{ steps.get_version.outputs.version }} @@ -98,35 +98,35 @@ jobs: exit 0 fi - uses: actions/checkout@v4 - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' with: persist-credentials: 'false' - name: Generate GitHub App token - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Install dependencies - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install . - name: Set git user for HawkyMcBuilderFace bot - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git config user.name "HawkyMcBuilderFace[bot]" git config user.email "hawkymcbuilderface[bot]@users.noreply.github.com" - name: Bump patch version with bumpver - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: bumpver update --patch --commit - name: Push version bump commit - if: steps.skip_bumpver.outcome == 'success' + if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' run: | git push From abe7dd92b117e9c9bb23209d5dc285a1f9aba5df Mon Sep 17 00:00:00 2001 From: KC Berg Date: Wed, 9 Jul 2025 06:59:39 -0600 Subject: [PATCH 4/4] ci: skip tag-version and bump-version jobs unless push to main --- .github/workflows/ci.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2d8932..5a49067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: pytest --maxfail=1 --disable-warnings tag-version: + if: github.ref == 'refs/heads/main' && github.event_name == 'push' needs: test runs-on: ubuntu-latest steps: @@ -52,34 +53,34 @@ jobs: exit 0 fi - uses: actions/checkout@v4 - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' with: persist-credentials: 'false' - name: Generate GitHub App token - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Show current branch and HEAD - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git branch -a git status git rev-parse --abbrev-ref HEAD - name: Get version from pyproject.toml - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' id: get_version run: | VERSION=$(grep '^version =' pyproject.toml | head -1 | cut -d '"' -f2) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Create and push tag for current version (with verbose logging) - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git remote -v git tag v${{ steps.get_version.outputs.version }} @@ -87,6 +88,7 @@ jobs: GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin v${{ steps.get_version.outputs.version }} bump-version: + if: github.ref == 'refs/heads/main' && github.event_name == 'push' needs: [test, tag-version] runs-on: ubuntu-latest steps: @@ -98,35 +100,35 @@ jobs: exit 0 fi - uses: actions/checkout@v4 - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' with: persist-credentials: 'false' - name: Generate GitHub App token - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' id: generate_token uses: tibdex/github-app-token@v2 with: app_id: ${{ secrets.HAWKY_APP_ID }} private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} - name: Set up git for pushing - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git - name: Install dependencies - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install . - name: Set git user for HawkyMcBuilderFace bot - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git config user.name "HawkyMcBuilderFace[bot]" git config user.email "hawkymcbuilderface[bot]@users.noreply.github.com" - name: Bump patch version with bumpver - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: bumpver update --patch --commit - name: Push version bump commit - if: steps.skip_bumpver.outcome == 'success' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: steps.skip_bumpver.outcome == 'success' run: | git push