-
Notifications
You must be signed in to change notification settings - Fork 1
233 lines (227 loc) · 9.2 KB
/
Copy pathrelease-please.yml
File metadata and controls
233 lines (227 loc) · 9.2 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Release Please
# Reusable workflow that automates versioning and releases from Conventional
# Commit messages, via release-please (https://github.com/googleapis/release-please).
#
# The model is two-step, and the second step is the one that releases:
#
# 1. A feature PR merges to main. release-please opens (or updates) a
# "chore(main): release X.Y.Z" **Release PR** that accumulates every change
# since the last release, writes the CHANGELOG, and bumps version files.
# Nothing is tagged yet.
#
# 2. You merge that Release PR. release-please then creates the git tag and
# the GitHub Release.
#
# So a release is still "merge a PR", but it is the Release PR — feature merges
# queue up into it rather than each cutting a version. That gives you a
# reviewable changelog and a release-when-ready gate.
#
# The version bump comes from the commit type:
#
# fix: … → patch (1.2.3 → 1.2.4)
# feat: … → minor (1.2.3 → 1.3.0)
# feat!: … / BREAKING CHANGE: → major (1.2.3 → 2.0.0)
# chore: / docs: / refactor: … → no release
#
# ⚠️ Two prerequisites that fail loudly (or silently) if missed:
#
# * Repository → Settings → Actions → General → "Allow GitHub Actions to
# create and approve pull requests" MUST be enabled, or creating the Release
# PR fails outright.
# * A PR opened with the default GITHUB_TOKEN does not trigger other workflows
# — that is GitHub's recursion guard, not a bug here. CI will not run on the
# Release PR unless you pass a PAT or GitHub App token as the `token` secret.
# Leave it unset if you don't need checks on the Release PR itself.
#
# Usage — releases with no build artifacts:
#
# name: Release
# on:
# push:
# branches: [main]
# permissions:
# contents: write
# issues: write
# pull-requests: write
# jobs:
# release:
# uses: slashdevops/gha-workflows/.github/workflows/release-please.yml@v1
# with:
# release-type: go
#
# Usage — attaching build artifacts to the release that was just created:
#
# jobs:
# release:
# uses: slashdevops/gha-workflows/.github/workflows/release-please.yml@v1
# with:
# release-type: go
#
# build:
# needs: release
# if: needs.release.outputs.released == 'true'
# # ... build, then actions/upload-artifact with name: dist
#
# publish:
# needs: [release, build]
# if: needs.release.outputs.released == 'true'
# uses: slashdevops/gha-workflows/.github/workflows/github-release.yml@v1
# with:
# tag: ${{ needs.release.outputs.tag-name }}
# generate-release-notes: false # keep release-please's CHANGELOG notes
on:
workflow_call:
inputs:
release-type:
description: >
Release strategy — `go`, `simple`, `node`, `python`, `ruby`,
`terraform-module`, and others release-please supports. Ignored when
the repository ships a release-please-config.json.
required: false
type: string
default: simple
config-file:
description: "Path to release-please-config.json. Takes precedence over release-type."
required: false
type: string
default: ""
manifest-file:
description: "Path to .release-please-manifest.json."
required: false
type: string
default: ""
target-branch:
description: "Branch to open the Release PR against. Detected by default."
required: false
type: string
default: ""
path:
description: "Release from a subdirectory rather than the repository root."
required: false
type: string
default: ""
include-component-in-tag:
description: "Prefix tags with the component name, for releasing several packages from one repo."
required: false
type: boolean
default: false
release-as:
description: "Force a specific version instead of deriving it from the commits."
required: false
type: string
default: ""
versioning-strategy:
description: "release-please versioning strategy."
required: false
type: string
default: default
skip-github-release:
description: "Maintain the Release PR but never tag. Useful for a dry run."
required: false
type: boolean
default: false
skip-github-pull-request:
description: >
Skip the Release PR and tag straight from main. Turns this into
release-on-every-merge and gives up the reviewable changelog — prefer
the default unless you specifically want that.
required: false
type: boolean
default: false
secrets:
token:
description: >
PAT or GitHub App token, only needed if CI must run on the Release PR.
Falls back to GITHUB_TOKEN, which cannot trigger other workflows.
required: false
outputs:
released:
description: "'true' when a release was created (the Release PR was merged this run)."
value: ${{ jobs.release-please.outputs.released }}
pr-created:
description: "'true' when a Release PR was opened or updated this run."
value: ${{ jobs.release-please.outputs.pr-created }}
tag-name:
description: "Tag created (e.g. v1.4.0). Empty unless a release happened."
value: ${{ jobs.release-please.outputs.tag-name }}
version:
description: "Version without the leading v (e.g. 1.4.0). Empty unless a release happened."
value: ${{ jobs.release-please.outputs.version }}
major:
description: "Major component of the released version."
value: ${{ jobs.release-please.outputs.major }}
minor:
description: "Minor component of the released version."
value: ${{ jobs.release-please.outputs.minor }}
patch:
description: "Patch component of the released version."
value: ${{ jobs.release-please.outputs.patch }}
sha:
description: "Commit SHA the release was cut from."
value: ${{ jobs.release-please.outputs.sha }}
html-url:
description: "Browser URL of the created release."
value: ${{ jobs.release-please.outputs.html-url }}
upload-url:
description: "Asset upload URL of the created release."
value: ${{ jobs.release-please.outputs.upload-url }}
workflow_dispatch:
permissions:
contents: write # create the tag, the release, and the CHANGELOG commit
pull-requests: write # open and groom the Release PR
issues: write # label the Release PR
defaults:
run:
# Explicit, because the runner's default is not the same shell everywhere and this one
# brings `pipefail` with it: a step whose pipeline fails in an earlier stage now fails
# the step instead of reporting the exit code of the last command in it.
shell: bash
jobs:
release-please:
name: Release Please
runs-on: ubuntu-latest
outputs:
# `|| 'false'` because release-please only sets these when they are true;
# unset would otherwise propagate as an empty string and every downstream
# `== 'true'` guard would read the same as a legitimate "no release".
released: ${{ steps.release.outputs.releases_created || 'false' }}
pr-created: ${{ steps.release.outputs.prs_created || 'false' }}
tag-name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
major: ${{ steps.release.outputs.major }}
minor: ${{ steps.release.outputs.minor }}
patch: ${{ steps.release.outputs.patch }}
sha: ${{ steps.release.outputs.sha }}
html-url: ${{ steps.release.outputs.html_url }}
upload-url: ${{ steps.release.outputs.upload_url }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v5.0.0
with:
token: ${{ secrets.token || github.token }}
release-type: ${{ inputs.release-type }}
config-file: ${{ inputs.config-file }}
manifest-file: ${{ inputs.manifest-file }}
target-branch: ${{ inputs.target-branch }}
path: ${{ inputs.path }}
include-component-in-tag: ${{ inputs.include-component-in-tag }}
release-as: ${{ inputs.release-as }}
versioning-strategy: ${{ inputs.versioning-strategy }}
skip-github-release: ${{ inputs.skip-github-release }}
skip-github-pull-request: ${{ inputs.skip-github-pull-request }}
- name: Summary
run: |
{
echo "# Release Please"
echo ""
if [ "${{ steps.release.outputs.releases_created }}" = "true" ]; then
echo "🏷️ Released **${{ steps.release.outputs.tag_name }}**"
echo ""
echo "${{ steps.release.outputs.html_url }}"
elif [ "${{ steps.release.outputs.prs_created }}" = "true" ]; then
echo "📝 Release PR opened or updated — merge it to cut the release."
else
echo "No release and no Release PR: nothing since the last release warrants a version bump."
fi
} >> $GITHUB_STEP_SUMMARY