-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.27 KB
/
cut-release.yml
File metadata and controls
72 lines (61 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Cut Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v0.2.0 or v0.2.0-beta1)'
required: true
type: string
permissions:
contents: write
jobs:
cut-release:
name: Cut Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "Error: Version must be in format v0.0.0 or v0.0.0-suffix"
echo "Got: $VERSION"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Strip the 'v' prefix for pyproject.toml
echo "VERSION_NUM=${VERSION#v}" >> $GITHUB_ENV
- name: Check if tag already exists
run: |
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Error: Tag $VERSION already exists"
exit 1
fi
- name: Update version in pyproject.toml
run: |
sed -i "s/^version = \".*\"/version = \"$VERSION_NUM\"/" pyproject.toml
echo "Updated pyproject.toml to version $VERSION_NUM"
grep "^version" pyproject.toml
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit version bump
run: |
git add pyproject.toml
git commit -m "Bump version to $VERSION"
- name: Create and push tag
run: |
git tag -a "$VERSION" -m "Release $VERSION"
git push origin HEAD:${{ github.ref_name }}
git push origin "$VERSION"
- name: Summary
run: |
echo "## Tag $VERSION created!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Now run the **Release** workflow manually:" >> $GITHUB_STEP_SUMMARY
echo "1. Go to [Actions → Release](/${{ github.repository }}/actions/workflows/release.yml)" >> $GITHUB_STEP_SUMMARY
echo "2. Click **Run workflow**" >> $GITHUB_STEP_SUMMARY
echo "3. Enter \`$VERSION\` as the tag" >> $GITHUB_STEP_SUMMARY