test(ci): cover the release versionCode gate, run Python through uv #4
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: Release Please | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: # lets maintainers kick release-please manually | |
| # via `gh workflow run "Release Please"` or the | |
| # "Run workflow" button in the Actions UI. Still | |
| # only opens a PR if there are qualifying commits | |
| # since the last tag. | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: googleapis/release-please-action@v5 | |
| id: release | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # release-please-action's Dart release-type has a known bug with | |
| # pre-release suffixes: each cycle re-injects another `+-b` into | |
| # pubspec, so main accumulates `0.0.X-b+-b+-b+...+N`. The CI | |
| # build step repairs in-place on the runner, but main itself | |
| # was never cleaned. This step checks out the release-please PR | |
| # branch, normalises pubspec, and amend-pushes — so the merged | |
| # commit lands a clean SemVer and main never accumulates. | |
| # | |
| # Needs its own checkout because the action above doesn't fetch | |
| # the repo (it talks to the GitHub API directly). `persist- | |
| # credentials: true` (default) keeps the GITHUB_TOKEN-backed | |
| # credential so the force-push at the end authenticates. | |
| - name: Checkout for pubspec repair | |
| if: ${{ steps.release.outputs.pr != '' }} | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Repair pubspec.yaml on release-please PR branch | |
| if: ${{ steps.release.outputs.pr != '' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_RAW: ${{ steps.release.outputs.pr }} | |
| run: | | |
| PR_NUMBER=$(echo "$PR_RAW" | jq -r '.number // empty') | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "no PR number in release-please output, skipping repair" | |
| exit 0 | |
| fi | |
| BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName -q .headRefName) | |
| git fetch origin "$BRANCH" | |
| git checkout "$BRANCH" | |
| before=$(grep '^version:' pubspec.yaml) | |
| sed -i -E 's/^(version: [0-9.]+-[a-zA-Z0-9.]+)(\+-[^+]+)+(\+[0-9]+)$/\1\3/' pubspec.yaml | |
| after=$(grep '^version:' pubspec.yaml) | |
| if [ "$before" != "$after" ]; then | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add pubspec.yaml | |
| git commit --amend --no-edit | |
| git push --force-with-lease origin "$BRANCH" | |
| echo "repaired pubspec on $BRANCH: '$before' -> '$after'" | |
| else | |
| echo "pubspec already clean: $before" | |
| fi | |
| - name: Dispatch release build | |
| if: ${{ steps.release.outputs.release_created }} | |
| uses: peter-evans/repository-dispatch@v4 | |
| with: | |
| event-type: release | |
| client-payload: '{"tag":"${{ steps.release.outputs.tag_name }}","version":"${{ steps.release.outputs.version }}"}' |