Skip to content

Commit 26892db

Browse files
authored
Add a release workflow (#349)
Mirroring astral-sh/setup-uv#839
1 parent d7f6ad6 commit 26892db

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version (e.g., 8.1.0)"
8+
required: true
9+
type: string
10+
11+
permissions: {}
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
environment: release
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
with:
23+
persist-credentials: false
24+
25+
- name: Validate version
26+
env:
27+
VERSION: ${{ inputs.version }}
28+
run: |
29+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
30+
echo "::error::Version must match MAJOR.MINOR.PATCH (e.g., 8.1.0)"
31+
exit 1
32+
fi
33+
34+
- name: Publish release
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
TAG: v${{ inputs.version }}
38+
run: |
39+
RELEASE_JSON=$(gh release view "$TAG" --json isDraft,targetCommitish 2>&1) || {
40+
echo "::error::No release found for $TAG"
41+
exit 1
42+
}
43+
44+
IS_DRAFT=$(echo "$RELEASE_JSON" | jq -r '.isDraft')
45+
TARGET=$(echo "$RELEASE_JSON" | jq -r '.targetCommitish')
46+
47+
if [[ "$IS_DRAFT" != "true" ]]; then
48+
echo "::error::Release $TAG already exists and is not a draft"
49+
exit 1
50+
fi
51+
52+
if [[ "$TARGET" != "$GITHUB_SHA" ]]; then
53+
echo "::error::Draft release target ($TARGET) does not match current commit ($GITHUB_SHA)"
54+
exit 1
55+
fi
56+
57+
echo "Publishing draft release $TAG"
58+
gh release edit "$TAG" --draft=false

0 commit comments

Comments
 (0)