Semantic Release from beta #1797
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: Semantic Release | |
| run-name: Semantic Release from ${{ github.ref_name }} | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| semantic: | |
| name: Determine version | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| outputs: | |
| new_release_published: ${{ steps.release.outputs.new_release_published }} | |
| new_release_version: ${{ steps.release.outputs.new_release_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Mirror prerelease tags as semver | |
| run: | | |
| # Prerelease tags use PEP 440 (v3.0.0b1) to match the published | |
| # package version, but semantic-release only understands semver and | |
| # silently ignores tags it cannot parse. Without this, every run | |
| # reports the first prerelease of the channel as the next version. | |
| # Mirror each PEP 440 prerelease tag onto its semver equivalent | |
| # (v3.0.0-beta.1). These are local to the run and are never pushed; | |
| # the PEP 440 tags remain the only real ones. The channel notes the | |
| # Version workflow records against the tagged commit apply to the | |
| # mirrored tag too, since notes attach to commits, not tags. | |
| for tag in $(git tag --list 'v*'); do | |
| semver="$( | |
| printf '%s' "${tag#v}" | sed -E \ | |
| -e 's/^([0-9]+\.[0-9]+\.[0-9]+)a([0-9]+)$/\1-alpha.\2/' \ | |
| -e 's/^([0-9]+\.[0-9]+\.[0-9]+)b([0-9]+)$/\1-beta.\2/' \ | |
| -e 's/^([0-9]+\.[0-9]+\.[0-9]+)rc([0-9]+)$/\1-rc.\2/' | |
| )" | |
| if [ "$semver" = "${tag#v}" ]; then | |
| continue | |
| fi | |
| git tag --force "v$semver" "$tag^{commit}" | |
| echo "Mirrored $tag as v$semver." | |
| done | |
| - name: Semantic release | |
| id: release | |
| uses: cycjimmy/semantic-release-action@v6 | |
| with: | |
| dry_run: true | |
| release: | |
| name: Release version | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: semantic | |
| if: needs.semantic.outputs.new_release_published == 'true' && needs.semantic.outputs.new_release_version != '1.0.0' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 1 | |
| - name: Release version ${{ needs.semantic.outputs.new_release_version }} on ${{ github.ref_name }} | |
| run: gh workflow run version.yml --raw-field version=$VERSION --ref $BRANCH | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
| VERSION: ${{ needs.semantic.outputs.new_release_version }} | |
| BRANCH: ${{ github.ref_name }} |