forked from liquibase/liquibase
-
Notifications
You must be signed in to change notification settings - Fork 0
283 lines (250 loc) · 12.3 KB
/
release-published.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
name: Release Published
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
env:
MAVEN_VERSION: '3.8.7'
jobs:
setup:
name: Setup
runs-on: ubuntu-20.04
outputs:
tag: ${{ steps.collect-data.outputs.tag }}
version: ${{ steps.collect-data.outputs.version }}
steps:
- name: Collect Data
id: collect-data
uses: actions/github-script@v6
with:
script: |
let tag;
if (context.payload.inputs) {
tag = context.payload.inputs.tag;
} else {
tag = context.payload.release.tag_name;
}
let version = tag.replace(/^v/, "");
core.setOutput("tag", tag);
core.setOutput("version", version);
- run: |
echo "Publishing version ${{ steps.collect-data.outputs.version }} from ${{ steps.collect-data.outputs.tag }}"
deploy_maven:
name: Deploy to Maven
needs: [ setup ]
runs-on: ubuntu-20.04
steps:
- name: Download release assets
uses: robinraju/[email protected]
with:
repository: "liquibase/liquibase"
tag: "${{ needs.setup.outputs.tag }}"
filename: "*"
out-file-path: "."
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SECRET }}
gpg-passphrase: GPG_PASSPHRASE
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
- name: Publish to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
run: |
version=${{ needs.setup.outputs.version }}
unzip -j liquibase-additional-*.zip
##extracts and sign poms
unzip -j liquibase-core-${version}.jar META-INF/maven/org.liquibase/liquibase-core/pom.xml
mv pom.xml liquibase-core-${version}.pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-core-${version}.pom
unzip -j liquibase-maven-plugin-${version}.jar META-INF/maven/org.liquibase/liquibase-maven-plugin/pom.xml
mv pom.xml liquibase-maven-plugin-${version}.pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-maven-plugin-${version}.pom
unzip -j liquibase-cdi-${version}.jar META-INF/maven/org.liquibase/liquibase-cdi/pom.xml
mv pom.xml liquibase-cdi-${version}.pom
sed -i -e "s/<description>/<name>Liquibase CDI Plugin<\/name><description>/" liquibase-cdi-${version}.pom ## name didn't end up in pom. Hack it in for now
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-cdi-${version}.pom
unzip -j liquibase-commercial-${version}.jar META-INF/maven/org.liquibase/liquibase-commercial/pom.xml
mv pom.xml liquibase-commercial-${version}.pom
sed -i -e "s/<\/licenses>/<\/licenses><scm><connection>private<\/connection><developerConnection>private<\/developerConnection><url>private<\/url><\/scm>/" liquibase-commercial-${version}.pom ## scm info not in the pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-commercial-${version}.pom
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-core-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-core-${version}.jar \
-Dsources=liquibase-core-${version}-sources.jar \
-Djavadoc=liquibase-core-${version}-javadoc.jar \
-Dfiles=liquibase-core-${version}.jar.asc,liquibase-core-${version}-sources.jar.asc,liquibase-core-${version}-javadoc.jar.asc,liquibase-core-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-commercial-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-commercial-${version}.jar \
-Dsources=liquibase-commercial-${version}-sources.jar \
-Djavadoc=liquibase-commercial-${version}-javadoc.jar \
-Dfiles=liquibase-commercial-${version}.jar.asc,liquibase-commercial-${version}-sources.jar.asc,liquibase-commercial-${version}-javadoc.jar.asc,liquibase-commercial-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-maven-plugin-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-maven-plugin-${version}.jar \
-Dsources=liquibase-maven-plugin-${version}-sources.jar \
-Djavadoc=liquibase-maven-plugin-${version}-javadoc.jar \
-Dfiles=liquibase-maven-plugin-${version}.jar.asc,liquibase-maven-plugin-${version}-sources.jar.asc,liquibase-maven-plugin-${version}-javadoc.jar.asc,liquibase-maven-plugin-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-cdi-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-cdi-${version}.jar \
-Dsources=liquibase-cdi-${version}-sources.jar \
-Djavadoc=liquibase-cdi-${version}-javadoc.jar \
-Dfiles=liquibase-cdi-${version}.jar.asc,liquibase-cdi-${version}-sources.jar.asc,liquibase-cdi-${version}-javadoc.jar.asc,liquibase-cdi-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
## Release repository
## Have to find the stagingRepositoryId that was auto-generated
rcList=$(mvn -B org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:rc-list -DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-nexus-staging)
#echo $rcList
stagingRepositoryId=$(echo $rcList | grep -o "\[INFO\] orgliquibase-[0-9]*[ ]*OPEN" | grep -o "orgliquibase-[0-9]*")
echo "Staging Repository Id: $stagingRepositoryId"
if [ "$(echo $stagingRepositoryId | grep -o "\-" | wc -l)" != "1" ]; then
echo "Did not find exactly one open repository"
exit 1
fi
mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:rc-close \
-DnexusUrl=https://oss.sonatype.org/ \
-DserverId=sonatype-nexus-staging \
-DstagingRepositoryId=$stagingRepositoryId \
-DstagingProgressTimeoutMinutes=10
mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:rc-release \
-DautoDropAfterRelease=true \
-DnexusUrl=https://oss.sonatype.org/ \
-DserverId=sonatype-nexus-staging \
-DstagingRepositoryId=$stagingRepositoryId \
-DstagingProgressTimeoutMinutes=10
deploy_javadocs:
name: Upload Javadocs
needs: [ setup ]
runs-on: ubuntu-20.04
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- name: Download release javadocs
uses: robinraju/[email protected]
with:
repository: "liquibase/liquibase"
tag: "${{ needs.setup.outputs.tag }}"
filename: "liquibase-additional*.zip"
out-file-path: "."
- name: Unpack javadoc files and upload to s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.JAVADOCS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.JAVADOCS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: |
unzip -j '*.zip' '*javadoc*.jar'
unzip '*liquibase-cdi*.jar' -d liquibase-cdi/
unzip '*liquibase-commercial*.jar' -d liquibase-commercial/
unzip '*liquibase-core*.jar' -d liquibase-core/
unzip '*liquibase-maven-plugin*.jar' -d liquibase-maven-plugin/
rm -rf *.jar *.zip
aws s3 sync . s3://javadocsliquibasecom-origin --only-show-errors
publish_to_github_packages:
name: Publish artifacts to Github Packages
runs-on: ubuntu-20.04
needs: [ setup ]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Java for publishing to GitHub Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: github
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: Version artifact
run: mvn versions:set -DnewVersion="${{ needs.setup.outputs.version }}"
# Publish to GitHub Packages
- name: Publish package to Github
run: mvn -B clean deploy -DskipTests=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_ARTIFACT_REPOSITORY: github
deploy_xsd:
name: Upload xsds
needs: [ setup ]
runs-on: ubuntu-20.04
outputs:
tag: ${{ steps.collect-data.outputs.tag }}
version: ${{ needs.setup.outputs.version }}
steps:
- name: Download liquibase xsd
uses: actions/checkout@v3
with:
# Relative path under $GITHUB_WORKSPACE to place the repository
path: liquibase-core-repo
repository: "liquibase/liquibase"
- name: Download liquibase-pro xsd
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_TOKEN }}
# Relative path under $GITHUB_WORKSPACE to place the repository
path: liquibase-pro-repo
repository: "liquibase/liquibase-pro"
- name: Upload to s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.LIQUIBASEORIGIN_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LIQUIBASEORIGIN_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
# aws s3 sync syncs directories and S3 prefixes.
run: |
aws s3 sync liquibase-pro-repo/pro/src/main/resources/www.liquibase.org/xml/ns/pro/ s3://liquibaseorg-origin/xml/ns/pro/ --content-type application/octet-stream --only-show-errors
aws s3 sync liquibase-core-repo/liquibase-core/src/main/resources/www.liquibase.org/xml/ns/dbchangelog/ s3://liquibaseorg-origin/xml/ns/dbchangelog/ --content-type application/octet-stream --only-show-errors
- name: Index.htm file upload
env:
AWS_ACCESS_KEY_ID: ${{ secrets.LIQUIBASEORIGIN_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LIQUIBASEORIGIN_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
# get the major.minor xsd version. grab the index.htm from s3, add the new verison of xsd and sync with the s3 again
run: |
version=${{ needs.setup.outputs.version }}
arr=(${version//./ })
xsd_version=${arr[0]}"."${arr[1]}
mkdir index-file
aws s3 cp s3://liquibaseorg-origin/xml/ns/dbchangelog/index.htm index-file
if ! grep -q ${xsd_version} index-file/index.htm ; then
sed -ie "s/<\/ul>/ <li><a href=\"\/xml\/ns\/dbchangelog\/dbchangelog-${xsd_version}.xsd\">dbchangelog-${xsd_version}.xsd<\/a><\/li>\n<\/ul>/" index-file/index.htm
aws s3 sync index-file s3://liquibaseorg-origin/xml/ns/dbchangelog/ --only-show-errors
fi