From 829390c7a6a61f2eb057e190bf7fb77abc751096 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Thu, 17 Jul 2025 18:04:01 +0200 Subject: [PATCH 01/10] remove `bump-version-on-push.yml` --- .github/workflows/bump-version-on-push.yml | 65 ---------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/bump-version-on-push.yml diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml deleted file mode 100644 index c512f17e..00000000 --- a/.github/workflows/bump-version-on-push.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# yamllint disable rule:line-length -name: Bump_and_Package - -on: # yamllint disable-line rule:truthy - push: - branches: - - master - -jobs: - bump-version: - - runs-on: ubuntu-latest - if: "!startsWith(github.event.head_commit.message, '[SKIP]')" - - steps: - - - uses: actions/checkout@v1 - - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - - name: Setup Git - run: | - git config user.name "JoaoRodrigues" - git config user.email 'joaorodrigues@users.noreply.github.com' - git remote set-url origin \https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout "${GITHUB_REF:11}" - - - name: Create skip flag - run: | - echo "SKIPBUMP=FALSE" >> $GITHUB_ENV - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install bump2version setuptools wheel twine - - - name: Bump Minor Version - run: | - bump2version minor - echo "SKIPBUMP=TRUE" >> $GITHUB_ENV - if: "startsWith(github.event.head_commit.message, '[FEATURE]')" - - # Default action - - name: Bump Patch Version - run: | - bump2version patch - if: env.SKIPBUMP == 'FALSE' - - # No major version change should go through automatically. - - - name: Commit version change to master - run: | - git push --follow-tags - - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* From 4b7f879d9bd59b98e2b1dbde2fa79680bbeb4c9d Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 10:20:31 +0200 Subject: [PATCH 02/10] Revert "remove `bump-version-on-push.yml`" This reverts commit 829390c7a6a61f2eb057e190bf7fb77abc751096. --- .github/workflows/bump-version-on-push.yml | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/bump-version-on-push.yml diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml new file mode 100644 index 00000000..c512f17e --- /dev/null +++ b/.github/workflows/bump-version-on-push.yml @@ -0,0 +1,65 @@ +--- +# yamllint disable rule:line-length +name: Bump_and_Package + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + +jobs: + bump-version: + + runs-on: ubuntu-latest + if: "!startsWith(github.event.head_commit.message, '[SKIP]')" + + steps: + + - uses: actions/checkout@v1 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + + - name: Setup Git + run: | + git config user.name "JoaoRodrigues" + git config user.email 'joaorodrigues@users.noreply.github.com' + git remote set-url origin \https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git checkout "${GITHUB_REF:11}" + + - name: Create skip flag + run: | + echo "SKIPBUMP=FALSE" >> $GITHUB_ENV + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install bump2version setuptools wheel twine + + - name: Bump Minor Version + run: | + bump2version minor + echo "SKIPBUMP=TRUE" >> $GITHUB_ENV + if: "startsWith(github.event.head_commit.message, '[FEATURE]')" + + # Default action + - name: Bump Patch Version + run: | + bump2version patch + if: env.SKIPBUMP == 'FALSE' + + # No major version change should go through automatically. + + - name: Commit version change to master + run: | + git push --follow-tags + + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From ad3caa2132ddb339be57fbcec25407c18fc35e5d Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 10:26:39 +0200 Subject: [PATCH 03/10] `bump2version` is deprecated move to `bump-my-version` --- .github/workflows/bump-version-on-push.yml | 104 +++++++++++---------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml index c512f17e..66906683 100644 --- a/.github/workflows/bump-version-on-push.yml +++ b/.github/workflows/bump-version-on-push.yml @@ -1,65 +1,71 @@ --- -# yamllint disable rule:line-length name: Bump_and_Package -on: # yamllint disable-line rule:truthy +on: push: branches: - master jobs: bump-version: - runs-on: ubuntu-latest if: "!startsWith(github.event.head_commit.message, '[SKIP]')" steps: + - uses: actions/checkout@v4 - - uses: actions/checkout@v1 - - - name: Set up Python - uses: actions/setup-python@v1 + - name: Bump version + id: bump + uses: callowayproject/bump-my-version@master + env: + BUMPVERSION_TAG: "true" with: - python-version: '3.x' - - - name: Setup Git - run: | - git config user.name "JoaoRodrigues" - git config user.email 'joaorodrigues@users.noreply.github.com' - git remote set-url origin \https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout "${GITHUB_REF:11}" - - - name: Create skip flag - run: | - echo "SKIPBUMP=FALSE" >> $GITHUB_ENV - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install bump2version setuptools wheel twine + args: ${{ inputs.bump-type }} + github-token: ${{ secrets.GH_TOKEN }} - - name: Bump Minor Version - run: | - bump2version minor - echo "SKIPBUMP=TRUE" >> $GITHUB_ENV - if: "startsWith(github.event.head_commit.message, '[FEATURE]')" - - # Default action - - name: Bump Patch Version - run: | - bump2version patch - if: env.SKIPBUMP == 'FALSE' - - # No major version change should go through automatically. - - - name: Commit version change to master - run: | - git push --follow-tags - - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + # - name: Set up Python + # uses: actions/setup-python@v5 + # with: + # python-version: "3.x" + # + # - name: Setup Git + # run: | + # git config user.name "JoaoRodrigues" + # git config user.email 'joaorodrigues@users.noreply.github.com' + # git remote set-url origin \https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + # git checkout "${GITHUB_REF:11}" + # + # - name: Create skip flag + # run: | + # echo "SKIPBUMP=FALSE" >> $GITHUB_ENV + # + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install bump2version setuptools wheel twine + # + # - name: Bump Minor Version + # run: | + # bump2version minor + # echo "SKIPBUMP=TRUE" >> $GITHUB_ENV + # if: "startsWith(github.event.head_commit.message, '[FEATURE]')" + # + # # Default action + # - name: Bump Patch Version + # run: | + # bump2version patch + # if: env.SKIPBUMP == 'FALSE' + # + # # No major version change should go through automatically. + # + # - name: Commit version change to master + # run: | + # git push --follow-tags + # + # - name: Build and publish + # env: + # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + # run: | + # python setup.py sdist bdist_wheel + # twine upload dist/* From 48f50012a0516fd1025c3119a4178ed67d257c9c Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:18:53 +0200 Subject: [PATCH 04/10] add PR title check --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1e992de..24a5cc2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,35 @@ on: - master jobs: + bump: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Determine bump type from PR title + id: determine-bump + run: | + COMMIT_MSG="${{ github.event.pull_request.title }}" + echo "PR title: $COMMIT_MSG" + if [[ "$COMMIT_MSG" =~ ^\[MAJOR\] ]]; then + echo "bump-type=major" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[MINOR\] ]]; then + echo "bump-type=minor" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[PATCH\] ]]; then + echo "bump-type=patch" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[SKIP\] ]]; then + echo "skip-bump=true" >> $GITHUB_OUTPUT + echo "::notice::Version bump skipped based on PR title" + exit 0 + else + echo "::error::PR title must start with [MAJOR], [MINOR], [PATCH], or [SKIP]" + exit 1 + fi + linter: runs-on: ubuntu-latest + needs: [bump] steps: - uses: actions/checkout@v4 @@ -32,6 +59,7 @@ jobs: test: name: test + needs: [bump] runs-on: ${{ matrix.platform }} strategy: matrix: From f25d74d9f9ae817d50ecb5a4dc51250f81457779 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:22:05 +0200 Subject: [PATCH 05/10] escape backticks --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24a5cc2a..780abb0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Determine bump type from PR title id: determine-bump run: | - COMMIT_MSG="${{ github.event.pull_request.title }}" + COMMIT_MSG=$(printf "%s" "${{ github.event.pull_request.title }}") echo "PR title: $COMMIT_MSG" if [[ "$COMMIT_MSG" =~ ^\[MAJOR\] ]]; then echo "bump-type=major" >> $GITHUB_OUTPUT From 0528620b2bdb67e2654bbf05e7ee221e32e7c236 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:23:57 +0200 Subject: [PATCH 06/10] add triggers --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 780abb0b..6daaceea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: ci on: pull_request: + types: [opened, edited, synchronize] branches: - master push: From e1d9a7b094cc185f54c6e7a36e09c3463d910ac1 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:27:10 +0200 Subject: [PATCH 07/10] use `bumpversion.toml` --- .bumpversion.toml | 21 ++++++ .github/workflows/bump-version-on-push.yml | 81 ++++++++-------------- 2 files changed, 50 insertions(+), 52 deletions(-) create mode 100644 .bumpversion.toml diff --git a/.bumpversion.toml b/.bumpversion.toml new file mode 100644 index 00000000..ac204cd6 --- /dev/null +++ b/.bumpversion.toml @@ -0,0 +1,21 @@ +[tool.bumpversion] +current_version = "2.5.1" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" +serialize = ["{major}.{minor}.{patch}"] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +ignore_missing_files = false +tag = true +sign_tags = false +tag_name = "v{new_version}" +tag_message = "{current_version} → {new_version}" +allow_dirty = false +commit = true +message = "{current_version} → {new_version}" +moveable_tags = [] +commit_args = "" +setup_hooks = [] +pre_commit_hooks = [] +post_commit_hooks = [] diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml index 66906683..ac58b46f 100644 --- a/.github/workflows/bump-version-on-push.yml +++ b/.github/workflows/bump-version-on-push.yml @@ -9,63 +9,40 @@ on: jobs: bump-version: runs-on: ubuntu-latest - if: "!startsWith(github.event.head_commit.message, '[SKIP]')" + + permissions: + contents: write + pull-requests: write steps: - - uses: actions/checkout@v4 + - name: Determine bump type + id: determine-bump + run: | + COMMIT_MSG="${{ github.event.head_commit.message }}" + echo "PR title: $COMMIT_MSG" + if [[ "$COMMIT_MSG" =~ ^\[MAJOR\] ]]; then + echo "bump-type=major" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[MINOR\] ]]; then + echo "bump-type=minor" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[PATCH\] ]]; then + echo "bump-type=patch" >> $GITHUB_OUTPUT + elif [[ "$COMMIT_MSG" =~ ^\[SKIP\] ]]; then + echo "skip-bump=true" >> $GITHUB_OUTPUT + echo "::notice::Version bump skipped based on PR title" + exit 0 + else + echo "::error::PR title must start with [MAJOR], [MINOR], [PATCH], or [SKIP]" + exit 1 + fi - name: Bump version + if: steps.determine-bump.outputs.skip-bump != 'true' id: bump uses: callowayproject/bump-my-version@master - env: - BUMPVERSION_TAG: "true" with: - args: ${{ inputs.bump-type }} - github-token: ${{ secrets.GH_TOKEN }} + args: ${{ steps.determine-bump.outputs.bump-type }} setup.py -v + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Default token for GitHub Actions + - # - name: Set up Python - # uses: actions/setup-python@v5 - # with: - # python-version: "3.x" - # - # - name: Setup Git - # run: | - # git config user.name "JoaoRodrigues" - # git config user.email 'joaorodrigues@users.noreply.github.com' - # git remote set-url origin \https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - # git checkout "${GITHUB_REF:11}" - # - # - name: Create skip flag - # run: | - # echo "SKIPBUMP=FALSE" >> $GITHUB_ENV - # - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install bump2version setuptools wheel twine - # - # - name: Bump Minor Version - # run: | - # bump2version minor - # echo "SKIPBUMP=TRUE" >> $GITHUB_ENV - # if: "startsWith(github.event.head_commit.message, '[FEATURE]')" - # - # # Default action - # - name: Bump Patch Version - # run: | - # bump2version patch - # if: env.SKIPBUMP == 'FALSE' - # - # # No major version change should go through automatically. - # - # - name: Commit version change to master - # run: | - # git push --follow-tags - # - # - name: Build and publish - # env: - # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - # run: | - # python setup.py sdist bdist_wheel - # twine upload dist/* + ## TODO: Publish it on PyPI From 020408f8f7071f38236efd12c5f8745db40165b2 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:46:10 +0200 Subject: [PATCH 08/10] add publish steps --- .github/workflows/bump-version-on-push.yml | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml index ac58b46f..be9b7fd3 100644 --- a/.github/workflows/bump-version-on-push.yml +++ b/.github/workflows/bump-version-on-push.yml @@ -42,7 +42,35 @@ jobs: with: args: ${{ steps.determine-bump.outputs.bump-type }} setup.py -v env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Default token for GitHub Actions + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish: + name: builds and publishes to pypi + needs: [bump-version] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pdb-tools + + permissions: + id-token: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade build + python -m pip install setuptools wheel twine + + - name: build + run: | + pyhton setup.py sdist bdist_wheel - ## TODO: Publish it on PyPI + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From 876627f170d670233cc833d7280ec00a41e25ac7 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 12:48:50 +0200 Subject: [PATCH 09/10] add conditional --- .github/workflows/bump-version-on-push.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/bump-version-on-push.yml b/.github/workflows/bump-version-on-push.yml index be9b7fd3..738d8db3 100644 --- a/.github/workflows/bump-version-on-push.yml +++ b/.github/workflows/bump-version-on-push.yml @@ -14,6 +14,9 @@ jobs: contents: write pull-requests: write + outputs: + skip-bump: ${{ steps.determine-bump.outputs.skip-bump }} + steps: - name: Determine bump type id: determine-bump @@ -45,6 +48,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish: + if: needs.bump-version.outputs.skip-bump != 'true' name: builds and publishes to pypi needs: [bump-version] runs-on: ubuntu-latest From e83d1699ceb3c93e43cfd3cd44a99b2e7ece0963 Mon Sep 17 00:00:00 2001 From: "Rodrigo V. Honorato" Date: Mon, 21 Jul 2025 13:45:37 +0200 Subject: [PATCH 10/10] cleaning --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6daaceea..22129f91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: - name: install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade bump2version twine + python -m pip install --upgrade twine python -m pip install --upgrade coverage - name: build @@ -87,9 +87,6 @@ jobs: python setup.py sdist bdist_wheel twine check dist/*.whl twine check dist/*.tar.gz - bump2version --dry-run --verbose --allow-dirty patch - bump2version --dry-run --verbose --allow-dirty minor - bump2version --dry-run --verbose --allow-dirty major - name: install pdb-tools run: |