diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a49067..13d756f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: jobs: test: + if: github.event_name != 'push' || github.ref != 'refs/heads/main' runs-on: ubuntu-latest strategy: matrix: @@ -17,8 +18,8 @@ jobs: id: skip_bumpver run: | if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then - echo "Bumpver commit detected, skipping job." - exit 0 + echo "Bumpver commit detected, failing job to prevent workflow loop." + exit 1 fi - uses: actions/checkout@v4 if: steps.skip_bumpver.outcome == 'success' @@ -40,47 +41,48 @@ jobs: run: | pytest --maxfail=1 --disable-warnings - tag-version: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - needs: test + check-bumpver: runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.check.outputs.should_run }} steps: - name: Check for bumpver commit - id: skip_bumpver + id: check run: | if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then - echo "Bumpver commit detected, skipping job." - exit 0 + echo "should_run=false" >> $GITHUB_OUTPUT + else + echo "should_run=true" >> $GITHUB_OUTPUT fi + + tag-version: + if: needs.check-bumpver.outputs.should_run == 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push' + needs: [test, check-bumpver] + runs-on: ubuntu-latest + steps: - 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 }} @@ -88,47 +90,33 @@ 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] + if: needs.check-bumpver.outputs.should_run == 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push' + needs: [test, tag-version, check-bumpver] 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 ab13c8b..ef60e1b 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -7,54 +7,55 @@ permissions: contents: write jobs: - bump-minor-version: - name: Bump Minor Version + check-bumpver: runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.check.outputs.should_run }} steps: - name: Check for bumpver commit - id: skip_bumpver + id: check run: | if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then - echo "Bumpver commit detected, skipping job." - exit 0 + echo "should_run=false" >> $GITHUB_OUTPUT + else + echo "should_run=true" >> $GITHUB_OUTPUT fi + + bump-minor-version: + name: Bump Minor Version + if: needs.check-bumpver.outputs.should_run == 'true' + needs: check-bumpver + runs-on: ubuntu-latest + steps: - 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