fix(release): use single stamp step for both push and dispatch triggers
This commit is contained in:
@@ -29,8 +29,8 @@ jobs:
|
|||||||
name: bump + tag
|
name: bump + tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.tag.outputs.tag_prefix }}
|
version: ${{ steps.stamp.outputs.version }}
|
||||||
tag: ${{ steps.tag.outputs.tag_full }}
|
tag: ${{ steps.stamp.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -49,34 +49,37 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-cargo-prepare-
|
${{ runner.os }}-cargo-prepare-
|
||||||
|
|
||||||
- name: Extract version from tag (push trigger)
|
- name: Stamp version + tag
|
||||||
if: github.event_name == 'push'
|
|
||||||
id: tag
|
|
||||||
run: |
|
|
||||||
echo "tag_prefix=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Validate version + stamp
|
|
||||||
if: github.event_name == 'workflow_dispatch'
|
|
||||||
id: stamp
|
id: stamp
|
||||||
env:
|
|
||||||
VERSION: ${{ inputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
ver="${VERSION#v}" # tolerate a leading v
|
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||||
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
# Tag push from local: tag already exists, just verify + extract version
|
||||||
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
tag="${GITHUB_REF_NAME}"
|
||||||
exit 1
|
ver="${tag#v}"
|
||||||
|
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
||||||
|
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Manual dispatch: validate input, stamp, verify tag doesn't exist yet
|
||||||
|
ver="${VERSION#v}"
|
||||||
|
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
||||||
|
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tag="v$ver"
|
||||||
|
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null \
|
||||||
|
|| git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1; then
|
||||||
|
echo "::error::tag $tag already exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
bash scripts/set-version.sh "$ver"
|
||||||
fi
|
fi
|
||||||
tag="v$ver"
|
|
||||||
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null \
|
|
||||||
|| git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1; then
|
|
||||||
echo "::error::tag $tag already exists"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
bash scripts/set-version.sh "$ver"
|
|
||||||
echo "version=$ver" >> "$GITHUB_OUTPUT"
|
echo "version=$ver" >> "$GITHUB_OUTPUT"
|
||||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
|
||||||
# Gate: never tag code that doesn't build/test. If this fails nothing
|
# Gate: never tag code that doesn't build/test. If this fails nothing
|
||||||
# is committed or pushed, so the release simply doesn't happen.
|
# is committed or pushed, so the release simply doesn't happen.
|
||||||
|
|||||||
Reference in New Issue
Block a user