Release (Manual) #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release (Manual) | |
on: | |
# Enable execution directly from Actions page | |
workflow_dispatch: | |
inputs: | |
bump-version: | |
description: 'Bump Level?' | |
type: choice | |
options: | |
- 'major' | |
- 'minor' | |
- 'patch' | |
- 'prerelease' | |
required: true | |
as-prerelease: | |
description: 'As pre-release?' | |
type: boolean | |
required: true | |
default: false | |
# default token permissions = none | |
permissions: {} | |
jobs: | |
validate: | |
uses: ./.github/workflows/validate.yml | |
permissions: {} | |
secrets: {} | |
release: | |
name: Semantic Release | |
concurrency: release | |
runs-on: ubuntu-latest | |
if: github.repository == 'python-semantic-release/publish-action' | |
needs: | |
- validate | |
permissions: | |
contents: write | |
steps: | |
# Note: we need to checkout the repository at the workflow sha in case during the workflow | |
# the branch was updated. To keep PSR working with the configured release branches, | |
# we force a checkout of the desired release branch but at the workflow sha HEAD. | |
- name: Setup | Checkout Repository at workflow sha | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.sha }} | |
- name: Setup | Force correct release branch on workflow sha | |
run: | | |
git checkout -B ${{ github.ref_name }} | |
- name: Release | Python Semantic Release | |
id: release | |
uses: python-semantic-release/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
root_options: "-vv -c releaserc.toml" | |
force: ${{ github.event.inputs.bump-version }} | |
prerelease: ${{ github.event.inputs.as-prerelease }} | |
changelog: false | |
- name: Release | Update Minor Release Tag Reference | |
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false' | |
env: | |
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }} | |
GIT_COMMITTER_NAME: github-actions | |
GIT_COMMITTER_EMAIL: [email protected] | |
run: | | |
MINOR_VERSION_TAG="$(printf '%s\n' "$FULL_VERSION_TAG" | cut -d. -f1,2)" | |
git tag --force --annotate "$MINOR_VERSION_TAG" "${FULL_VERSION_TAG}^{}" -m "$MINOR_VERSION_TAG" | |
git push origin "$MINOR_VERSION_TAG" --force | |
- name: Release | Update Major Release Tag Reference | |
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false' | |
env: | |
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }} | |
GIT_COMMITTER_NAME: github-actions | |
GIT_COMMITTER_EMAIL: [email protected] | |
run: | | |
MAJOR_VERSION_TAG="$(printf '%s\n' "$FULL_VERSION_TAG" | cut -d. -f1)" | |
git tag --force --annotate "$MAJOR_VERSION_TAG" "${FULL_VERSION_TAG}^{}" -m "$MAJOR_VERSION_TAG" | |
git push origin "$MAJOR_VERSION_TAG" --force |