Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ on:
workflow_dispatch:
inputs:
version:
description: "Version to release, without leading v (e.g. 0.5.0 or 0.5.0-rc.1)"
description: "Version to release (e.g. 0.1.0, v0.1.0 or 0.1.0-rc.1)"
required: true
type: string
workflow_call:
inputs:
version:
description: "Version to release, without leading v (e.g. 0.5.0 or 0.5.0-rc.1)"
description: "Version to release (e.g. 0.1.0, v0.1.0 or 0.1.0-rc.1)"
required: true
type: string
secrets:
Expand All @@ -43,18 +43,21 @@ jobs:
timeout-minutes: 10
steps:
- name: Validate inputs
id: validate
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
VERSION="${VERSION#v}"
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "::error::Releases must be cut from main (got $GITHUB_REF)"
exit 1
fi
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::'$VERSION' is not a valid semver version (expected X.Y.Z or X.Y.Z-pre)"
echo "::error::'$VERSION' is not a valid semver version (expected X.Y.Z or X.Y.Z-pre, optionally with a leading v)"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Create release app token
id: app-token
Expand All @@ -74,17 +77,17 @@ jobs:
- name: Ensure tag does not exist
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.validate.outputs.version }}
run: |
if git rev-parse -q --verify "refs/tags/v${VERSION}" > /dev/null; then
echo "::error::Tag v${VERSION} already exists"
exit 1
fi

- name: Pin self-references to v${{ inputs.version }}
- name: Pin self-references to the release tag
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.validate.outputs.version }}
run: |
self="${GITHUB_REPOSITORY//./\\.}(/[A-Za-z0-9_./-]+)?"
mapfile -t files < <(git ls-files '.github/workflows/*.yml' '.github/workflows/*.yaml' \
Expand All @@ -100,7 +103,7 @@ jobs:
- name: Commit, tag and push
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.validate.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand All @@ -113,7 +116,7 @@ jobs:
- name: Create GitHub release
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.validate.outputs.version }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
PRERELEASE=()
Expand All @@ -125,7 +128,7 @@ jobs:
- name: Update floating tags
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.validate.outputs.version }}
run: |
if [[ "$VERSION" == *-* ]]; then
echo "Skipping floating tag update for pre-release v${VERSION}"
Expand Down
Loading