-
Notifications
You must be signed in to change notification settings - Fork 467
417 lines (370 loc) · 14.9 KB
/
legacy-release_maven-release-process.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
name: Maven Release Process
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release Version (yy.mm.dd[_lts_v##]])'
required: true
release_commit:
description: 'Commit Hash (default to latest commit)'
required: false
deploy_artifact:
description: 'Deploy Artifact'
type: boolean
default: true
required: false
update_plugins:
description: 'Update Plugins'
type: boolean
default: true
required: false
upload_javadocs:
description: 'Upload Javadocs'
type: boolean
default: true
required: false
update_github_labels:
description: 'Update GitHub labels'
type: boolean
default: false
required: false
notify_slack:
description: 'Notify Slack'
type: boolean
default: true
required: false
env:
JAVA_VERSION: 11
JAVA_DISTRO: temurin
JVM_TEST_MAVEN_OPTS: '-e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
DOCKER_BUILD_CONTEXT: /home/runner/work/_temp/core-build
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-20.04
outputs:
release_version: ${{ steps.set-common-vars.outputs.release_version }}
release_tag: ${{ steps.set-common-vars.outputs.release_tag }}
date: ${{ steps.set-common-vars.outputs.date }}
steps:
- name: Validate Inputs
run: |
if [[ ! ${{ github.event.inputs.release_version }} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}(_lts_v[0-9]{2})?$ ]]; then
echo 'Release version must be in the format yy.mm.dd or yy.mm.dd_lts_v##'
exit 1
fi
- run: echo 'GitHub context'
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Checkout core
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CI_MACHINE_TOKEN }}
- uses: ./.github/actions/core-cicd/cleanup-runner
- name: Set Common Vars
id: set-common-vars
run: |
git config user.name "${{ secrets.CI_MACHINE_USER }}"
git config user.email "[email protected]"
release_version=${{ github.event.inputs.release_version }}
release_branch=release-${release_version}
release_tag=v${release_version}
release_commit=${{ github.event.inputs.release_commit }}
if [[ -z "${release_commit}" ]]; then
release_commit=$(git log -1 --pretty=%H)
fi
release_hash=${release_commit::7}
is_lts=false
[[ ${release_version} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{2}_lts_v[0-9]{2}$ ]] && is_lts=true
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
echo "release_branch=${release_branch}" >> $GITHUB_OUTPUT
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT
echo "release_commit=${release_commit}" >> $GITHUB_OUTPUT
echo "release_hash=${release_hash}" >> $GITHUB_OUTPUT
echo "is_lts=${is_lts}" >> $GITHUB_OUTPUT
echo "date=$(/bin/date -u "+%Y-%m")" >> $GITHUB_OUTPUT
- name: Set Release Version
id: set-release-version
run: |
release_tag=${{ steps.set-common-vars.outputs.release_tag }}
if git rev-parse "${release_tag}" >/dev/null 2>&1; then
echo "Tag ${release_tag} exists, removing it"
git push origin :refs/tags/${release_tag}
fi
git reset --hard ${{ steps.set-common-vars.outputs.release_commit }}
release_version=${{ steps.set-common-vars.outputs.release_version }}
release_branch=${{ steps.set-common-vars.outputs.release_branch }}
remote=$(git ls-remote --heads https://github.com/dotCMS/core.git ${release_branch} | wc -l | tr -d '[:space:]')
if [[ "${remote}" == '1' ]]; then
echo "Release branch ${release_branch} already exists, removing it"
git push origin :${release_branch}
fi
git checkout -b ${release_branch}
# set version in .mvn/maven.config
echo "-Dprod=true" > .mvn/maven.config
echo "-Drevision=${release_version}" >> .mvn/maven.config
echo "-Dchangelist=" >> .mvn/maven.config
git add .mvn/maven.config
git status
git commit -a -m "🏁 Publishing release version [${release_version}]"
git push origin ${release_branch}
release_commit=$(git log -1 --pretty=%H)
echo "release_commit=${release_commit}" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
- name: Build Core
run: |
mkdir -p ${DOCKER_BUILD_CONTEXT}
./mvnw -ntp \
${JVM_TEST_MAVEN_OPTS} \
-Dprod=true \
-Ddocker.buildArchiveOnly=${DOCKER_BUILD_CONTEXT} \
-DskipTests=true \
-DskipITs=true \
clean install \
--file pom.xml \
--show-version
rc=$?
if [[ $rc != 0 ]]; then
echo "Build failed with exit code $rc"
exit $rc
fi
- name: Setup Context
id: setup-docker-context
run: |
mkdir -p ${DOCKER_BUILD_CONTEXT}/context
tar -xvf ${DOCKER_BUILD_CONTEXT}/docker-build.tar -C ${DOCKER_BUILD_CONTEXT}/context
if: success()
- name: Cache Maven Repository
id: cache-maven
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: maven-core-${{ steps.set-common-vars.outputs.date }}-${{ github.run_id }}
restore-keys: |
maven-core-${{ steps.set-common-vars.outputs.date }}
if: success()
- name: Cache Core Output
id: cache-core-output
uses: actions/cache@v4
with:
path: |
./dotCMS/target/classes
./dotCMS/target/generated-sources
./dotCMS/target/dotcms-core-${{ steps.set-common-vars.outputs.release_version }}.zip
key: maven-core-output-${{ steps.set-common-vars.outputs.date }}-${{ github.run_id }}
restore-keys: |
maven-core-output-${{ steps.set-common-vars.outputs.date }}
if: success()
- name: Cache Node Binary
id: cache-node-binary
uses: actions/cache@v4
with:
path: |
core-web/installs
key: node-binary-${{ hashFiles('core-web/.nvmrc') }}
if: success()
- name: Cache NPM
id: cache-npm
uses: actions/cache@v4
with:
path: |
~/.npm
key: npm-${{ hashFiles('core-web/package-lock.json') }}
restore-keys: npm-
if: success()
- name: Cache Docker Context
id: cache-docker-context
uses: actions/cache@v4
with:
path: ${{ env.DOCKER_BUILD_CONTEXT }}/context
key: docker-context-${{ steps.set-common-vars.outputs.date }}-${{ github.run_id }}
restore-keys: |
docker-context-${{ steps.set-common-vars.outputs.date }}
if: success()
- name: Create Release
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer ${{ secrets.CI_MACHINE_TOKEN }}" \
https://api.github.com/repos/dotCMS/core/releases \
-d '{"tag_name": "${{ steps.set-common-vars.outputs.release_tag }}", "name": "Release ${{ steps.set-common-vars.outputs.release_version }}", "target_commitish": "${{ steps.set-release-version.outputs.release_commit }}", "draft": false, "prerelease": false, "generate_release_notes": false}'
if: success()
release-process:
name: Release Process
runs-on: ubuntu-latest
needs: prepare-release
env:
AWS_REGION: us-east-1
if: success()
steps:
- name: Checkout core
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-release.outputs.release_tag }}
- uses: ./.github/actions/core-cicd/cleanup-runner
- name: Restore Maven Repository
id: restore-maven
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: maven-core-${{ needs.prepare-release.outputs.date }}-${{ github.run_id }}
- name: Restore Core Output
id: restore-core-output
uses: actions/cache/restore@v4
with:
path: |
./dotCMS/target/classes
./dotCMS/target/generated-sources
./dotCMS/target/dotcms-core-${{ needs.prepare-release.outputs.release_version }}.zip
key: maven-core-output-${{ needs.prepare-release.outputs.date }}-${{ github.run_id }}
- name: Restore Node Binary
id: restore-node-binary
uses: actions/cache/restore@v4
with:
path: core-web/installs
key: node-binary-${{ hashFiles('core-web/.nvmrc') }}
- name: Restore NPM
id: restore-npm
uses: actions/cache/restore@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('core-web/package-lock.json') }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v20
with:
servers: '[{ "id": "dotcms-libs-local", "username": "${{ secrets.EE_REPO_USERNAME }}", "password": "${{ secrets.EE_REPO_PASSWORD }}" }]'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Deploy Release
run: |
./mvnw -ntp \
${JVM_TEST_MAVEN_OPTS} \
-Dprod=true \
-DskipTests=true \
-DskipITs=true \
deploy
if: github.event.inputs.deploy_artifact == 'true'
- name: Generate/Push Javadoc
run: |
./mvnw -ntp \
${JVM_TEST_MAVEN_OPTS} \
javadoc:javadoc \
-pl :dotcms-core
rc=$?
if [[ $rc != 0 ]]; then
echo "Javadoc generation failed with exit code $rc"
exit $rc
fi
site_dir=./dotCMS/target/site
javadoc_dir=${site_dir}/javadocs
s3_uri=s3://static.dotcms.com/docs/${{ needs.prepare-release.outputs.release_version }}/javadocs
mv ${site_dir}/apidocs ${javadoc_dir}
echo "Running: aws s3 cp ${javadoc_dir} ${s3_uri} --recursive"
aws s3 cp ${javadoc_dir} ${s3_uri} --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
if: github.event.inputs.upload_javadocs == 'true'
- name: Update Plugins
run: |
release_version=${{ needs.prepare-release.outputs.release_version }}
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.CI_MACHINE_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/dotCMS/plugin-seeds/dispatches \
-d "{\"event_type\": \"on-plugins-release\", \"client_payload\": {\"release_version\": \"$release_version\"}}"
if: github.event.inputs.update_plugins == 'true'
build-push-image:
name: Build/Push Image
needs: prepare-release
uses: ./.github/workflows/legacy-release_comp_maven-build-docker-image.yml
with:
ref: ${{ needs.prepare-release.outputs.release_tag }}
docker_platforms: linux/amd64,linux/arm64
docker_context_cache_key: docker-context-${{ needs.prepare-release.outputs.date }}-${{ github.run_id }}
secrets:
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
docker_io_token: ${{ secrets.DOCKER_TOKEN }}
generate-sbom:
name: Generate SBOM
runs-on: ubuntu-latest
needs: [ prepare-release, build-push-image ]
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/legacy-release/sbom-generator
id: sbom-generator
with:
dotcms_version: ${{ needs.prepare-release.outputs.release_version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Download all build artifacts'
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
pattern: ${{ steps.sbom-generator.outputs.sbom-artifact }}
- name: Upload SBOM Asset
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
echo "::group::Upload SBOM Asset"
ARTIFACT_NAME=${{ steps.sbom-generator.outputs.sbom-artifact }}
SBOM="./artifacts/${ARTIFACT_NAME}/${ARTIFACT_NAME}.json"
if [ -f "${SBOM}" ]; then
echo "SBOM: ${SBOM}"
cat "${SBOM}"
zip "${ARTIFACT_NAME}.zip" "${SBOM}"
gh release upload "${{ needs.prepare-release.outputs.release_tag }}" "${ARTIFACT_NAME}.zip"
else
echo "SBOM artifact not found."
fi
echo "::endgroup::"
finish-release:
name: Finish Release
runs-on: ubuntu-latest
needs: [prepare-release, release-process, build-push-image]
if: success()
env:
NEXT_VERSION: '1.0.0-SNAPSHOT'
FETCH_VALUE: 'Next Release'
steps:
- name: Checkout core
uses: actions/checkout@v4
with:
ref: main
- uses: ./.github/actions/core-cicd/cleanup-runner
- name: Release Labeling
if: success() && github.event.inputs.update_github_labels == 'true'
uses: ./.github/workflows/issue_comp_release-labeling.yml
with:
new_label: 'Release ${{ github.event.inputs.release_version }}''
secrets:
CI_MACHINE_TOKEN: ${{ secrets.CI_MACHINE_TOKEN }}
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.RELEASE_SLACK_WEBHOOK }}
SLACK_USERNAME: dotBot
SLACK_TITLE: "Important news!"
SLACK_MSG_AUTHOR: " "
MSG_MINIMAL: true
SLACK_FOOTER: ""
SLACK_ICON: https://avatars.slack-edge.com/temp/2021-12-08/2830145934625_e4e464d502865ff576e4.png
SLACK_MESSAGE: "<!channel> This automated script is excited to announce the release of a new version of dotCMS `${{ needs.prepare-release.outputs.release_version }}` :rocket:\n:docker: Produced images: [${{ needs.build-push-image.outputs.formatted_tags }}]"
if: success() && github.event.inputs.notify_slack == 'true'