From d0a067e89d9b3e7ffa44f0a1fab75332810bf792 Mon Sep 17 00:00:00 2001 From: Thomas Owen Date: Thu, 29 Jan 2026 15:16:53 +0000 Subject: [PATCH] chore(ci): Use release-please to orchestrate releases --- .github/workflows/release-please.yml | 19 ++++ .github/workflows/release.yml | 144 --------------------------- 2 files changed, 19 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/release-please.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..177ff8e --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,19 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + issues: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + release-type: python diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 48d2482..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,144 +0,0 @@ -name: Create Release - -on: - workflow_dispatch: - inputs: - version: - description: 'Version number (e.g., 0.2.0)' - required: true - type: string - -permissions: - contents: write - -jobs: - validate-changelog: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Validate changelog contains version - run: | - set -e - VERSION="${{ inputs.version }}" - PATTERN="^## \[(v)?${VERSION}\]" - echo "Checking CHANGELOG.md for header: $PATTERN" - MATCH_COUNT=$(grep -c -E "$PATTERN" CHANGELOG.md || true) - if [ "$MATCH_COUNT" -eq 0 ]; then - echo "ERROR: No changelog section found for v$VERSION" >&2 - exit 1 - fi - if [ "$MATCH_COUNT" -gt 1 ]; then - echo "ERROR: Multiple changelog sections found for v$VERSION" >&2 - exit 1 - fi - echo "Changelog validation passed." - - extract-changelog: - runs-on: ubuntu-latest - needs: validate-changelog - outputs: - notes_artifact: release_notes - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Extract changelog section - run: | - set -e - VERSION="${{ inputs.version }}" - awk -v ver="$VERSION" ' - $0 ~ ("^## \\[v?" ver "\\]") {flag=1} - /^## \[/{ - if (flag && $0 !~ ("^## \\[v?" ver "\\]")) exit - } - flag - ' CHANGELOG.md > raw_release_notes.md || { - echo "Failed to extract changelog section" >&2; exit 1; } - # Trim trailing blank lines - awk 'NF{p=1} p' raw_release_notes.md > release_notes.md - echo "Extracted release notes:"; cat release_notes.md - - name: Upload release notes artifact - uses: actions/upload-artifact@v4 - with: - name: release_notes - path: release_notes.md - - release: - runs-on: ubuntu-latest - needs: extract-changelog - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 # Fetch all history for changelog generation - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - - name: Install uv - uses: astral-sh/setup-uv@v7 - - - name: Configure Git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Bump version with uv - run: | - uv version ${{ inputs.version }} - - - name: Commit version bump - run: | - git add pyproject.toml - git commit --allow-empty -m "Bump version to ${{ inputs.version }}" - git push - - - name: Download extracted release notes - uses: actions/download-artifact@v4 - with: - name: release_notes - path: release_notes - - - name: Create and push tag - run: | - git tag "v${{ inputs.version }}" - git push origin "v${{ inputs.version }}" - - - name: Create GitHub Release - env: - GH_TOKEN: ${{ github.token }} - run: | - gh release create "v${{ inputs.version }}" \ - --title "Release ${{ inputs.version }}" \ - --notes-file release_notes/release_notes.md - - add-wheel: - runs-on: ubuntu-latest - needs: release - environment: release - steps: - - uses: actions/checkout@v5 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - name: Install uv - uses: astral-sh/setup-uv@v7 - - name: Bump version with uv - run: | - uv version ${{ inputs.version }} - - name: Build - run: | - uv build - - name: Upload wheel to release - env: - GH_TOKEN: ${{ github.token }} - run: | - RELEASE_TAG="v${{ inputs.version }}" - for wheel in dist/*.whl; do - gh release upload "$RELEASE_TAG" "$wheel" --clobber - done