-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Added action for bumping release version #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
01d1b2a
a0e259c
dcf6e7b
c9405e1
280c92d
cf745d3
c18fd9d
82e9baf
e8d9fd9
ca615be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| name: Release new version | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adapted with lots of modifications from https://github.com/AllenCell/github-restructure/blob/workflow-templates/.github/workflows/release-new-version-tag-only.yml |
||
|
|
||
| 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happened because I was trying to follow |
||
|
|
||
| - 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 }} | ||
There was a problem hiding this comment.
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-versionwould throw an error since some documentation markdown files do not have version numbers present