-
Notifications
You must be signed in to change notification settings - Fork 4
280 lines (256 loc) · 10.5 KB
/
pro-extension-build-for-liquibase.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
name: Build and Test Pro Extension for Liquibase
on:
workflow_call:
inputs:
java:
description: "Java version to test"
required: false
default: "[11, 17, 21]"
type: string
os:
description: "Operating system to build/test on"
required: false
default: '["ubuntu-latest", "windows-latest"]'
type: string
extraCommand:
description: "Specify it if you want to run an extra command before attaching the artifact. This runs on both Linux and Windows runners."
required: false
default: ""
type: string
extraLinuxCommand:
description: "Specify it if you want to run an extra command before attaching the artifact on Linux."
required: false
default: ""
type: string
extraWindowsCommand:
description: "Specify it if you want to run an extra command before attaching the artifact on Windows."
required: false
default: ""
type: string
extraMavenArgs:
description: "Specify it if you want to run an extra maven argument"
required: false
default: ""
type: string
mavenProfiles:
description: "Specify it if you want to run different Maven profiles from the default (coverage). mavenProfiles example: 'coverage,run-proguard'"
required: false
default: "coverage"
type: string
artifactPath:
description: "Specify the path to the artifacts that should be attached to the build. Useful for multi-module extensions."
required: false
default: "."
type: string
combineJars:
description: "Specify it if you want to combine the built jars into a single jar"
required: false
default: false
type: boolean
repository:
required: true
description: 'Repository to check out'
type: string
version:
required: true
description: 'Version to publish'
type: string
secrets:
SONAR_TOKEN:
description: "SONAR_TOKEN from the caller workflow"
required: true
PRO_LICENSE_KEY:
description: "PRO_LICENSE_KEY from the caller workflow"
required: true
AWS_GITHUB_OIDC_ROLE_ARN_S3_GHA:
description: "OIDC Role from the caller workflow"
required: true
env:
AWS_REGION: us-east-1
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.PRO_LICENSE_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_VERSION: "3.9.5"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: ${{fromJson(inputs.os || '["ubuntu-latest"]')}}
name: Build & Package - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || github.repository }}
token: ${{ secrets.BOT_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_OIDC_ROLE_ARN_S3_GHA }}
aws-region: us-east-1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
cache: "maven"
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
# look for dependencies in maven
- 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"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- name: Run extra command
if: inputs.extraCommand != ''
run: |
${{ inputs.extraCommand }}
- name: Run extra Linux command
if: inputs.extraLinuxCommand != '' && runner.os == 'Linux'
shell: bash
run: |
${{ inputs.extraLinuxCommand }}
- name: Run extra Windows Command
if: inputs.extraWindowsCommand != '' && runner.os == 'Windows'
shell: powershell
run: |
${{ inputs.extraWindowsCommand }}
- name: Set Artifact Versions
shell: bash
run: |
mvn versions:set -DnewVersion='${{ inputs.version }}' -DgenerateBackupPoms=false
- name: Set Artifact Versions
working-directory: ${{ inputs.artifactPath }}
shell: bash
run: |
mvn versions:set -DnewVersion='${{ inputs.version }}' -DgenerateBackupPoms=false
- name: Build and Package
shell: bash
run: |
if [ -n "${{ inputs.extraMavenArgs }}" ]; then
mvn -B dependency:go-offline clean package -DskipTests=true ${{ inputs.extraMavenArgs }}
else
mvn -B dependency:go-offline clean package -DskipTests=true
fi
- name: Get Artifact ID
working-directory: ${{ inputs.artifactPath }}
id: get-artifact-id
shell: bash
run: echo "::set-output name=artifact_id::$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)"
- name: Get Artifact Version
working-directory: ${{ inputs.artifactPath }}
id: get-artifact-version
shell: bash
run: echo "::set-output name=artifact_version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
- name: Save Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-artifact-id.outputs.artifact_id }}-${{ matrix.os }}-${{ inputs.version }}-artifacts
path: |
${{ inputs.artifactPath }}/target/*
- name: Save Event File
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: ${{ steps.get-artifact-id.outputs.artifact_id }}-${{ matrix.os }}-${{ inputs.version }}-events
path: ${{ github.event_path }}
outputs:
artifact_id: ${{ steps.get-artifact-id.outputs.artifact_id }}
artifact_version: ${{ inputs.version }}
combineJars:
needs: build
if: ${{ inputs.combineJars }}
name: Combine Jars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || github.repository }}
token: ${{ secrets.BOT_TOKEN }}
- name: Download Ubuntu Artifacts
uses: actions/download-artifact@v4
with:
name: ${{needs.build.outputs.artifact_id}}-ubuntu-latest-${{ inputs.version }}-artifacts
path: /tmp/ubuntu
- name: Download macOS Artifacts
uses: actions/download-artifact@v4
with:
name: ${{needs.build.outputs.artifact_id}}-macos-latest-${{ inputs.version }}-artifacts
path: /tmp/macos
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: ${{needs.build.outputs.artifact_id}}-windows-latest-${{ inputs.version }}-artifacts
path: /tmp/windows
- name: Create multiplatform jar
run: |
rm -rf /tmp/combined/ubuntu /tmp/combined/windows /tmp/combined/macos
mkdir -p /tmp/combined/ubuntu /tmp/combined/windows /tmp/combined/macos
unzip -d /tmp/combined/ubuntu /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar
unzip -d /tmp/combined/windows /tmp/windows/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar
unzip -d /tmp/combined/macos /tmp/macos/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar
rm -r -f /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}
mkdir /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}
cp -a /tmp/combined/ubuntu/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/
cp -a /tmp/combined/windows/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/
cp -a /tmp/combined/macos/* /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/
rm /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/org.graalvm.python.vfs/fileslist.txt
cat /tmp/combined/ubuntu/org.graalvm.python.vfs/fileslist.txt /tmp/combined/windows/org.graalvm.python.vfs/fileslist.txt /tmp/combined/macos/org.graalvm.python.vfs/fileslist.txt > /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/org.graalvm.python.vfs/fileslist.txt
rm -f /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar
cd /tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}/
zip -r ../${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar *
cd ..
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}-sources.jar /tmp/combined/
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}-javadoc.jar /tmp/combined/
cp /tmp/ubuntu/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.pom /tmp/combined/
- name: Upload multiplatform artifact
uses: actions/upload-artifact@v4
with:
name: multiplatform-artifacts
path: |
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}-sources.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}-javadoc.jar
/tmp/combined/${{needs.build.outputs.artifact_id}}-${{ inputs.version }}.pom