-
Notifications
You must be signed in to change notification settings - Fork 0
370 lines (323 loc) · 13.8 KB
/
create-release.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
name: Create Release
on:
workflow_dispatch:
inputs:
release-type:
required: true
type: choice
description: What type of release
options:
- major
- minor
- patch
jobs:
determine-next-versions:
name: Determine next version
runs-on: ubuntu-latest
outputs:
next-major: ${{ steps.nexttag.outputs.major }}
next-minor: ${{ steps.nexttag.outputs.minor }}
next-patch: ${{ steps.nexttag.outputs.patch }}
branch-major: ${{ steps.branchnames.outputs.major-branch }}
branch-minor: ${{ steps.branchnames.outputs.minor-branch }}
branch-patch: ${{ steps.branchnames.outputs.patch-branch }}
steps:
- name: check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Previous Tag
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.0
- name: Get Next Versions
id: nexttag
uses: "WyriHaximus/github-action-next-semvers@v1"
with:
version: ${{ steps.previoustag.outputs.tag }}
- name: Build Branch Names
id: branchnames
run: |
echo "major-branch=release-major-v${{ steps.nexttag.outputs.major }}" >> $GITHUB_OUTPUT
echo "minor-branch=release-minor-v${{ steps.nexttag.outputs.minor }}" >> $GITHUB_OUTPUT
echo "patch-branch=release-patch-v${{ steps.nexttag.outputs.patch }}" >> $GITHUB_OUTPUT
create-release-branch:
name: Create Release Branch
runs-on: ubuntu-latest
needs: determine-next-versions
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Create major release branch
if: ${{ github.event.inputs.release-type == 'major' }}
run: |
git checkout -b ${{needs.determine-next-versions.outputs.branch-major}}
git push origin ${{needs.determine-next-versions.outputs.branch-major}}
- name: Create minor release branch
if: ${{ github.event.inputs.release-type == 'minor' }}
run: |
git checkout -b ${{needs.determine-next-versions.outputs.branch-minor}}
git push origin ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Create patch release branch
if: ${{ github.event.inputs.release-type == 'patch' }}
run: |
git checkout -b ${{needs.determine-next-versions.outputs.branch-patch}}
git push origin ${{needs.determine-next-versions.outputs.branch-patch}}
bump-version:
name: Bump the version
runs-on: ubuntu-latest
needs: [determine-next-versions, create-release-branch]
steps:
- name: Check out code - major release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'major' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-major}}
- name: Check out code - minor release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Check out code - patch release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-patch}}
- name: Update major version
uses: jsdaniell/[email protected]
if: ${{ github.event.inputs.release-type == 'major' }}
with:
name: "settings.json"
dir: "./Sources/Passage/"
json: "{\n\t\"version\": \"${{ needs.determine-next-versions.outputs.next-major }}\"\n}"
- name: Update minor version
uses: jsdaniell/[email protected]
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
name: "settings.json"
dir: "./Sources/Passage/"
json: "{\n\t\"version\": \"${{ needs.determine-next-versions.outputs.next-minor }}\"\n}"
- name: Update patch version
uses: jsdaniell/[email protected]
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
name: "settings.json"
dir: "./Sources/Passage/"
json: "{\n\t\"version\": \"${{ needs.determine-next-versions.outputs.next-patch }}\"\n}"
- name: Commit major version change
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.event.inputs.release-type == 'major' }}
with:
commit_message: "Generated and Updated Major Version to ${{ needs.determine-next-versions.outputs.next-major }}"
branch: ${{needs.determine-next-versions.outputs.branch-major}}
- name: Commit minor version change
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
commit_message: "Generated and Updated Minor Version to ${{ needs.determine-next-versions.outputs.next-minor }}"
branch: ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Commit patch version change
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
commit_message: "Generated and Updated Patch Version to ${{ needs.determine-next-versions.outputs.next-patch }}"
branch: ${{needs.determine-next-versions.outputs.branch-patch}}
tag-and-create-release:
name: Tag Release
runs-on: ubuntu-latest
needs:
[
determine-next-versions,
create-release-branch,
bump-version,
]
steps:
- name: Check out code - major release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'major' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-major}}
- name: Check out code - minor release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Check out code - patch release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-patch}}
- name: Tag Major
if: ${{ github.event.inputs.release-type == 'major' }}
run: |
tag='v${{ needs.determine-next-versions.outputs.next-major }}'
message='Push tag for new major release v${{ needs.determine-next-versions.outputs.next-major }}'
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
- name: Tag Minor
if: ${{ github.event.inputs.release-type == 'minor' }}
run: |
tag='v${{ needs.determine-next-versions.outputs.next-minor }}'
message='Push tag for new minor release v${{ needs.determine-next-versions.outputs.next-minor }}'
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
- name: Tag Patch
if: ${{ github.event.inputs.release-type == 'patch' }}
run: |
tag='v${{ needs.determine-next-versions.outputs.next-patch }}'
message='Push tag for new patch release v${{ needs.determine-next-versions.outputs.next-patch }}'
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
- name: Create Major Release
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.release-type == 'major' }}
with:
tag: "${{ needs.determine-next-versions.outputs.next-major }}"
generateReleaseNotes: true
draft: false
- name: Create Minor Release
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
tag: "${{ needs.determine-next-versions.outputs.next-minor }}"
generateReleaseNotes: true
draft: false
- name: Create Patch Release
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
tag: "${{ needs.determine-next-versions.outputs.next-patch }}"
generateReleaseNotes: true
draft: false
publish-cocoapod:
name: Publish Cocoapod
runs-on: macos-latest
needs:
[
determine-next-versions,
create-release-branch,
bump-version,
tag-and-create-release,
]
steps:
- name: Check out code - major release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'major' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-major}}
- name: Check out code - minor release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Check out code - patch release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-patch}}
- name: Set up Xcode 15.4
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install Cocoapods
run: gem install cocoapods
- name: Deploy Major to Cocoapds
if: ${{ github.event.inputs.release-type == 'major' }}
run: |
set -eo pipefail
export LIB_VERSION=${{ needs.determine-next-versions.outputs.next-major }}
echo "version: ${LIB_VERSION}"
pod lib lint --allow-warnings
pod trunk push --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
- name: Deploy Minor to Cocoapds
if: ${{ github.event.inputs.release-type == 'minor' }}
run: |
set -eo pipefail
export LIB_VERSION=${{ needs.determine-next-versions.outputs.next-minor }}
echo "version: ${LIB_VERSION}"
pod lib lint --allow-warnings
pod trunk push --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
- name: Deploy Patch to Cocoapds
if: ${{ github.event.inputs.release-type == 'patch' }}
run: |
set -eo pipefail
export LIB_VERSION=${{ needs.determine-next-versions.outputs.next-patch }}
echo "version: ${LIB_VERSION}"
pod lib lint --allow-warnings
pod trunk push --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
create-pull-request:
name: Create Pull Request
runs-on: ubuntu-latest
needs:
[
determine-next-versions,
create-release-branch,
bump-version,
tag-and-create-release,
publish-cocoapod,
]
steps:
- name: Check out code - major release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'major' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-major}}
- name: Check out code - minor release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-minor}}
- name: Check out code - patch release
uses: actions/checkout@v3
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
ref: ${{needs.determine-next-versions.outputs.branch-patch}}
- name: Create pull request for major release into main
uses: thomaseizinger/[email protected]
if: ${{ github.event.inputs.release-type == 'major' }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
head: ${{needs.determine-next-versions.outputs.branch-major}}
base: main
title: v${{ needs.determine-next-versions.outputs.next-major }} into main
body: |
This PR was created by the create-release-branch workflow.
New Release: v${{ needs.determine-next-versions.outputs.next-major }}
I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.
- name: Create pull request for minor release into main
uses: thomaseizinger/[email protected]
if: ${{ github.event.inputs.release-type == 'minor' }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
head: ${{needs.determine-next-versions.outputs.branch-minor}}
base: main
title: v${{ needs.determine-next-versions.outputs.next-minor }} into main
body: |
This PR was created by the create-release-branch workflow.
New Release: v${{ needs.determine-next-versions.outputs.next-minor }}
I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.
- name: Create pull request for patch release into main
uses: thomaseizinger/[email protected]
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
head: ${{needs.determine-next-versions.outputs.branch-patch}}
base: main
title: v${{ needs.determine-next-versions.outputs.next-patch }} into main
body: |
This PR was created by the create-release-branch workflow.
New Release: v${{ needs.determine-next-versions.outputs.next-patch }}
I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.