mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-17 02:06:29 +00:00
Add a release-gate step to the release workflow (#859)
This commit is contained in:
73
.github/workflows/release.yml
vendored
73
.github/workflows/release.yml
vendored
@@ -11,31 +11,86 @@ on:
|
|||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
validate-release:
|
||||||
name: Release
|
name: Validate release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: release
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- name: Validate version and draft release
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Validate version
|
|
||||||
env:
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
|
TAG: v${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
|
||||||
echo "::error::Version must match MAJOR.MINOR.PATCH (e.g., 8.1.0)"
|
echo "::error::Version must match MAJOR.MINOR.PATCH (e.g., 8.1.0)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
RELEASE_JSON=$(gh release view "$TAG" --json isDraft,targetCommitish 2>&1) || {
|
||||||
|
echo "::error::No release found for $TAG"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
IS_DRAFT=$(echo "$RELEASE_JSON" | jq -r '.isDraft')
|
||||||
|
TARGET=$(echo "$RELEASE_JSON" | jq -r '.targetCommitish')
|
||||||
|
|
||||||
|
if [[ "$IS_DRAFT" != "true" ]]; then
|
||||||
|
echo "::error::Release $TAG already exists and is not a draft"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$TARGET" != "$GITHUB_SHA" ]]; then
|
||||||
|
echo "::error::Draft release target ($TARGET) does not match current commit ($GITHUB_SHA)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
release-gate:
|
||||||
|
# N.B. This name should not change, it is used for downstream checks.
|
||||||
|
name: release-gate
|
||||||
|
needs:
|
||||||
|
- validate-release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: release-gate
|
||||||
|
steps:
|
||||||
|
- run: echo "Release approved"
|
||||||
|
|
||||||
|
create-deployment:
|
||||||
|
name: create-deployment
|
||||||
|
needs:
|
||||||
|
- validate-release
|
||||||
|
- release-gate
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: release
|
||||||
|
steps:
|
||||||
|
- run: echo "Release deployment created"
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
needs:
|
||||||
|
- validate-release
|
||||||
|
- release-gate
|
||||||
|
- create-deployment
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
- name: Publish release
|
- name: Publish release
|
||||||
env:
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
TAG: v${{ inputs.version }}
|
TAG: v${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
|
||||||
|
echo "::error::Version must match MAJOR.MINOR.PATCH (e.g., 8.1.0)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
RELEASE_JSON=$(gh release view "$TAG" --json isDraft,targetCommitish 2>&1) || {
|
RELEASE_JSON=$(gh release view "$TAG" --json isDraft,targetCommitish 2>&1) || {
|
||||||
echo "::error::No release found for $TAG"
|
echo "::error::No release found for $TAG"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user