chore: release v0.11.0 (#196) #19
Workflow file for this run
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: GitHub Release | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Existing tag to create or update a GitHub Release for (e.g. v0.2.2)' | |
| required: true | |
| type: string | |
| # Deny all permissions by default; grant only what each job needs. | |
| permissions: {} | |
| jobs: | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # create/update the GitHub Release and read the tagged ref | |
| env: | |
| RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} | |
| steps: | |
| - name: Validate release tag format | |
| if: github.event_name == 'workflow_dispatch' | |
| env: | |
| INPUT_TAG: ${{ github.event.inputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| if [[ ! "$INPUT_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "tag must look like vX.Y.Z, got: $INPUT_TAG" >&2 | |
| exit 1 | |
| fi | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 | |
| with: | |
| ref: ${{ env.RELEASE_TAG }} | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Read package metadata | |
| id: meta | |
| run: | | |
| pkg_name=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['name'])") | |
| pkg_version="${RELEASE_TAG#v}" | |
| echo "name=${pkg_name}" >> "$GITHUB_OUTPUT" | |
| echo "version=${pkg_version}" >> "$GITHUB_OUTPUT" | |
| - name: Extract changelog notes | |
| id: notes | |
| run: | | |
| set -euo pipefail | |
| version="${RELEASE_TAG#v}" | |
| if [[ -f CHANGELOG.md ]]; then | |
| body="$(python scripts/extract-changelog.py "$version")" | |
| else | |
| body="Release ${version}." | |
| fi | |
| delimiter="EOF_${RANDOM}_${RANDOM}" | |
| { | |
| echo "body<<${delimiter}" | |
| echo "$body" | |
| echo "${delimiter}" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| name: ${{ steps.meta.outputs.name }} ${{ steps.meta.outputs.version }} | |
| body: ${{ steps.notes.outputs.body }} | |
| generate_release_notes: false | |
| # Let GitHub decide by tag date/semver rather than by run order. This | |
| # workflow already accepts a dispatch for an existing tag, so a repair | |
| # run may target an older tag than the newest release — `true` would | |
| # move the badge onto it. `false` is not "leave alone" either: it marks | |
| # a release explicitly NOT latest, which would demote the newest tag | |
| # when the dispatch is repairing that one. | |
| make_latest: legacy |