Skip to content
6 changes: 3 additions & 3 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ tag = true
tag_name = "v{new_version}"
current_version = "1.7.1"

[[tool.bumpversion.files]]
glob = "documentation/**/*.md"

Comment on lines -8 to -10

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed an issue where bump-my-version would throw an error since some documentation markdown files do not have version numbers present

[[tool.bumpversion.files]]
glob = "*.md"

Expand All @@ -19,3 +16,6 @@ filename = "pyproject.toml"

[[tool.bumpversion.files]]
filename = "documentation/getting_started_guide/requirements.txt"

[[tool.bumpversion.files]]
glob = "documentation/DATA_FORMAT.md"
99 changes: 99 additions & 0 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Release new version

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


run-name: Release new version with ${{ inputs.increment }} bump by @${{ github.actor }}

on:
workflow_dispatch:
inputs:
increment:
description: "Semantic version increment to bump"
default: "patch"
options:
- major
- minor
- patch
required: true
type: choice

permissions: {}

jobs:
bump-version:
if: ${{ github.ref_name == github.event.repository.default_branch }}
runs-on: ubuntu-latest
outputs:
version-tag: ${{ steps.get-tag.outputs.VERSION_TAG }}

permissions:
contents: write # required to push new tag to repo

steps:
# Create a token so it can be used during checkout + push steps; it must
# be explicitly passed to steps that need it.
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happened because I was trying to follow zizmor guidance on avoiding persist-credentials: true in actions/checkout. I create a GitHub token and then pass it into the specific steps that I want to have access to it.


- name: Checkout the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # fetch full commit and tag history
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false

- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"

- name: Install dependencies
run: pip install -e '.[dev]'

# Configure git before bumping version, since it makes a commit
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Bump version
run: bump-my-version bump -v ${BUMP_TYPE}
env:
BUMP_TYPE: ${{ inputs.increment }}

- name: Get the new tag
id: get-tag
run: echo "VERSION_TAG=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"

# The checkout action normally sets the git access token (via
# persist-credentials), but this can be unsafe! We explicitly set the
# token in the authorization header here, so that other steps don't have
# unintended access to the token.
- name: Push changes and new tag
run: |
git config http.extraheader "Authorization: Basic $(echo -n x-access-token:${GH_TOKEN} | base64 -w 0)"
git push origin ${DEFAULT_BRANCH}
git push origin ${VERSION_TAG}
git config --unset-all http.extraheader
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
VERSION_TAG: ${{ steps.get-tag.outputs.VERSION_TAG }}

create-draft-release:
if: ${{ github.ref_name == github.event.repository.default_branch }}
runs-on: ubuntu-latest
needs: [bump-version]

permissions:
contents: write

steps:
- name: Draft release
run: gh release create ${VERSION_TAG} --draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_TAG: ${{ needs.bump-version.outputs.version-tag }}
Loading