diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fa607c..c7e7b30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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 @@ -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' \ @@ -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" @@ -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=() @@ -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}"