Repository navigation
81 lines (76 loc) · 3.05 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (76 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Release
# uppt (https://github.com/danielroe/uppt) runs releases, as in docov. Each push to main opens or
# updates a draft release PR from the conventional commits since the last tag, bumping
# package.json. Merging it tags the commit and cuts a GitHub release. There's nothing to publish:
# callers use the action from the repository at a commit SHA.
#
# The release PR is opened with a GitHub App's token (vars.CI_APP_CLIENT_ID and
# secrets.CI_APP_PRIVATE_KEY), since this repository doesn't let Actions create pull requests.
on:
push:
# release/v* picks up hand edits to an open release PR
branches: [main, 'release/v*']
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
prerelease:
description: Cut a prerelease instead of a normal release, e.g. `beta`, `rc`, or `0`
required: false
default: ''
permissions: {}
# Back-to-back pushes to main would otherwise race on the release PR's branch. Runs for the same
# event and ref wait their turn, the newest replacing any still waiting.
concurrency:
group: release-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: false
jobs:
# open or update a draft release PR from conventional commits
pr:
if: |
!github.event.repository.fork
&& (
(
github.event_name == 'push'
&& (
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|| startsWith(github.ref, 'refs/heads/release/v')
)
) || github.event_name == 'workflow_dispatch'
)
runs-on: ubuntu-latest
timeout-minutes: 10
permissions: {} # uppt/pr does everything with the app token below
steps:
- id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.CI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
permission-contents: write # push the release/vX.Y.Z branch and delete superseded ones
permission-pull-requests: write # open and update the release PR, close superseded ones
- uses: danielroe/uppt/pr@6c1a9b480b0f02a3f535dedaf1a113f590aa56f2 # v0.6.12
with:
token: ${{ steps.app-token.outputs.token }}
prerelease: ${{ inputs.prerelease }}
title: 'chore(release): v{version}'
# release PR merged: tag it and cut a GitHub release
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
&& !github.event.repository.fork
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: release-${{ github.event.pull_request.number }}
cancel-in-progress: false
permissions:
contents: write
steps:
- uses: danielroe/uppt/release@6c1a9b480b0f02a3f535dedaf1a113f590aa56f2 # v0.6.12
with:
token: ${{ secrets.GITHUB_TOKEN }}