Repository navigation
237 lines (234 loc) · 9.11 KB
/
Copy pathrelease.yml
File metadata and controls
237 lines (234 loc) · 9.11 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
234
235
236
237
name: Release Gem
on:
workflow_call:
inputs:
version:
description: Optional release version overriding the checked-in version in the standard workflow.
type: string
gemspec:
description: Optional gemspec path; defaults to the only root gemspec.
type: string
gemfile:
description: Gemfile for Bundler, relative to the repository root; its lockfile must be committed or ignored.
type: string
default: Gemfile
rubygems-owner:
description: Optional RubyGems account ID for first publication with a pending trusted publisher.
type: string
git-user-name:
description: Author name for release and next development iteration commits.
type: string
default: github-actions[bot]
git-user-email:
description: Author email for release and next development iteration commits.
type: string
default: github-actions[bot]@users.noreply.github.com
ruby-version:
description: Ruby version used to validate and build.
type: string
required: true
timezone:
description: Timezone for release dates and Git timestamps.
type: string
default: UTC
prepare-artifacts:
description: Optional command preparing explicitly selected input archives before context capture.
type: string
default: ''
artifacts:
description: Additional newline-separated artifact paths to preserve before publication.
type: string
default: ''
validate:
description: Command validating release preconditions; must exit nonzero on failure.
type: string
default: bundle exec rake release:validate
prepare:
description: Command to prepare release files; INPUT_VERSION is the selected release version.
type: string
default: bundle exec rake release:prepare
test:
description: Command to test the prepared release.
type: string
default: bundle exec rake
publish:
description: Idempotent publication command; runs after recovery artifacts are preserved.
type: string
default: bundle exec rake release:publish
bump:
description: Command to prepare, commit, and push the next development iteration.
type: string
default: bundle exec rake release:bump
success:
description: Command to run after the release and next development iteration succeed.
type: string
default: bundle exec rake release:success
failure:
description: Command to run after a release job failure.
type: string
default: bundle exec rake release:failure
dry-run:
description: Check release prerequisites, such as RubyGems Trusted Publishing, without editing files, pushing, or publishing.
type: boolean
default: false
concurrency:
group: ruby-gem-release-${{ github.repository }}
cancel-in-progress: false
jobs:
preflight:
if: ${{ inputs.dry-run }}
runs-on: ubuntu-latest
environment: release
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_GEMSPEC_PATH: ${{ inputs.gemspec }}
BUNDLE_GEMFILE: ${{ inputs.gemfile }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GIT_USER_NAME: ${{ inputs.git-user-name }}
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
RUBYGEMS_OWNER_ID: ${{ inputs.rubygems-owner }}
TZ: ${{ inputs.timezone }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
fetch-depth: 0
- uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
id: setup_ruby
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
- name: Capture Release Context
id: capture_release_context
env:
RELEASE_STEP_ID: capture_release_context
run: bundle exec rake release:workflow:capture
- name: Check Release Prerequisites
id: check_release_prerequisites
env:
GH_TOKEN: ${{ github.token }}
RELEASE_STEP_ID: check_release_prerequisites
run: bundle exec rake release:workflow:preflight
release:
if: ${{ !inputs.dry-run }}
runs-on: ubuntu-latest
environment: release
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_GEMSPEC_PATH: ${{ inputs.gemspec }}
BUNDLE_GEMFILE: ${{ inputs.gemfile }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GIT_USER_NAME: ${{ inputs.git-user-name }}
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
RUBYGEMS_OWNER_ID: ${{ inputs.rubygems-owner }}
TZ: ${{ inputs.timezone }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
fetch-depth: 0
- uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
id: setup_ruby
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
- name: Prepare Input Artifacts
id: prepare_input_artifacts
if: ${{ inputs.prepare-artifacts != '' }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_COMMAND: ${{ inputs.prepare-artifacts }}
RELEASE_STEP_ID: prepare_input_artifacts
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Capture Release Context
id: capture_release_context
env:
RELEASE_STEP_ID: capture_release_context
run: bundle exec rake release:workflow:capture
- name: Check Release Prerequisites
id: check_release_prerequisites
env:
GH_TOKEN: ${{ github.token }}
RELEASE_STEP_ID: check_release_prerequisites
run: bundle exec rake release:workflow:preflight
- name: Validate Release
id: validate_release
env:
RELEASE_COMMAND: ${{ inputs.validate }}
RELEASE_STEP_ID: validate_release
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Prepare Release
id: prepare_release
env:
RELEASE_COMMAND: ${{ inputs.prepare }}
RELEASE_STEP_ID: prepare_release
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Resolve Prepared Version
id: resolve_prepared_version
env:
RELEASE_STEP_ID: resolve_prepared_version
run: bundle exec rake release:workflow:resolve
- name: Test Release
id: test_release
env:
RELEASE_COMMAND: ${{ inputs.test }}
RELEASE_STEP_ID: test_release
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Checkpoint Release
id: checkpoint_release
env:
RELEASE_STEP_ID: checkpoint_release
run: bundle exec rake release:workflow:checkpoint
- name: Preserve Release Artifacts
id: preserve_release_artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-gem-${{ env.RELEASE_VERSION }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ inputs.artifacts }}
${{ runner.temp }}/release.gem
${{ runner.temp }}/release.json
${{ runner.temp }}/release.bundle
if-no-files-found: error
retention-days: 30
- name: Publish Release
id: publish_release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_COMMAND: ${{ inputs.publish }}
RELEASE_STEP_ID: publish_release
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Prepare Next Development Iteration
id: prepare_next_development_iteration
env:
RELEASE_COMMAND: ${{ inputs.bump }}
RELEASE_STEP_ID: prepare_next_development_iteration
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Run Release Success Callback
id: release_success_callback
if: ${{ success() }}
env:
RELEASE_COMMAND: ${{ inputs.success }}
RELEASE_STEP_ID: release_success_callback
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"
- name: Determine Release Failure Phase
id: determine_release_failure_phase
if: ${{ failure() && steps.setup_ruby.outcome == 'success' }}
env:
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bundle exec rake release:workflow:failure_phase
- name: Run Release Failure Callback
id: release_failure_callback
if: ${{ failure() && steps.setup_ruby.outcome == 'success' }}
env:
RELEASE_COMMAND: ${{ inputs.failure }}
RELEASE_STEP_ID: release_failure_callback
RELEASE_STEPS_JSON: ${{ toJSON(steps) }}
run: bash -euo pipefail -c "$RELEASE_COMMAND"