Skip to content

Commit a660aaa

Browse files
committed
release: add protected release workflow
1 parent 9ea0c8d commit a660aaa

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Semantic version tag such as v1.0.0
8+
required: true
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
environment: release
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Validate version
20+
run: |
21+
python - <<'PY'
22+
import os, re
23+
version = os.environ['VERSION']
24+
if not re.fullmatch(r'v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?', version):
25+
raise SystemExit('Invalid version: ' + version)
26+
print(version)
27+
PY
28+
env:
29+
VERSION: ${{ inputs.version }}
30+
- name: Create release
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
VERSION: ${{ inputs.version }}
34+
run: gh release create "$VERSION" --title "$VERSION" --generate-notes

0 commit comments

Comments
 (0)