Skip to content

Commit fbbb08a

Browse files
committed
ci: add uppt release flow
Signed-off-by: Tierney Cyren <hello@bnb.im>
1 parent ebe784f commit fbbb08a

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [closed]
8+
branches: [main]
9+
# this is required to trigger releases when the release PR is merged, or to rerun a release if needed
10+
workflow_dispatch:
11+
12+
permissions: {}
13+
14+
jobs:
15+
# Parse commits since the last tag, push a `release/vX.Y.Z` branch, open
16+
# or update a draft release PR, and close any superseded release PRs
17+
# (e.g. `release/v1.0.1` when the bump is now `release/v1.1.0`).
18+
pr:
19+
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write # push the `release/vX.Y.Z` branch and delete superseded ones
23+
pull-requests: write # create a release PR, update its body, close superseded PRs
24+
steps:
25+
- uses: danielroe/uppt/pr@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
# The release PR was merged: tag the squash commit, cut a GitHub release
30+
# from the PR body, and dispatch the publish workflow. The `release/v`
31+
# head-ref guard keeps regular feature-PR merges from triggering this;
32+
# the head-repo guard keeps merged fork PRs from triggering it.
33+
release:
34+
if: |
35+
github.event_name == 'pull_request'
36+
&& github.event.pull_request.merged == true
37+
&& startsWith(github.event.pull_request.head.ref, 'release/v')
38+
&& github.event.pull_request.head.repo.full_name == github.repository
39+
runs-on: ubuntu-latest
40+
concurrency:
41+
group: release-${{ github.event.pull_request.number }}
42+
cancel-in-progress: false
43+
permissions:
44+
contents: write # push the `vX.Y.Z` tag and create the GitHub release
45+
actions: write # `gh workflow run release.yml --ref vX.Y.Z` chained dispatch
46+
steps:
47+
- uses: danielroe/uppt/release@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
48+
with:
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
51+
# The chained dispatch from `release` lands here as a `workflow_dispatch`
52+
# event on a `vX.Y.Z` tag ref. The `pack` job installs deps, runs
53+
# `pnpm pack` (or `npm pack`), and uploads the tarball as a workflow
54+
# artifact. See "Lifecycle scripts" below for what runs where. Manual
55+
# recovery uses the same path (Run workflow -> pick a `v*` tag).
56+
pack:
57+
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v')
58+
runs-on: ubuntu-latest
59+
concurrency:
60+
group: pack-${{ github.ref }}
61+
cancel-in-progress: false
62+
permissions: {}
63+
outputs:
64+
files: ${{ steps.pack.outputs.files }}
65+
steps:
66+
- id: pack
67+
uses: danielroe/uppt/pack@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
68+
69+
# `publish` downloads the prebuilt tarball from the pack job's
70+
# artifact and stages it for publish.
71+
publish:
72+
if: |
73+
github.event_name == 'workflow_dispatch'
74+
&& startsWith(github.ref, 'refs/tags/v')
75+
&& needs.pack.outputs.files != '[]'
76+
needs: pack
77+
runs-on: ubuntu-latest
78+
concurrency:
79+
group: publish-${{ github.ref }}
80+
cancel-in-progress: false
81+
permissions:
82+
id-token: write # OIDC claim for npm trusted publisher
83+
environment: npm # must match the trusted-publisher entry on npmjs.com
84+
steps:
85+
- uses: danielroe/uppt/publish@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
86+
with:
87+
files: ${{ needs.pack.outputs.files }}

0 commit comments

Comments
 (0)