ci: add uppt release flow (#84) #1
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] | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| # this is required to trigger releases when the release PR is merged, or to rerun a release if needed | |
| workflow_dispatch: | |
| permissions: {} | |
| jobs: | |
| # Parse commits since the last tag, push a `release/vX.Y.Z` branch, open | |
| # or update a draft release PR, and close any superseded release PRs | |
| # (e.g. `release/v1.0.1` when the bump is now `release/v1.1.0`). | |
| pr: | |
| if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # push the `release/vX.Y.Z` branch and delete superseded ones | |
| pull-requests: write # create a release PR, update its body, close superseded PRs | |
| steps: | |
| - uses: danielroe/uppt/pr@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| packages: | | |
| aliases | |
| core | |
| fetchindex | |
| newest | |
| oldest | |
| parsefiles | |
| ranges | |
| static | |
| !opt | |
| !translate | |
| # The release PR was merged: tag the squash commit, cut a GitHub release | |
| # from the PR body, and dispatch the publish workflow. The `release/v` | |
| # head-ref guard keeps regular feature-PR merges from triggering this; | |
| # the head-repo guard keeps merged fork PRs from triggering it. | |
| release: | |
| if: | | |
| github.event_name == 'pull_request' | |
| && github.event.pull_request.merged == true | |
| && startsWith(github.event.pull_request.head.ref, 'release/v') | |
| && github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: release-${{ github.event.pull_request.number }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write # push the `vX.Y.Z` tag and create the GitHub release | |
| actions: write # `gh workflow run release.yml --ref vX.Y.Z` chained dispatch | |
| steps: | |
| - uses: danielroe/uppt/release@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| packages: | | |
| aliases | |
| core | |
| fetchindex | |
| newest | |
| oldest | |
| parsefiles | |
| ranges | |
| static | |
| !opt | |
| !translate | |
| # The chained dispatch from `release` lands here as a `workflow_dispatch` | |
| # event on a `vX.Y.Z` tag ref. The `pack` job installs deps, runs | |
| # `pnpm pack` (or `npm pack`), and uploads the tarball as a workflow | |
| # artifact. See "Lifecycle scripts" below for what runs where. Manual | |
| # recovery uses the same path (Run workflow -> pick a `v*` tag). | |
| pack: | |
| if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: pack-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: {} | |
| outputs: | |
| files: ${{ steps.pack.outputs.files }} | |
| steps: | |
| - id: pack | |
| uses: danielroe/uppt/pack@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5 | |
| with: | |
| packages: | | |
| aliases | |
| core | |
| fetchindex | |
| newest | |
| oldest | |
| parsefiles | |
| ranges | |
| static | |
| !opt | |
| !translate | |
| # `publish` downloads the prebuilt tarball from the pack job's | |
| # artifact and stages it for publish. | |
| publish: | |
| if: | | |
| github.event_name == 'workflow_dispatch' | |
| && startsWith(github.ref, 'refs/tags/v') | |
| && needs.pack.outputs.files != '[]' | |
| needs: pack | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| id-token: write # OIDC claim for npm trusted publisher | |
| environment: npm # must match the trusted-publisher entry on npmjs.com | |
| steps: | |
| - uses: danielroe/uppt/publish@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5 | |
| with: | |
| files: ${{ needs.pack.outputs.files }} |