-
Notifications
You must be signed in to change notification settings - Fork 0
259 lines (223 loc) · 9.8 KB
/
release-assemble-archive.yml
File metadata and controls
259 lines (223 loc) · 9.8 KB
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release Assemble Archive
# Create Jlink And Java Archive
on:
# Trigger on button click
workflow_dispatch:
inputs:
tag:
description: 'Tag to checkout (vx.x.x or early-access)'
required: true
type: string
default: 'early-access'
# Trigger from another workflow
workflow_call:
inputs:
tag:
description: 'Tag to checkout (vx.x.x or early-access)'
required: true
type: string
# Constant for entire workflow
env:
COMMAND: doc-exec
JRELEASER_JPACKAGE_ASSEMBLY_NAME: 'doc-exec-installer' # The jpackage assembly name
JRELEASER_JLINK_ASSEMBLY_NAME: 'doc-exec-jre' # The jlink assembly name
JRELEASER_JAVA_ARCHIVE_ASSEMBLY_NAME: 'doc-exec-nojre'
WORKFLOW_ID: release-assemble-archive # the workflow name without extension
BUILD_DIRECTORY: target
SNAPSHOT_TAG: early-access
jobs:
# Assemble artifacts except installers
# Release all generated artifacts
# The name is used as path in GitHub
# so we get: release-assemble / assemble-archive / assemble
assemble:
runs-on: ubuntu-latest
steps:
# Checkout first as we do a control on the pom.xml version
- name: Git Checkout ${{ inputs.tag }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
fetch-depth: 0
# Homebrew is installed but not in the path
# https://github.com/actions/runner-images/issues/6283
- name: Homebrew Setup
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Homebrew Utility Installation
run: brew install yq
# Extract Props from pom.xml
- name: Props And Version Check ${{ inputs.tag }}
id: props
shell: bash
run: |
set -TCEeuo pipefail
# Tag
TAG=${{ inputs.tag }}
echo "tag=${TAG}" >> $GITHUB_OUTPUT
# Generate the effective pom
POM_EFFECTIVE="${{runner.temp}}/pom-effective.xml"
./mvnw help:effective-pom "-Doutput=$POM_EFFECTIVE" --no-transfer-progress --batch-mode
# Project version and tag
PROJECT_VERSION=$(yq --exit-status '.project.version' "$POM_EFFECTIVE")
PROJECT_TAG="v$PROJECT_VERSION"
if [[ "$PROJECT_VERSION" =~ .*-SNAPSHOT ]]; then
PROJECT_VERSION=${{env.SNAPSHOT_TAG}}
PROJECT_TAG=${{env.SNAPSHOT_TAG}}
fi
echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
# Check
if [ "$PROJECT_TAG" != "$TAG" ]; then
echo "Derived Tag from pom.xml ($PROJECT_TAG) is not the same as the workflow tag $TAG"
exit 1
fi
ARTIFACT_ID=$(yq --exit-status '.project.artifactId' "$POM_EFFECTIVE")
echo "artifact_id=$ARTIFACT_ID" >> $GITHUB_OUTPUT
JDK_VERSION=$(yq --exit-status '.project.properties."jdk.version"' "$POM_EFFECTIVE")
echo "jdk_version=$JDK_VERSION" >> $GITHUB_OUTPUT
JDK_DISTRO=$(yq --exit-status '.project.properties."jdk.distribution"' "$POM_EFFECTIVE")
echo "jdk_distro=$JDK_DISTRO" >> $GITHUB_OUTPUT
# JDK Name - The jdk and runner id
# The name uses to download the jdk. It's unique by runner and unique by jdk
# It should be lowercase, we use the bash syntax to do that
# Why Node and not bash subsitution, macOS has an old bash: 3.2.57(1)-release
JDK_NAME=$(echo 'console.log("${{ runner.os }}-${{ runner.arch }}".toLowerCase())' | node -);
echo "jdk_name=${JDK_NAME}" >> $GITHUB_OUTPUT
# Cache to not download the maven dependency between matrix run
# https://github.com/actions/cache/blob/main/examples.md#java---maven
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Java
uses: actions/setup-java@v5
with:
java-version: ${{ steps.props.outputs.jdk_version }}
distribution: ${{ steps.props.outputs.jdk_distro }}
cache: maven
# Prepare Maven Central
# We do it here and not in the last release phase to catch error early
- name: Maven Central Artifacts Creation
shell: bash
run: ./mvnw -Ppublication -DskipTests --no-transfer-progress --batch-mode --settings .github\cd-maven-settings.xml
# Upload Maven Central
- name: Maven Central Artifacts Upload
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: java-maven-central-${{ steps.props.outputs.project_version }}
path: |
${{env.BUILD_DIRECTORY}}/staging-deploy/
# Run the jdks profile default goal with maven wrapper
- name: Maven Setup JDKs
# The shell is bash on Linux and Powershell in Windows
run: ./mvnw -Pjdks --no-transfer-progress --batch-mode --settings .github\cd-maven-settings.xml
# Run the deps profile default goal with maven wrapper
# Jlink packaging needs them
- name: Maven Copy dependencies
run: ./mvnw -Pdeps --no-transfer-progress --batch-mode --quiet --settings .github\cd-maven-settings.xml
# Build jar
- name: Maven Build
run: ./mvnw package -DskipTests --no-transfer-progress --batch-mode --settings .github\cd-maven-settings.xml
# Create Java Archive
- name: Java Archive Assemble
shell: bash
run: |
./mvnw jreleaser:assemble \
-Djreleaser.assemblers=javaArchive \
--no-transfer-progress \
--batch-mode
# Test Java Archive
# We test only the zip
- name: Java Archive Test
shell: bash
run: |
set -TCEeuo pipefail
ARCHIVE_NAME="${{ steps.props.outputs.artifact_id }}-${{ steps.props.outputs.project_version }}-nojre"
JAVA_ARCHIVE=${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JAVA_ARCHIVE_ASSEMBLY_NAME}}/java-archive/$ARCHIVE_NAME.zip
UNZIP_TARGET="${{runner.temp}}"
unzip "$JAVA_ARCHIVE" -d "$UNZIP_TARGET"
if ! OUTPUT=$($UNZIP_TARGET/${ARCHIVE_NAME}/bin/${{ env.COMMAND }} --version); then
echo "Error while running ${{ env.COMMAND }}"
exit 1
fi
if [[ ! $OUTPUT =~ "${{ steps.props.outputs.project_version }}" ]]; then
echo "Version output does not contains the version"
echo "Version output: \n$OUTPUT"
exit 1
fi
# Upload Java Archive
- name: Java Archive Upload
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: java-archive-${{ steps.props.outputs.project_version }}
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JAVA_ARCHIVE_ASSEMBLY_NAME}}/java-archive/*.zip
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JAVA_ARCHIVE_ASSEMBLY_NAME}}/java-archive/*.tar.gz
# Jlink assembly
- name: Jlink Archive Assemble
shell: bash
run: |
./mvnw jreleaser:assemble \
-Djreleaser.assemblers=jlink
# Test Java Archive
# We test only the zip
- name: Jlink Test
shell: bash
run: |
set -TCEeuo pipefail
ARCHIVE_NAME="${{ steps.props.outputs.artifact_id }}-${{ steps.props.outputs.project_version }}-jre-linux-x64"
JAVA_ARCHIVE=${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JLINK_ASSEMBLY_NAME}}/jlink/$ARCHIVE_NAME.zip
UNZIP_TARGET="${{runner.temp}}"
unzip "$JAVA_ARCHIVE" -d "$UNZIP_TARGET"
if ! OUTPUT=$($UNZIP_TARGET/${ARCHIVE_NAME}/bin/${{ env.COMMAND }} --version); then
echo "Error while running ${{ env.COMMAND }}"
exit 1
fi
if [[ ! $OUTPUT =~ "${{ steps.props.outputs.project_version }}" ]]; then
echo "Version output does not contains the version"
echo "Version output: \n$OUTPUT"
exit 1
fi
# Upload JLink
- name: Upload JLink Windows
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: jlink-${{ steps.props.outputs.project_version }}-windows
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JLINK_ASSEMBLY_NAME}}/jlink/*windows*.zip
- name: Upload JLink Linux
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: jlink-${{ steps.props.outputs.project_version }}-linux
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JLINK_ASSEMBLY_NAME}}/jlink/*linux*.zip
- name: Upload JLink Alpine
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: jlink-${{ steps.props.outputs.project_version }}-alpine
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JLINK_ASSEMBLY_NAME}}/jlink/*alpine*.zip
- name: Upload JLink Macos
uses: actions/upload-artifact@v4
with:
retention-days: 1 # 90 by default
name: jlink-${{ steps.props.outputs.project_version }}-macos
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/assemble/${{env.JRELEASER_JLINK_ASSEMBLY_NAME}}/jlink/*macos*.zip
- name: JReleaser Logs
if: always()
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: jreleaser-logs-${{env.WORKFLOW_ID}}
path: |
${{env.BUILD_DIRECTORY}}/jreleaser/trace.log
${{env.BUILD_DIRECTORY}}/jreleaser/output.properties