-
Notifications
You must be signed in to change notification settings - Fork 1.8k
685 lines (601 loc) · 30.2 KB
/
build.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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
name: Build and Test
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
archive_test_results:
description: 'If set to true, the unit and integration test results will be archived to the build artifacts page.'
required: false
default: 'false'
# DAT branches can get triggered from this logic
pull_request_target:
types:
- opened
- reopened
- synchronize
- labeled
push:
branches:
- master
- main
- github-action-**
paths-ignore:
- '**.md'
env:
MAVEN_VERSION: '3.9.2'
jobs:
check_build_safety:
permissions:
contents: none
name: Check if Build should be done
runs-on: ubuntu-22.04
steps:
- name: Emit failure code for unsafe fork PRs
if: github.event.pull_request && github.event.pull_request.head.repo.full_name != 'liquibase/liquibase' && github.event.label.name != 'SafeToBuild'
run: |
echo "PR from Fork is NOT safe to build"
echo "A member of Liquibase team needs to apply label 'SafeToBuild'! "
exit 1
setup:
name: Setup
needs: check_build_safety
runs-on: ubuntu-22.04
outputs:
proBranchName: ${{ steps.find-branches.outputs.proBranchName }}
proBranchSha: ${{ steps.find-branches.outputs.proBranchSha }}
thisSha: ${{ steps.find-branches.outputs.thisSha }}
thisBranchName: ${{ steps.find-branches.outputs.thisBranchName }}
thisBranchFileName: ${{ steps.find-branches.outputs.thisBranchFileName }}
thisRepositoryName: ${{ steps.find-branches.outputs.thisRepoName }}
thisRepositoryOwner: ${{ steps.find-branches.outputs.thisRepoName }}
standAlonePR: ${{ steps.find-branches.outputs.standAlonePR }}
stablePro: ${{ steps.find-branches.outputs.stablePro }}
timestamp: ${{ steps.get-date.outputs.date }}
setupSuccessful: "true"
steps:
- name: Failsafe
uses: actions/github-script@v6
with:
script: |
if (${{ github.run_attempt }} % 5 == 0) {
core.setFailed("Fail every 5 run attempts to catch accidental infinite loops");
}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Get current date
id: get-date
run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S %Z')"
- name: Find corresponding branches
id: find-branches
uses: actions/github-script@v6
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
core.setOutput("thisSha", helper.getCurrentSha());
core.setOutput("thisBranchName", helper.getCurrentBranch());
core.setOutput("thisBranchFileName", helper.getCurrentBranch().replace(/[^a-zA-Z0-9\-_\.]/g, "_"));
core.setOutput("thisRepoName", helper.getRepositoryName());
core.setOutput("thisRepoOwner", helper.getRepositoryOwner());
let proStatusMessage = "success";
let proFailed = false;
let branch = await helper.findMatchingBranch("liquibase", "liquibase-pro");
//count as not a stand-alone PR for branch builds on master/main, even though there are no PRs
if (helper.getCurrentBranch() == 'master' || helper.getCurrentBranch() == 'main' && branch.pullRequestId) {
core.setOutput("standAlonePR", helper.getCurrentBranch() !== branch.name);
} else {
core.setOutput("standAlonePR", true);
}
if (!branch.lastSuccessfulRunNumber) {
proFailed = true;
proStatusMessage = "Matching pro branch has never passed. Falling back to master"
branch = await helper.findMatchingBranch("liquibase", "liquibase-pro", ["main", "master"])
}
core.setOutput("proBranchName", branch.name);
core.setOutput("proBranchSha", branch.sha);
if (!proFailed) {
if (!branch.workflowId) {
proStatusMessage = "does not have a ran workflow";
proFailed = true
} else if ( branch.runStatus != "completed") {
proStatusMessage = "build is "+ branch.runStatus;
proFailed = true
} else if ( branch.runConclusion != "success") {
proStatusMessage = "build conclusion was "+branch.runConclusion;
proFailed = true
}
}
statusMessage = "liquibase/liquibase-pro:"+branch.name+"@" + branch.sha.substring(0, 7) + " " + proStatusMessage;
console.log("Pro failed?" + proFailed + ": "+statusMessage);
github.rest.repos.createCommitStatus({
"owner": "liquibase",
"repo": "liquibase",
"sha": helper.getCurrentSha(),
"state": (proFailed ? "failure" : "success"),
"target_url": branch.runHtmlUrl,
"context": "Stable Liquibase Pro",
"description": statusMessage
});
core.setOutput("stablePro", !proFailed);
- name: Upload Event File
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}
build:
name: Build & Test (Java ${{ matrix.java }} ${{ matrix.os }})
needs: setup
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, macos-latest, windows-2019 ]
java: [ 8, 11, 17, 20 ]
exclude:
# exclude non-java 8 on macos and windows builds
- os: macos-latest
java: 11
- os: windows-2019
java: 11
- os: macos-latest
java: 17
- os: windows-2019
java: 17
- os: macos-latest
java: 20
- os: windows-2019
java: 20
runs-on: ${{ matrix.os }}
env:
OS_TYPE: ${{ matrix.os }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Built Code Cache
if: ${{ matrix.java == 11}}
uses: actions/cache@v3.3.1
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: Build & Test Java 8
if: ${{ matrix.java == 8}}
run: |
mvn -B "-Dbuild.repository.owner=${{ needs.setup.outputs.thisRepositoryOwner }}" "-Dbuild.repository.name=${{ needs.setup.outputs.thisRepositoryName }}" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.thisSha }}" "-DtrimStackTrace=false" -pl '!liquibase-cdi-jakarta' clean verify -DskipITs
- name: Build & Test Java non-jdk-8
if: ${{ matrix.java != 8}}
run: |
mvn -B "-Dbuild.repository.owner=${{ needs.setup.outputs.thisRepositoryOwner }}" "-Dbuild.repository.name=${{ needs.setup.outputs.thisRepositoryName }}" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.thisSha }}" "-DtrimStackTrace=false" clean verify -DskipITs
- name: Remove Original Jars for *nix
if: env.OS_TYPE != 'windows-2019'
run: |
find . -name original-*.jar -exec rm {} \;
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: liquibase-test-results-jdk${{ matrix.java }}
path: |
./**/target/surefire-reports
./**/target/site
- name: Save Jacoco Report for Sonar
if: ${{ matrix.java == 11 && matrix.os == 'ubuntu-22.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-jacoco-test-results
path: |
./liquibase-standard/target/jacoco.exec
- name: Archive Modules
if: ${{ matrix.java == 11 && matrix.os == 'ubuntu-22.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-modules
path: |
*/target/*-0-SNAPSHOT.jar
integration-test:
name: Integration Test
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
testSystem:
- db2
- h2
#- h2:1.4
- hsqldb
- mariadb
- mssql
- mysql
- oracle
- postgresql
- sqlite
- firebird
needs: setup
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Prepare
id: prepare
uses: actions/github-script@v6
with:
script: |
core.setOutput("testResultsArtifact", "liquibase-test-results-integration-${{ matrix.testSystem }}".replace(/[^a-zA-Z0-9\-_]/g, "_"));
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: Restore Built Code Cache
uses: actions/cache@v3.3.1
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Login to Artifactory
uses: docker/login-action@v2
with:
registry: docker-dev.artifactory.datical.net
username: ${{ secrets.ARTIFACTORY_USER }}
password: ${{ secrets.ARTIFACTORY_TOKEN }}
- name: Run Tests
run: mvn -B clean verify -DtrimStackTrace=false -Dliquibase.sdk.testSystem.test=${{ matrix.testSystem }} -Dliquibase.sdk.testSystem.acceptLicenses=${{ matrix.testSystem }} -Dtest='*IntegrationTest,*ExecutorTest' -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.prepare.outputs.testResultsArtifact }}
path: |
./**/target/surefire-reports
- name: Save Jacoco Report for Sonar
uses: actions/upload-artifact@v3
with:
name: liquibase-integration-jacoco-test-results-${{ matrix.testSystem }}
path: |
./liquibase-integration-tests/target/jacoco.exec
sonar:
needs: [ build, integration-test ]
uses: liquibase/build-logic/.github/workflows/sonar-test-scan.yml@v0.4.7
with:
thisBranchName: ${{ needs.setup.outputs.thisBranchName }}
thisSha: ${{ needs.setup.outputs.thisSha }}
liquibaseBranchName: ${{ needs.setup.outputs.liquibaseBranchName }}
pullRequestNumber: ${{ github.event.pull_request.number }}
pullRequestBranchName: ${{ github.event.pull_request.head.ref }}
pullRequestBaseBranchName: ${{ github.event.pull_request.base.ref }}
testedClassesModuleName: liquibase-standard
dbPlatforms: h2,hsqldb,mariadb,mssql,mysql,oracle,postgresql,sqlite,firebird
secrets: inherit
package:
name: Package Artifacts
runs-on: macos-latest
needs: [ setup, build ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
# this includes all the tar files included in the previous runs. So in the next step we deploy what was previously build
- name: Built Code Cache
uses: actions/cache@v3.3.1
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
##Cache based on install4j file, since changes to JVM is seen in there. If install4j version changes without changing the file, change the prefix letter before hashFiles to force a new cache
- name: Install4j Cache
uses: actions/cache@v3.3.1
with:
key: install4j-A${{ hashFiles('liquibase-dist/src/main/install4j/liquibase.install4j') }}
path: ~/.install4j8/**
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
gpg-private-key: ${{ secrets.GPG_SECRET }}
gpg-passphrase: GPG_PASSPHRASE
cache: 'maven'
overwrite-settings: false
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
# look for dependencies in maven
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v21
with:
repositories: |
[
{
"id": "liquibase",
"url": "https://maven.pkg.github.com/liquibase/liquibase",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: ${{ env.MAVEN_VERSION }}
# Version artifact based off of branch
- name: Version Artifact
run: |
version=${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT
# Replace / with - in branch name
version=$(echo "$version" | sed 's/\//-/g')
mvn versions:set -DnewVersion="$version"
- name: Build & Sign Artifacts
env:
INSTALL4J_LICENSE: ${{ secrets.INSTALL4J_LICENSE }}
INSTALL4J_APPLE_KEY: ${{ secrets.INSTALL4J_APPLE_KEY }}
INSTALL4J_APPLE_KEY_PASSWORD: ${{ secrets.INSTALL4J_APPLE_KEY_PASSWORD }}
INSTALL4J_APPLE_ID: ${{ secrets.INSTALL4J_APPLE_ID }}
INSTALL4J_APPLE_ID_PASSWORD: ${{ secrets.INSTALL4J_APPLE_ID_PASSWORD }}
INSTALL4J_WINDOWS_KEY: ${{ secrets.INSTALL4J_WINDOWS_KEY }}
INSTALL4J_WINDOWS_KEY_PASSWORD: ${{ secrets.INSTALL4J_WINDOWS_KEY_PASSWORD }}
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
## save install4j code signing keys
mkdir -p liquibase-dist/target/keys
echo "Saving apple key"
echo "$INSTALL4J_APPLE_KEY" | base64 -d > liquibase-dist/target/keys/datical_apple.p12
echo "Saving windows key"
echo "$INSTALL4J_WINDOWS_KEY" | base64 -d > liquibase-dist/target/keys/datical_windows.pfx
# we are packaging and deploying liquibase tar which includes liquibase-commercial
mvn -B -pl liquibase-dist -P liquibase-commercial source:jar package -DskipTests "-Dliquibase-pro.version=${{ needs.setup.outputs.proBranchName }}-SNAPSHOT" "-Dbuild.repository.owner=${{ needs.setup.outputs.thisRepositoryOwner }}" "-Dbuild.repository.name=${{ needs.setup.outputs.thisRepositoryName }}" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchFileName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.thisSha }}" "-Dbuild.timestamp=${{ needs.setup.outputs.timestamp }}"
## extract tar content for other artifacts
mkdir -p liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT
(cd liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT && tar -xzf ../liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT.tar.gz)
## verify that the contents of the tar matches the expectation
echo "Comparing the contents of the tar.gz with the expected contents (using baseline file in liquibase-dist directory) to ensure that no new files were accidentally added. A failure here indicates that a new file was added to the tar.gz, and it should either be rectififed or added to the baseline."
brew install tree --quiet
tree liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT -o actual-distribution-contents.txt --noreport
# remove first line of actual, because it contains the folder name, which the expected will not have
echo "$(tail -n +2 actual-distribution-contents.txt)" > actual-distribution-contents.txt
diff actual-distribution-contents.txt liquibase-dist/expected-distribution-contents.txt
rm -rf actual-distribution-contents.txt
##create zip file from tar content
(cd liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT && zip -r ../liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT.zip *)
ls liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT
##create installer - disabled here but run as nightly job and as part of release workflow
# (cd liquibase-dist && ${{ github.workspace }}/.github/util/package-install4j.sh 0-SNAPSHOT)
find . -name original-*.jar -exec rm {} \;
mkdir -p artifacts
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT.tar.gz artifacts
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT.zip artifacts
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT/internal/lib/liquibase-core.jar artifacts/liquibase-core-0-SNAPSHOT.jar
cp liquibase-core/target/liquibase-core-0-SNAPSHOT-sources.jar artifacts/liquibase-core-0-SNAPSHOT-sources.jar
cp target/liquibase-0-SNAPSHOT-javadoc.jar artifacts/liquibase-core-0-SNAPSHOT-javadoc.jar
##create installer - disabled here but run as nightly job and as part of release workflow
#cp liquibase-dist/target/liquibase-*-installer-* artifacts
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT.jar artifacts
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT-sources.jar artifacts
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT-javadoc.jar artifacts
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT.jar artifacts
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT-sources.jar artifacts
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT-javadoc.jar artifacts
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT.jar artifacts
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT-sources.jar artifacts
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT-javadoc.jar artifacts
echo "Source code not available for liquibase-commercial" > /tmp/readme.source.txt
(cd /tmp && jar cf liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-sources.jar readme.source.txt)
echo "Javadocs not available for liquibase-commercial" > /tmp/readme.javadocs.txt
(cd /tmp && jar cf liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-javadoc.jar readme.javadocs.txt)
commercialJarM2Location=/Users/runner/.m2/repository/org/liquibase/liquibase-commercial/${{ needs.setup.outputs.proBranchName }}-SNAPSHOT/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT.jar
cp $commercialJarM2Location artifacts
cp /tmp/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-sources.jar artifacts
cp /tmp/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-javadoc.jar artifacts
.github/util/sign-artifacts.sh artifacts
##prepare branch-named convenience artifacts directories
mkdir artifacts-named
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT.tar.gz artifacts-named/liquibase-${{ needs.setup.outputs.thisBranchFileName }}.tar.gz
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT/internal/lib/liquibase-core.jar artifacts-named/liquibase-core-${{ needs.setup.outputs.thisBranchFileName }}.jar
#cp liquibase-core/target/liquibase-core-0-SNAPSHOT.jar artifacts-named/liquibase-core-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT.jar artifacts-named/liquibase-maven-plugin-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT.jar artifacts-named/liquibase-cdi-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT.jar artifacts-named/liquibase-cdi-jakarta-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT-deps.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}-deps.jar
cp $commercialJarM2Location artifacts-named/liquibase-commercial-${{ needs.setup.outputs.thisBranchFileName }}.jar
- name: Archive Packages
uses: actions/upload-artifact@v3
with:
name: liquibase-artifacts
path: artifacts/*
- name: Archive Convenience Zip
uses: actions/upload-artifact@v3
with:
name: liquibase-zip-${{ needs.setup.outputs.thisBranchFileName }}
path: liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchFileName }}-SNAPSHOT/*
- name: Archive Convenience Artifacts
uses: actions/upload-artifact@v3
with:
name: liquibase-artifacts-${{ needs.setup.outputs.thisBranchFileName }}
path: artifacts-named/*
# Publish to GitHub Packages. We are building a tar file which includes liquibase-commercial hence we need "-Dliquibase-pro.version"
- name: Publish tar.gz package to GPM
run: |
mvn -B -pl liquibase-dist -P liquibase-commercial clean deploy -DskipTests "-Dliquibase-pro.version=${{ needs.setup.outputs.proBranchName }}-SNAPSHOT" "-Dbuild.timestamp=${{ needs.setup.outputs.timestamp }}" "-Dbuild.repository.owner=${{ needs.setup.outputs.thisRepositoryOwner }}" "-Dbuild.repository.name=${{ needs.setup.outputs.thisRepositoryName }}" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchFileName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.thisSha }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# this triggers the pro-tests and test-harness to run
finish:
name: Finish Build
runs-on: ubuntu-22.04
needs: [ setup, build, package, sonar]
if: ${{ needs.setup.outputs.setupSuccessful }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Coordinate Liquibase-Pro
uses: actions/github-script@v6
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
let currentBranchInfo = await helper.findMatchingBranch("liquibase", "liquibase-pro");
let thisStatus = "${{ needs.package.result }}" == "success" ? "success" : "failure";
let stablePro = ("${{ needs.setup.outputs.stablePro }}" == "true");
let standalonePR = "${{ needs.setup.outputs.standAlonePR }}" == "true";
console.log("Stand alone PR: "+standalonePR);
let runFunctionalTests = false;
let markFunctionalTestsStatus = "failure";
let markFunctionalTestsDescription = "Unexpected setup";
if (stablePro) {
console.log("Pro is stable");
runFunctionalTests = true;
markFunctionalTestsStatus = "pending";
markFunctionalTestsDescription = "Trigger internal functional tests";
} else {
console.log("Last pro was unstable");
runFunctionalTests = false;
markFunctionalTestsStatus = "failure";
markFunctionalTestsDescription = "Liquibase Pro is unstable";
let checks = await github.rest.repos.listCommitStatusesForRef({
"owner": "liquibase",
"repo": "liquibase-pro",
"ref": currentBranchInfo.sha
});
let failedCheckingUs = false;
if (standalonePR) {
for (let status of checks.data) {
if (status.context == "Stable Liquibase Core") {
console.log("Stable Liquibase Core is "+ status.state);
failedCheckingUs = (status.state == "failure");
}
}
}
if (failedCheckingUs) {
console.log("Rerun liquibase-commercial that was waiting on us");
//octokit removed the retryWorkflow function
github.request("POST "+currentBranchInfo.runRerunUrl);
//await github.rest.actions.retryWorkflow({
// "owner": "liquibase",
// "repo": "liquibase-pro",
// "run_id": currentBranchInfo.workflowId
//});
}
}
if (standalonePR) {
console.log("Do not mark base pro branch as included in this");
} else {
console.log("Mark 'Included in Liquibase Core' status as "+thisStatus);
github.rest.repos.createCommitStatus({
"owner": "liquibase",
"repo": "liquibase-pro",
"sha": currentBranchInfo.sha,
"state": thisStatus,
"context": "Stable Liquibase Core",
"target_url": currentBranchInfo.runHtmlUrl,
"description": "Latest Liquibase Core build"
});
}
if (runFunctionalTests) {
let testsBranch = await helper.findMatchingBranch("liquibase", "liquibase-pro-tests");
let notices = [];
if (context.payload.pull_request) {
console.log("Sending pull request information");
notices = ["Triggered by PR " + context.payload.pull_request.html_url];
}
console.log("Trigger functional tests");
let workflowDispatch = await github.rest.actions.createWorkflowDispatch({
"owner": "liquibase",
"repo": "liquibase-pro-tests",
"workflow_id": "test.yml",
"ref": testsBranch.name,
"inputs": {
"liquibaseCommit": helper.getCurrentSha(),
"runDescription": "Triggered by https://github.com/liquibase/liquibase/actions/runs/"+context.runId,
"liquibaseBranch": helper.getCurrentBranch(),
"runDetails": JSON.stringify({
"liquibaseBranch": helper.getCurrentBranch(),
"notices": notices
})
}
});
let testHarnessBranch = await helper.findMatchingBranch("liquibase", "liquibase-test-harness");
if (testHarnessBranch.name == "main" || testHarnessBranch.name == "master") {
testHarnessBranch.name = "develop";
}
console.log("Trigger Test Harness tests");
let testHarnessWorkflowDispatch = await github.rest.actions.createWorkflowDispatch({
"owner": "liquibase",
"repo": "liquibase-test-harness",
"workflow_id": "main.yml",
"ref": testHarnessBranch.name,
"inputs": {
"liquibaseCommit": helper.getCurrentSha(),
"runDescription": "Triggered by https://github.com/liquibase/liquibase/actions/runs/"+context.runId,
"liquibaseBranch": helper.getCurrentBranch(),
"liquibaseRepo": "liquibase/liquibase",
"runDetails": JSON.stringify({
"liquibaseBranch": helper.getCurrentBranch(),
"notices": notices
})
}
});
}
await github.rest.repos.createCommitStatus({
"owner": "liquibase",
"repo": "liquibase",
"sha": helper.getCurrentSha(),
"state": markFunctionalTestsStatus,
"context": "Run Functional Tests",
"description": markFunctionalTestsDescription
});
await github.rest.repos.createCommitStatus({
"owner": "liquibase",
"repo": "liquibase",
"sha": helper.getCurrentSha(),
"state": markFunctionalTestsStatus,
"context": "Run Test Harness",
"description": markFunctionalTestsDescription
});