fix(ci): use monorepo-mode release-please outputs #22
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"] | |
| paths: | |
| - "apps/cli/**" | |
| - "docs/reference/cli.md" | |
| - "go.work" | |
| - "go.work.sum" | |
| - ".goreleaser-cli.yml" | |
| - ".release-please-config.json" | |
| - ".github/workflows/release-please.yml" | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| # release-please-action runs in monorepo mode here because | |
| # .release-please-config.json declares a `packages` map (even though | |
| # there is currently only one package). In that mode the top-level | |
| # `release_created` / `tag_name` outputs are NOT set — those exist | |
| # only in single-package mode. Instead we read: | |
| # - `releases_created`: top-level boolean ("any package released") | |
| # - `<path>--tag_name`: tag name for the specific package path | |
| release_created: ${{ steps.release.outputs.releases_created }} | |
| tag_name: ${{ steps.release.outputs['apps/cli--tag_name'] }} | |
| steps: | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }} | |
| config-file: .release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| # When the release-please-action above creates a new GitHub Release, the | |
| # tag it pushes is authored by the default GITHUB_TOKEN, which GitHub's | |
| # anti-recursion guard prevents from firing `on: push: tags` workflows. | |
| # That's why a separate release-cli.yml listening on `v*` tag pushes | |
| # silently fails for release-please-created tags. To avoid depending on a | |
| # PAT/App token in `RELEASE_PLEASE_TOKEN` (which has historically expired | |
| # and broken releases), we build artifacts in this same workflow, | |
| # conditional on release-please's release output. | |
| goreleaser: | |
| needs: release-please | |
| if: needs.release-please.outputs.release_created == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ needs.release-please.outputs.tag_name }} | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run CLI tests | |
| run: go test -mod=readonly ./apps/cli/... | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean --config .goreleaser-cli.yml | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GOFLAGS: -mod=readonly |