ci: replace the two-stage release flow with release-please (#143) #127
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - '*.x' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| concurrency: | |
| group: release-${{ github.ref_name }} | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| name: 🚀 Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Reversible half: keep the Release PR current. Never gated. | |
| - uses: googleapis/release-please-action@v4 | |
| with: | |
| config-file: release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| target-branch: ${{ github.ref_name }} | |
| skip-github-release: true | |
| # Irreversible half is gated on this. Go resolves a v2+ module only if go.mod carries the | |
| # matching /vN suffix, and release-please never rewrites it, so a major stays a manual | |
| # migration. proxy.golang.org caches a tag permanently, so this must hold before tagging. | |
| - name: Verify go.mod major matches the version about to be tagged | |
| run: | | |
| version="$(jq -r '.["."]' .release-please-manifest.json)" | |
| expected="${version%%.*}" | |
| module_path="$(sed -n 's/^module //p' go.mod)" | |
| module_major="$(printf '%s' "$module_path" | sed -n 's|.*/v\([0-9][0-9]*\)$|\1|p')" | |
| [ -n "$module_major" ] || module_major=1 | |
| if [ "$module_major" != "$expected" ]; then | |
| echo "::error::go.mod declares '$module_path' (major v$module_major) but the pending release is $version." | |
| echo "::error::A major must be migrated on main BEFORE its Release PR merges. See CONTRIBUTING.md." | |
| exit 1 | |
| fi | |
| - uses: googleapis/release-please-action@v4 | |
| with: | |
| config-file: release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| target-branch: ${{ github.ref_name }} | |
| skip-github-pull-request: true |