Tag and release to Github #34
This file contains hidden or 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: Tag and release to Github | |
| env: | |
| UV_FROZEN: "1" | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump-version: | |
| description: 'What bump level?' | |
| type: choice | |
| options: ['major', 'minor', 'patch', 'prerelease'] | |
| required: true | |
| as-prerelease: | |
| description: 'As pre-release?' | |
| type: boolean | |
| required: true | |
| default: false | |
| jobs: | |
| check-code: | |
| uses: ./.github/workflows/check-code.yml | |
| run-tests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13'] | |
| env: | |
| WX_API_KEY: ${{ secrets.WX_API_KEY }} | |
| WX_PROJECT_ID: ${{ secrets.WX_PROJECT_ID }} | |
| WX_SPACE_ID: ${{ secrets. WX_SPACE_ID }} | |
| WX_URL: ${{ vars.WX_URL }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| - uses: ./.github/actions/setup-python-uv | |
| - uses: ./.github/actions/run-tests | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| run-tests | |
| permissions: | |
| contents: write | |
| steps: | |
| # Note: We checkout the repository at the branch that triggered the workflow | |
| # with the entire history to ensure to match PSR's release branch detection | |
| # and history evaluation. | |
| # However, we forcefully reset the branch to the workflow sha because it is | |
| # possible that the branch was updated while the workflow was running. This | |
| # prevents accidentally releasing un-evaluated changes. | |
| - name: Checkout code on release branch | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 | |
| token: ${{ secrets.CI_PUSH_TOKEN }} | |
| - name: Force release branch to be at workflow sha | |
| run: | | |
| git reset --hard ${{ github.sha }} | |
| - name: Verify upstream has NOT changed | |
| # Last chance to abort before causing an error as another PR/push was applied to | |
| # the upstream branch while this workflow was running. This is important | |
| # because we are committing a version change (--commit). You may omit this step | |
| # if you have 'commit: false' in your configuration. | |
| # | |
| # You may consider moving this to a repo script and call it from this step instead | |
| # of writing it in-line. | |
| shell: bash | |
| run: bash .github/scripts/verify_upstream.sh | |
| - name: Run semantic version release | |
| id: release | |
| # Adjust tag with desired version if applicable. | |
| uses: python-semantic-release/python-semantic-release@v10.4.1 | |
| with: | |
| verbosity: 2 | |
| github_token: ${{ secrets.CI_PUSH_TOKEN }} | |
| git_committer_name: "github-actions" | |
| git_committer_email: "actions@users.noreply.github.com" | |
| force: ${{ github.event.inputs.bump-version }} | |
| prerelease: ${{ github.event.inputs.as-prerelease }} | |
| - name: Upload to GitHub release assets | |
| uses: python-semantic-release/publish-action@v10.4.1 | |
| if: steps.release.outputs.released == 'true' | |
| with: | |
| github_token: ${{ secrets.CI_PUSH_TOKEN }} | |
| tag: ${{ steps.release.outputs.tag }} |