diff --git a/.bumpversion.toml b/.bumpversion.toml new file mode 100644 index 0000000..ac204cd --- /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 c512f17..738d8db 100644 --- a/.github/workflows/bump-version-on-push.yml +++ b/.github/workflows/bump-version-on-push.yml @@ -1,65 +1,80 @@ --- -# 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: + permissions: + contents: write + pull-requests: write - - uses: actions/checkout@v1 + outputs: + skip-bump: ${{ steps.determine-bump.outputs.skip-bump }} - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - - name: Setup Git + steps: + - name: Determine bump type + id: determine-bump 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}" + 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: Create skip flag - run: | - echo "SKIPBUMP=FALSE" >> $GITHUB_ENV + - name: Bump version + if: steps.determine-bump.outputs.skip-bump != 'true' + id: bump + uses: callowayproject/bump-my-version@master + with: + args: ${{ steps.determine-bump.outputs.bump-type }} setup.py -v + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install bump2version setuptools wheel twine + publish: + if: needs.bump-version.outputs.skip-bump != 'true' + name: builds and publishes to pypi + needs: [bump-version] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pdb-tools - - name: Bump Minor Version - run: | - bump2version minor - echo "SKIPBUMP=TRUE" >> $GITHUB_ENV - if: "startsWith(github.event.head_commit.message, '[FEATURE]')" + permissions: + id-token: write - # Default action - - name: Bump Patch Version - run: | - bump2version patch - if: env.SKIPBUMP == 'FALSE' + steps: + - uses: actions/checkout@v4 - # No major version change should go through automatically. + - uses: actions/setup-python@v5 + with: + python-version: "3.13" - - name: Commit version change to master + - name: install dependencies run: | - git push --follow-tags + python -m pip install --upgrade pip + python -m pip install --upgrade build + python -m pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + - name: build run: | - python setup.py sdist bdist_wheel - twine upload dist/* + pyhton setup.py sdist bdist_wheel + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1e992d..22129f9 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: @@ -10,8 +11,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=$(printf "%s" "${{ 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 +60,7 @@ jobs: test: name: test + needs: [bump] runs-on: ${{ matrix.platform }} strategy: matrix: @@ -49,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 @@ -58,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: |