-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
246 lines (218 loc) · 9.39 KB
/
action.yml
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
234
235
236
237
238
239
240
241
242
243
244
245
246
name: release-train
description: Release every PR merge. No magic commit message required.
branding:
icon: send
color: yellow
inputs:
repo:
description: GitHub repository in the form of owner/repo.
default: ${{ github.repository }}
check-pr:
description: |-
Operates as if the given PR has already been merged. Useful for making sure the PR is properly labeled.
Skips tag and release.
default: ${{ github.event.number }}
labels:
description: |-
PR label alias in the form of "<alias>=<label>" where <label> is a canonical label.
Accepts multiple values. One value per line.
checkout-dir:
description: The directory where the repository is checked out.
default: ${{ github.workspace }}
ref:
description: git ref.
default: HEAD
github-token:
description: 'The GitHub token to use for authentication. Must have `contents: write` permission if creating a release or tag.'
default: ${{ github.token }}
create-tag:
description: |-
Whether to create a tag for the release.
Only literal 'true' will be treated as true.
create-release:
description: |-
Whether to create a release. Implies create-tag.
Only literal 'true' will be treated as true.
draft:
description: |-
Leave the release as a draft.
Only literal 'true' will be treated as true.
tag-prefix:
description: The prefix to use for the tag.
default: v
v0:
description: |-
Assert that current major version is 0 and treat breaking changes as minor changes.
Errors if the major version is not 0.
Only literal 'true' will be treated as true.
initial-release-tag:
description: The tag to use if no previous version can be found. Set to "" to cause an error instead.
default: v0.0.0
pre-tag-hook:
description: "Command to run before tagging the release. You may abort the release by exiting with a non-zero exit code. Exit code 0\nwill continue the release. Exit code 10 will skip the release without error. Any other exit code will abort the release\nwith an error.\n\nEnvironment variables available to the hook:\n\n RELEASE_VERSION\n The semantic version being released (e.g. 1.2.3).\n\n RELEASE_TAG\n The tag being created (e.g. v1.2.3).\n\n PREVIOUS_VERSION \n The previous semantic version (e.g. 1.2.2). Empty on\n first release.\n\n FIRST_RELEASE\n Whether this is the first release. Either \"true\" or\n \"false\".\n\n GITHUB_TOKEN\n The GitHub token that was provided to release-train.\n\n RELEASE_NOTES_FILE\n A file path where you can write custom release notes.\n When nothing is written to this file, release-train\n will use GitHub's default release notes.\n\n RELEASE_TARGET\n A file path where you can write an alternate git ref\n to release instead of HEAD.\n\n ASSETS_DIR\n A directory where you can write release assets. All\n files in this directory will be uploaded as release\n assets.\n\nIn addition to the above environment variables, all variables from release-train's environment are available to the\nhook.\n\nWhen the hook creates a tag named $RELEASE_TAG, it will be used as the release target instead of either HEAD or the\nvalue written to $RELEASE_TARGET."
pre-release-hook:
deprecationMessage: deprecated
description: '*deprecated* Will be removed in a future release. Alias for pre-tag-hook.'
release-refs:
description: |-
Only allow tags and releases to be created from matching refs. Refs can be patterns accepted by git-show-ref.
If undefined, any branch can be used.
Accepts multiple values. One value per line.
tempdir:
description: The prefix to use with mktemp to create a temporary directory.
debug:
description: |-
Enable debug logging.
Only literal 'true' will be treated as true.
release-train-bin:
description: Path to release-train binary. Only needed if you're using a custom release-train binary.
outputs:
previous-ref:
value: ${{ steps.release.outputs.previous-ref }}
description: A git ref pointing to the previous release, or the current ref if no previous release can be found.
previous-version:
value: ${{ steps.release.outputs.previous-version }}
description: The previous version on the release branch.
first-release:
value: ${{ steps.release.outputs.first-release }}
description: Whether this is the first release on the release branch. Either "true" or "false".
release-version:
value: ${{ steps.release.outputs.release-version }}
description: The version of the new release. Empty if no release is called for.
release-tag:
value: ${{ steps.release.outputs.release-tag }}
description: The tag of the new release. Empty if no release is called for.
change-level:
value: ${{ steps.release.outputs.change-level }}
description: The level of change in the release. Either "major", "minor", "patch" or "none".
created-tag:
value: ${{ steps.release.outputs.created-tag }}
description: Whether a tag was created. Either "true" or "false".
created-release:
value: ${{ steps.release.outputs.created-release }}
description: Whether a release was created. Either "true" or "false".
pre-release-hook-output:
value: ${{ steps.release.outputs.pre-release-hook-output }}
description: '*deprecated* Will be removed in a future release. Alias for pre-tag-hook-output'
pre-release-hook-aborted:
value: ${{ steps.release.outputs.pre-release-hook-aborted }}
description: '*deprecated* Will be removed in a future release. Alias for pre-tag-hook-aborted'
pre-tag-hook-output:
value: ${{ steps.release.outputs.pre-tag-hook-output }}
description: The stdout of the pre-tag-hook. Empty if pre_release_hook is not set or if the hook returned an exit other than 0 or 10.
pre-tag-hook-aborted:
value: ${{ steps.release.outputs.pre-tag-hook-aborted }}
description: Whether pre-tag-hook issued an abort by exiting 10. Either "true" or "false".
runs:
using: composite
steps:
- name: release
id: release
shell: sh
run: |
#!/bin/sh
set -e
ACTION_DIR="${{ github.action_path }}"
RELEASE_TRAIN_BIN="$ACTION_DIR"/script/release-train
if [ -n "${{ inputs.release-train-bin }}" ]; then
RELEASE_TRAIN_BIN="${{ inputs.release-train-bin }}"
fi
set -- --output-format action
if [ -n "${{ inputs.repo }}" ]; then
set -- "$@" --repo '${{ inputs.repo }}'
fi
if [ -n "${{ inputs.check-pr }}" ]; then
set -- "$@" --check-pr '${{ inputs.check-pr }}'
fi
while IFS= read -r line; do
[ -n "$line" ] || continue
set -- "$@" --label "$line"
done <<EOF
${{ inputs.labels }}
EOF
if [ -n "${{ inputs.checkout-dir }}" ]; then
set -- "$@" --checkout-dir '${{ inputs.checkout-dir }}'
fi
if [ -n "${{ inputs.ref }}" ]; then
set -- "$@" --ref '${{ inputs.ref }}'
fi
if [ -n "${{ inputs.github-token }}" ]; then
set -- "$@" --github-token '${{ inputs.github-token }}'
fi
case "${{ inputs.create-tag }}" in
true)
set -- "$@" --create-tag
;;
false) ;;
"") ;;
*)
echo "Input create-tag must be 'true' or 'false'. Got '${{ inputs.create-tag }}'." >&2
exit 1
;;
esac
case "${{ inputs.create-release }}" in
true)
set -- "$@" --create-release
;;
false) ;;
"") ;;
*)
echo "Input create-release must be 'true' or 'false'. Got '${{ inputs.create-release }}'." >&2
exit 1
;;
esac
case "${{ inputs.draft }}" in
true)
set -- "$@" --draft
;;
false) ;;
"") ;;
*)
echo "Input draft must be 'true' or 'false'. Got '${{ inputs.draft }}'." >&2
exit 1
;;
esac
if [ -n "${{ inputs.tag-prefix }}" ]; then
set -- "$@" --tag-prefix '${{ inputs.tag-prefix }}'
fi
case "${{ inputs.v0 }}" in
true)
set -- "$@" --v0
;;
false) ;;
"") ;;
*)
echo "Input v0 must be 'true' or 'false'. Got '${{ inputs.v0 }}'." >&2
exit 1
;;
esac
if [ -n "${{ inputs.initial-release-tag }}" ]; then
set -- "$@" --initial-tag '${{ inputs.initial-release-tag }}'
fi
if [ -n "${{ inputs.pre-tag-hook }}" ]; then
set -- "$@" --pre-tag-hook '${{ inputs.pre-tag-hook }}'
fi
if [ -n "${{ inputs.pre-release-hook }}" ]; then
set -- "$@" --pre-release-hook '${{ inputs.pre-release-hook }}'
fi
while IFS= read -r line; do
[ -n "$line" ] || continue
set -- "$@" --release-ref "$line"
done <<EOF
${{ inputs.release-refs }}
EOF
if [ -n "${{ inputs.tempdir }}" ]; then
set -- "$@" --tempdir '${{ inputs.tempdir }}'
fi
case "${{ inputs.debug }}" in
true)
set -- "$@" --debug
;;
false) ;;
"") ;;
*)
echo "Input debug must be 'true' or 'false'. Got '${{ inputs.debug }}'." >&2
exit 1
;;
esac
"$RELEASE_TRAIN_BIN" "$@"