Cut Release #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |