forked from liquibase/liquibase
-
Notifications
You must be signed in to change notification settings - Fork 0
309 lines (287 loc) · 12.4 KB
/
build-extension-jars.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
name: Build & Deploy extensions
on:
workflow_call:
inputs:
liquibase-version:
description: "liquibase version"
required: true
type: string
dependencies:
description: "Comma separated list of needed dependencies to release the extensions list"
required: false
type: string
extensions:
description: "Comma separated list of extensions to release to GPM"
required: true
type: string
branch:
description: "branch to check out"
required: true
type: string
workflow_dispatch:
inputs:
liquibase-version:
description: "liquibase version"
required: true
type: string
dependencies:
description: "Comma separated list of needed dependencies to release the extensions list"
required: false
type: string
extensions:
description: "Comma separated list of extensions to release to GPM"
required: true
type: string
branch:
description: "branch to check out"
required: true
type: string
env:
MAVEN_VERSION: "3.9.2"
jobs:
setup_matrix:
runs-on: ubuntu-latest
outputs:
dependencies_matrix: ${{ steps.setup_dependencies_matrix.outputs.matrix_output }}
extensions_matrix: ${{ steps.setup_extensions_matrix.outputs.matrix_output }}
steps:
- id: setup_dependencies_matrix
uses: cschadewitz/dynamic-matrix-input@v1.0.0
with:
matrix_input: ${{ inputs.dependencies }}
- id: setup_extensions_matrix
uses: cschadewitz/dynamic-matrix-input@v1.0.0
with:
matrix_input: ${{ inputs.extensions }}
delete-dependency-packages:
needs: setup_matrix
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
matrix:
dependencies: ${{ fromJson(needs.setup_matrix.outputs.dependencies_matrix) }}
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: org.liquibase.ext.${{ matrix.dependencies }}
package-type: "maven"
token: ${{ secrets.BOT_TOKEN }}
ignore-versions: "^((?!${{ inputs.liquibase-version }}$).)*$"
delete-extension-packages:
needs: setup_matrix
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
matrix:
extensions: ${{ fromJson(needs.setup_matrix.outputs.extensions_matrix) }}
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: org.liquibase.ext.${{ matrix.extensions }}
package-type: "maven"
token: ${{ secrets.BOT_TOKEN }}
ignore-versions: "^((?!${{ inputs.liquibase-version }}$).)*$"
get-liquibase-checks-version:
if: ${{ contains(inputs.extensions, 'liquibase-checks') }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
repository: liquibase/liquibase-checks
token: ${{ secrets.BOT_TOKEN }}
- id: extract-version
name: Extract version from pom.xml
shell: bash
run: |
VERSION=$(grep '<version>' pom.xml | head -n 1 | sed 's/.*<version>\(.*\)-SNAPSHOT<\/version>.*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
delete-checks-packages:
needs: [ get-liquibase-checks-version ]
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: org.liquibase.ext.liquibase-checks
package-type: "maven"
token: ${{ secrets.BOT_TOKEN }}
ignore-versions: "^((?!${{ needs.get-liquibase-checks-version.outputs.version }}$).)*$"
build-liquibase-checks:
if: ${{ contains(inputs.extensions, 'liquibase-checks') }}
needs: [ delete-extension-packages, get-liquibase-checks-version, delete-checks-packages ]
uses: liquibase/build-logic/.github/workflows/publish-for-liquibase.yml@main
with:
repository: liquibase/liquibase-checks
version: ${{ needs.get-liquibase-checks-version.outputs.version }}
secrets: inherit
build-and-deploy-extensions:
needs: [delete-dependency-packages, delete-extension-packages, delete-checks-packages]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_USERNAME: "liquibot"
GIT_PASSWORD: ${{ secrets.LIQUIBOT_PAT_GPM_ACCESS }}
steps:
- uses: actions/checkout@v4
name: Checkout liquibase
- uses: actions/checkout@v4
name: Checkout liquibase-pro
with:
repository: liquibase/liquibase-pro
ref: "${{ inputs.branch }}"
path: liquibase-pro
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout Dependencies
run: |
git config --global credential.helper store
echo "https://$GIT_USERNAME:$GIT_PASSWORD@github.com" > ~/.git-credentials
IFS=',' read -ra DEP_ARRAY <<< "${{ inputs.dependencies }}"
for dep in "${DEP_ARRAY[@]}"; do
dep=$(echo $dep | xargs) # Remove leading and trailing whitespaces
echo "Checking out $dep"
git clone https://github.com/liquibase/$dep.git $dep
done
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: "temurin"
cache: "maven"
gpg-private-key: ${{ secrets.GPG_SECRET }}
gpg-passphrase: GPG_PASSPHRASE
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ env.MAVEN_VERSION }}
- 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",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT_GPM_ACCESS }}"
},
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT_GPM_ACCESS }}"
}
]
- name: Install liquibase 0-SNAPSHOT
run: mvn clean install -DskipTests
- name: Install liquibase-commercial 0-SNAPSHOT
run: |
cd liquibase-pro
mvn clean install -DskipTests -P '!run-proguard'
cd ..
- name: Re-version and build Dependencies
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
if: ${{ inputs.dependencies != '' }}
continue-on-error: true
run: |
scripts_branch=${{ inputs.branch }}
IFS=',' read -ra DEP_ARRAY <<< "${{ inputs.dependencies }}"
for dep in "${DEP_ARRAY[@]}"; do
dep=$(echo $dep | xargs) # Remove leading and trailing whitespaces
echo "Re-versioning $dep"
cd $dep
sed -i "s/<liquibase.version>.*<\/liquibase.version>/<liquibase.version>0-SNAPSHOT<\/liquibase.version>/" pom.xml
mvn versions:set -DnewVersion=0-SNAPSHOT
mvn clean install -DskipTests
mkdir -p $PWD/.github/util/
curl -o $PWD/.github/util/re-version.sh https://raw.githubusercontent.com/liquibase/liquibase/$scripts_branch/.github/util/re-version.sh
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/sign-artifacts.sh
chmod +x $PWD/.github/util/ManifestReversion.java
$PWD/.github/util/re-version.sh ./target "${{ inputs.liquibase-version }}" "${{ inputs.branch }}" ${dep}
$PWD/.github/util/sign-artifacts.sh ./target "${{ inputs.liquibase-version }}" "${{ inputs.branch }}"
mvn versions:set -DnewVersion=${{ inputs.liquibase-version }}
sed -i -e "s/<liquibase.version>0-SNAPSHOT<\/liquibase.version>/<liquibase.version>${{ inputs.liquibase-version }}<\/liquibase.version>/g" pom.xml
mvn deploy:deploy-file \
-Dfile=./re-version/out/${dep}-${{ inputs.liquibase-version }}.jar \
-Dsources=./re-version/out/${dep}-${{ inputs.liquibase-version }}-sources.jar \
-Djavadoc=./re-version/out/${dep}-${{ inputs.liquibase-version }}-javadoc.jar \
-DrepositoryId=liquibase \
-Durl=https://maven.pkg.github.com/liquibase/$dep \
-DpomFile=pom.xml
cd ..
done
- name: Checkout and build Extensions
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
continue-on-error: true
run: |
scripts_branch=${{ inputs.branch }}
git config --global credential.helper store
echo "https://$GIT_USERNAME:$GIT_PASSWORD@github.com" > ~/.git-credentials
IFS=',' read -ra EXT_ARRAY <<< "${{ inputs.extensions }}"
for ext in "${EXT_ARRAY[@]}"; do
ext=$(echo $ext | xargs) # Remove leading and trailing whitespaces
if [ "$ext" != "liquibase-checks" ]; then
echo "Checking out and building $ext"
git clone https://github.com/liquibase/$ext.git $ext
cd $ext
sed -i "s/<liquibase.version>.*<\/liquibase.version>/<liquibase.version>0-SNAPSHOT<\/liquibase.version>/" pom.xml
mvn versions:set -DnewVersion=0-SNAPSHOT
for dep in "${DEP_ARRAY[@]}"; do
dep=$(echo $dep | xargs)
sed -i "/<artifactId>${dep//./\\.}<\/artifactId>/{N; s/<version>.*<\/version>/<version>${{ inputs.liquibase-version }}<\/version>/}" pom.xml || true
done
mvn clean install -DskipTests
mkdir -p $PWD/.github/util/
curl -o $PWD/.github/util/re-version.sh https://raw.githubusercontent.com/liquibase/liquibase/$scripts_branch/.github/util/re-version.sh
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/sign-artifacts.sh
chmod +x $PWD/.github/util/ManifestReversion.java
$PWD/.github/util/re-version.sh ./target "${{ inputs.liquibase-version }}" "${{ inputs.branch }}" ${ext}
$PWD/.github/util/sign-artifacts.sh ./target "${{ inputs.liquibase-version }}" "${{ inputs.branch }}"
mvn versions:set -DnewVersion=${{ inputs.liquibase-version }}
sed -i -e "s/<liquibase.version>0-SNAPSHOT<\/liquibase.version>/<liquibase.version>${{ inputs.liquibase-version }}<\/liquibase.version>/g" pom.xml
mvn deploy:deploy-file \
-Dfile=./re-version/out/${ext}-${{ inputs.liquibase-version }}.jar \
-Dsources=./re-version/out/${ext}-${{ inputs.liquibase-version }}-sources.jar \
-Djavadoc=./re-version/out/${ext}-${{ inputs.liquibase-version }}-javadoc.jar \
-DrepositoryId=liquibase \
-Durl=https://maven.pkg.github.com/liquibase/$ext \
-DpomFile=pom.xml
cd ..
fi
done