-
Notifications
You must be signed in to change notification settings - Fork 54
373 lines (329 loc) · 16.1 KB
/
template-pre-release.yaml
File metadata and controls
373 lines (329 loc) · 16.1 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
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
371
372
373
#
# This workflow helps to create a release candidate branch and a pre-release tag.
# It also allows to update the dev version.
#
# HOW TO USE:
#
# To call this reusable workflow, copy the code between === lines to a new workflow file,
# uncomment and adjust "uses" as needed (use the latest tag available).
# ======================================================================
#
# name: Pre-Release of XXX component
#
# on:
# workflow_dispatch:
# inputs:
# new-version:
# description: 'New version to be set. (1.0.1)'
# type: string
# required: true
# release-date:
# description: 'Release date. (YYYY-MM-DD)'
# type: string
# required: true
# new-dev-release:
# description: 'Set the new dev version. (1.0.1)'
# type: string
# required: false
#
#jobs:
# create-release-candidate:
# uses: OutSystems/ui-components.github-reusable-workflows/.github/workflows/pre-release.yaml@CommitHash #v?.?.?
# with:
# new-version: ${{ inputs.new-version }}
# release-date: ${{ inputs.release-date }}
# new-dev-release: ${{ inputs.new-dev-release }}
#
# ======================================================================
#
name: Pre-Release
on:
workflow_call:
inputs:
new-version:
description: 'New version to be set. (1.0.1)'
type: string
required: true
release-date:
description: 'Release date. (YYYY-MM-DD)'
type: string
required: true
new-dev-release:
description: 'Set the new dev version. (1.0.1)'
type: string
required: false
secrets:
GPG_PRIVATE_KEY:
description: 'GPG private key'
required: true
OSUI_AZURE_CLIENT_ID:
description: 'Azure Client ID for authentication'
required: true
OSUI_AZURE_TENANT_ID:
description: 'Azure Tenant ID for authentication'
required: true
OSUI_AZURE_SUBSCRIPTION_ID:
description: 'Azure Subscription ID for authentication'
required: true
jobs:
run-lint-on-dev:
name: Run lint on dev branch
runs-on: ubuntu-latest
permissions:
contents: read
if: ${{ inputs.new-version }}
steps:
- name: 📥 Checkout into dev
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: dev
- name: 📦 Install project dependencies
run: npm install
- name: 🏗️ Run build
run: npm run build
cleanup-existing-rc:
needs: run-lint-on-dev
name: Cleanup existing rc branch and tag
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
if: ${{ inputs.new-version }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get GitHub Token
id: get-github-token
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gitpersonal-token-prd
- name: 📥 Checkout with token
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
- name: 🗑️ Delete existing branch rc${{ inputs.new-version }} if exists
run: |
if git ls-remote --exit-code --heads origin rc${{ inputs.new-version }}; then
echo "Branch rc${{ inputs.new-version }} exists. Deleting..."
git push origin --delete rc${{ inputs.new-version }}
else
echo "Branch rc${{ inputs.new-version }} does not exist."
fi
- name: 🗑️ Delete existing tag v${{ inputs.new-version }} if exists
run: |
if git ls-remote --exit-code --tags origin refs/tags/v${{ inputs.new-version }}; then
echo "Tag v${{ inputs.new-version }} exists. Deleting..."
git push origin --delete refs/tags/v${{ inputs.new-version }}
else
echo "Tag v${{ inputs.new-version }} does not exist."
fi
create-rc:
needs: cleanup-existing-rc
name: Create rc branch
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
if: ${{ inputs.new-version }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get GitHub Token
id: get-github-token
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gitpersonal-token-prd
- name: 📥 Checkout into dev
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: dev
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
- name: 🔄 Create branch rc${{ inputs.new-version }}
run: |
git checkout -b rc${{ inputs.new-version }}
git push -u origin rc${{ inputs.new-version }}
set-tag:
needs: create-rc
name: Set tag
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
if: ${{ inputs.new-version }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get GitHub Token
id: get-github-token
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gitpersonal-token-prd
- name: 📥 Checkout into rc${{ inputs.new-version }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: rc${{ inputs.new-version }}
fetch-depth: 0
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
- name: 🔖 Set tag
run: |
git tag v${{ inputs.new-version }} HEAD
git push origin --tags
set-pre-release:
needs: set-tag
name: Set pre-release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
if: ${{ inputs.new-version }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get GitHub Token
id: get-github-token
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gitpersonal-token-prd
- name: 📦 Create release
id: create_release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
with:
tag_name: v${{ inputs.new-version }}
name: Release of version ${{ inputs.new-version }} (${{ inputs.release-date }})
body: |
### What's New
- First
- ...
### Fixed Issues and Improvements
- First
- ...
draft: false
prerelease: true
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
update-dev-version:
needs: create-rc
name: Update dev version
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
# This job creates a branch from dev, updates the version, commits the changes,
# and creates a PR into dev. This is required because the bot does not have
# permissions to commit directly to the dev branch.
if: ${{ inputs.new-version && inputs.new-dev-release }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get GitHub Token
id: get-github-token
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gitpersonal-token-prd
- name: 📥 Checkout into dev
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: dev
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
# Create a new branch from dev for the version update.
# If the branch already exists (e.g., workflow was run twice), checkout the existing branch
# instead of creating a duplicate. This makes the workflow idempotent.
- name: 🔄 Create branch chore/update-dev-version-${{ inputs.new-dev-release }}
run: |
if git ls-remote --exit-code --heads origin chore/update-dev-version-${{ inputs.new-dev-release }}; then
echo "Branch chore/update-dev-version-${{ inputs.new-dev-release }} already exists. Checking out..."
git fetch origin chore/update-dev-version-${{ inputs.new-dev-release }}
git checkout chore/update-dev-version-${{ inputs.new-dev-release }}
else
echo "Creating new branch chore/update-dev-version-${{ inputs.new-dev-release }}"
git checkout -b chore/update-dev-version-${{ inputs.new-dev-release }}
git push -u origin chore/update-dev-version-${{ inputs.new-dev-release }}
fi
env:
GITHUB_TOKEN: ${{ steps.get-github-token.outputs.az-keyvault-value }}
- name: 🕸️ Install project dependencies
run: npm install
- name: 🔖 Update dev version into v${{ inputs.new-dev-release }}
run: |
npm run gta-update-version --newVersion=${{ inputs.new-dev-release }}
# 14 May 2025 - rug
# Currently Azure Key Vault does not support multi-line secrets, so we are using a secret instead.
# - name: Get GPG key from Azure Key Vault
# id: GetGPGKey
# uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
# with:
# key-name: o11odc-github-gpg-key-prd
- name: 🔑 Get GPG Passphrase from Azure Key Vault
id: GetGPGPassphrase
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-gpg-passphrase-prd
# Commit the version changes to the branch with GPG signing.
# The signed-commit action will stage, commit, and push the changes.
- name: 🔏 Sign and commit version increment to branch chore/update-dev-version-${{ inputs.new-dev-release }}
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/signed-commit@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/signed-commit
with:
commit-branch: chore/update-dev-version-${{ inputs.new-dev-release }}
commit-message: 'Updated into v${{ inputs.new-dev-release }} [skip ci]'
commit-new-files: true
gpg-priv-key: ${{ secrets.GPG_PRIVATE_KEY }}
# gpg-priv-key: ${{ steps.GetGPGKey.outputs.az-keyvault-value }}
gpg-pass-phrase: ${{ steps.GetGPGPassphrase.outputs.az-keyvault-value }}
# Create a pull request from the chore/update-dev-version-${{ inputs.new-dev-release }} branch into dev.
# Since the commit is already pushed to the remote branch, we use GitHub CLI to create a PR.
- name: 🔀 Create pull request
run: |
gh pr create \
--base dev \
--draft \
--head chore/update-dev-version-${{ inputs.new-dev-release }} \
--title "Update version into v${{ inputs.new-dev-release }} [skip ci]" \
--body "$(cat <<EOF
This PR updates the dev version into v${{ inputs.new-dev-release }}.
This PR was automatically created by the Pre-Release workflow.
EOF
)"
env:
GH_TOKEN: ${{ steps.get-github-token.outputs.az-keyvault-value }}