forked from liquibase/liquibase
-
Notifications
You must be signed in to change notification settings - Fork 0
405 lines (356 loc) · 14.7 KB
/
create-release.yml
File metadata and controls
405 lines (356 loc) · 14.7 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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
name: Attach Artifacts To Draft Release
permissions:
contents: write
actions: write
packages: write
id-token: write
on:
workflow_dispatch:
inputs:
version:
description: "Version (example: 4.8.2)"
required: true
branch:
description: "Branch to release (Defaults to master)"
required: false
default: "master"
runId:
description: "RunId of liquibase/liquibase artifacts to attach"
required: true
standalone_zip:
description: "Flag to indicate if the workflow is triggered to create a standalone zip"
required: false
type: boolean
default: false
dry_run:
description: "Flag to indicate if the workflow is triggered to create a dry-run release"
required: false
type: boolean
default: false
workflow_call:
inputs:
version:
description: "Version (example: 4.8.2)"
required: true
type: string
branch:
description: "Branch to release (Defaults to master)"
required: false
default: "master"
type: string
runId:
description: "RunId of liquibase/liquibase artifacts to attach"
required: true
type: string
standalone_zip:
description: "Flag to indicate if the workflow is triggered to create a standalone zip"
required: true
type: boolean
default: false
dry_run:
description: "Flag to indicate if the workflow is triggered to create a dry-run release"
required: true
type: boolean
default: false
outputs:
dry_run_zip_url:
description: "The URL of the created zip file"
value: ${{ jobs.build-installers.outputs.dry_run_zip_url }}
dry_run_tar_gz_url:
description: "The URL of the created tar.gz file"
value: ${{ jobs.build-installers.outputs.dry_run_tar_gz_url }}
jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
outputs:
version: ${{ inputs.version }}
branch: ${{ inputs.branch }}
runId: ${{ inputs.runId }}
uber_jar_runId: ${{ steps.get_run_id.outputs.run_id }}
steps:
- run: |
echo "Creating version ${{ inputs.version }} from ${{ inputs.branch }} with artifacts from build ${{ inputs.runId }} "
# owasp-scanner:
# needs: [setup]
# uses: liquibase/build-logic/.github/workflows/owasp-scanner.yml@main
# with:
# branch: ${{ needs.setup.outputs.branch }}
# secrets: inherit
reversion:
needs: [setup]
name: Re-version artifacts ${{ needs.setup.outputs.version }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- name: Configure AWS credentials for vault access
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.LIQUIBASE_VAULT_OIDC_ROLE_ARN }}
aws-region: us-east-1
- name: Get secrets from vault
id: vault-secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
,/vault/liquibase
parse-json-secrets: true
- name: Download liquibase-artifacts
uses: dawidd6/action-download-artifact@v11
with:
workflow: run-tests.yml
run_id: ${{ needs.setup.outputs.runId }}
name: liquibase-artifacts
path: download/liquibase-artifacts
- name: Get Current Run ID
id: get_run_id
run: |
run_id=${{ github.run_id }}
echo "uber_jar_runId=${run_id}" >> $GITHUB_OUTPUT
- name: Convert escaped newlines and set GPG key
run: |
{
echo "GPG_KEY_CONTENT<<GPG_EOF"
printf '%b' "${{ env.GPG_SECRET }}"
echo
echo "GPG_EOF"
} >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: "8"
distribution: "temurin"
gpg-private-key: ${{ env.GPG_KEY_CONTENT }}
gpg-passphrase: GPG_PASSPHRASE
env:
GPG_PASSWORD: ${{ env.GPG_PASSPHRASE }}
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: |
[
{
"id": "liquibase",
"url": "https://maven.pkg.github.com/liquibase/liquibase",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ env.LIQUIBOT_PAT_GPM_ACCESS }}"
}
]
- name: Re-version Artifacts
env:
GPG_PASSWORD: ${{ env.GPG_PASSPHRASE }}
run: |
scripts_branch=${{ github.ref }}
mkdir -p $PWD/.github/util/
# Download a script (re-version.sh) from a URL and save it to the specified directory
curl -o $PWD/.github/util/re-version.sh https://raw.githubusercontent.com/liquibase/liquibase/$scripts_branch/.github/util/re-version.sh
# Download another script (sign-artifacts.sh) from a URL and save it to the specified directory
curl -o $PWD/.github/util/sign-artifacts.sh https://raw.githubusercontent.com/liquibase/liquibase/$scripts_branch/.github/util/sign-artifacts.sh
curl -o $PWD/.github/util/ManifestReversion.java https://raw.githubusercontent.com/liquibase/liquibase/$scripts_branch/.github/util/ManifestReversion.java
chmod +x $PWD/.github/util/re-version.sh
chmod +x $PWD/.github/util/ManifestReversion.java
chmod +x $PWD/.github/util/sign-artifacts.sh
$PWD/.github/util/re-version.sh download/liquibase-artifacts "${{ needs.setup.outputs.version }}" "${{ needs.setup.outputs.branch }}"
# Execute the sign-artifacts.sh script with specific arguments
$PWD/.github/util/sign-artifacts.sh download/liquibase-artifacts "${{ needs.setup.outputs.version }}" "${{ needs.setup.outputs.branch }}"
$PWD/.github/util/sign-artifacts.sh re-version/out
# Move files to a specific directory
mkdir re-version/final
mv re-version/out/liquibase-core-${{ needs.setup.outputs.version }}.jar re-version/final
mv re-version/out/liquibase-${{ needs.setup.outputs.version }}.tar.gz re-version/final
mv re-version/out/liquibase-${{ needs.setup.outputs.version }}.zip re-version/final
(cd re-version/out/ && zip liquibase-additional-${{ needs.setup.outputs.version }}.zip *)
mv re-version/out/liquibase-additional-${{ needs.setup.outputs.version }}.zip re-version/final
- name: Cache Completed Artifacts
uses: actions/cache@v4.3.0
with:
key: completed-artifacts-${{ github.run_number }}-${{ github.run_attempt }}
path: re-version/final
- name: Set repository tags
if: ${{ inputs.standalone_zip == false && inputs.dry_run == false }}
run: |
git tag -f v${{ needs.setup.outputs.version }}
git push -f origin v${{ needs.setup.outputs.version }}
build-installers:
needs: [setup, reversion]
name: Build Installers
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v5
- name: Configure AWS credentials for vault access
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.LIQUIBASE_VAULT_OIDC_ROLE_ARN }}
aws-region: us-east-1
- name: Get secrets from vault
id: vault-secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
,/vault/liquibase
parse-json-secrets: true
- name: Convert escaped newlines and set GPG key
run: |
{
echo "GPG_KEY_CONTENT<<GPG_EOF"
printf '%b' "${{ env.GPG_SECRET }}"
echo
echo "GPG_EOF"
} >> $GITHUB_ENV
- name: Restore Completed Artifacts
uses: actions/cache@v4.3.0
with:
key: completed-artifacts-${{ github.run_number }}-${{ github.run_attempt }}
path: re-version/final
# https://github.com/actions/setup-java/tree/v4/?tab=readme-ov-file#install-multiple-jdks
- name: Set up JDK for GPG
uses: actions/setup-java@v5
with:
java-version: |
17
8
distribution: "temurin"
gpg-private-key: ${{ env.GPG_KEY_CONTENT }}
gpg-passphrase: GPG_PASSPHRASE
env:
GPG_PASSWORD: ${{ env.GPG_PASSPHRASE }}
- name: Decode Client Authentication Certificate
run: |
echo "${{ env.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /tmp/client-auth.p12
- name: Set Environment Variables for Signing
run: |
echo "SM_HOST=${{ env.SM_HOST }}" >> "$GITHUB_ENV"
echo "SM_API_KEY=${{ env.SM_API_KEY }}" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_FILE=/tmp/client-auth.p12" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_PASSWORD=${{ env.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
echo "SM_CODE_SIGNING_CERT_SHA1_HASH=${{ env.SM_CODE_SIGNING_CERT_SHA1_HASH }}" >> "$GITHUB_ENV"
echo "SM_KEY_PAIR_ALIAS=${{ env.SM_KEY_PAIR_ALIAS }}" >> "$GITHUB_ENV"
- name: Install jsign and osslsigncode
run: |
curl -fSslL https://github.com/ebourg/jsign/releases/download/3.1/jsign_3.1_all.deb -o jsign_3.1_all.deb
sudo dpkg --install jsign_3.1_all.deb
sudo apt-get install osslsigncode
- name: Create pkcs11properties.cfg
run: |
cat << EOF > pkcs11properties.cfg
name=signingmanager
library="$(pwd)/.github/util/smpkcs11.so"
slotListIndex=0
EOF
mv pkcs11properties.cfg $(pwd)/.github/util/
- name: Install Android SDK & Build Tools
run: |
export JAVA_HOME=${JAVA_HOME_17_x64}
export PATH="$JAVA_HOME/bin:$PATH"
java -version
ANDROID_SDK_ROOT=$HOME/android-sdk
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
cd "$ANDROID_SDK_ROOT/cmdline-tools"
wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O tools.zip
unzip tools.zip -d temp
rm tools.zip
mv temp/cmdline-tools "$ANDROID_SDK_ROOT/cmdline-tools/latest"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager \
--sdk_root="$ANDROID_SDK_ROOT" \
"platform-tools" "build-tools;30.0.2"
echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "$ANDROID_SDK_ROOT/platform-tools" >> $GITHUB_PATH
echo "$ANDROID_SDK_ROOT/build-tools/30.0.2" >> $GITHUB_PATH
- name: Install DigiCert KeyLocker Client Tools
uses: digicert/ssm-code-signing@v1.1.1
- name: Build Unsigned Windows Installer
env:
INSTALL4J_LICENSE_KEY: ${{ env.INSTALL4J_LICENSE_KEY }}
run: |
version="${{ needs.setup.outputs.version }}"
tarFile=$(pwd)/re-version/final/liquibase-$version.tar.gz
scriptDir=$(pwd)/.github/util/
mkdir -p liquibase-dist/target/liquibase-$version
(cd liquibase-dist/target/liquibase-$version && tar xfz $tarFile)
(cd liquibase-dist && $scriptDir/package-install4j.sh $version)
mv liquibase-dist/target/liquibase-*-installer-* re-version/final
- name: Find Unsigned Windows Installer
id: find-installer
run: |
INSTALLER_PATH=$(find re-version/final -name "liquibase-*-installer-*" | head -n 1)
if [ -z "$INSTALLER_PATH" ]; then
echo "Error: No installer file found!"
exit 1
fi
echo "Found installer: $INSTALLER_PATH"
echo "INSTALLER_PATH=$INSTALLER_PATH" >> $GITHUB_ENV
- name: Sign Windows Installer using KeyLocker
run: |
smctl sign -v --fingerprint "$SM_CODE_SIGNING_CERT_SHA1_HASH" \
--keypair-alias $SM_KEY_PAIR_ALIAS \
--certificate "$SM_CLIENT_CERT_FILE" \
--config-file "$(pwd)/.github/util/pkcs11properties.cfg" \
--input "$INSTALLER_PATH" --tool jsign
- name: Verify Windows Installer Signature
run: osslsigncode verify -CAfile /etc/ssl/certs/ca-certificates.crt -in "$INSTALLER_PATH"
- name: Re-version Installers
env:
GPG_PASSWORD: ${{ env.GPG_PASSPHRASE }}
run: |
version="${{ needs.setup.outputs.version }}"
##Sign Files
$PWD/.github/util/sign-artifacts.sh re-version/final
(cd re-version/final && zip liquibase-additional-$version.zip *.asc *.md5 *.sha1)
rm re-version/final/*.asc
rm re-version/final/*.md5
rm re-version/final/*.sha1
# Check if the tag already exists in OSS repository, if it does, exit with error. This is to prevent the artifacts from being attached to the already released tag.
- name: Check OSS release tag existence, if tag exists, exit with error
run: |
tag="v${{ needs.setup.outputs.version }}"
if git show-ref --tags --quiet --verify -- "refs/tags/$tag"
then
echo "Tag $tag already exists"
exit 1
fi
- name: Attach Files to Draft Release
if: ${{ inputs.standalone_zip == false && inputs.dry_run == false }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.setup.outputs.version }}
fail_on_unmatched_files: true
body: Liquibase ${{ needs.setup.outputs.version }}
generate_release_notes: true
draft: true
files: re-version/final/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attach Files to Dry-Run Draft Release
id: attach-files-dry-run
if: ${{ inputs.standalone_zip == false && inputs.dry_run == true }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.setup.outputs.version }}
fail_on_unmatched_files: true
body: Liquibase ${{ needs.setup.outputs.version }} (Dry-Run)
generate_release_notes: true
draft: true
files: re-version/final/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attach standalone zip to Build
if: ${{ inputs.standalone_zip == true && inputs.dry_run == false }}
uses: actions/upload-artifact@v5
with:
name: liquibase-installers-${{ needs.setup.outputs.version }}
path: re-version/final/*