Skip to content

Commit 521aa26

Browse files
Copilotedburns
andauthored
Java: add linux-arm64 native runtime support (#2421)
* Initial plan * Add Java linux-arm64 native runtime support Co-authored-by: edburns <75821+edburns@users.noreply.github.com> * Scope Java glibc option to ARM64 CI Co-authored-by: edburns <75821+edburns@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 3d630a7 commit 521aa26

12 files changed

Lines changed: 525 additions & 22 deletions

.github/workflows/java-publish-maven.yml

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,65 @@ jobs:
184184
echo "tag_commit=$TAG_COMMIT" >> "$GITHUB_OUTPUT"
185185
echo "post_prepare_commit=$POST_PREPARE_COMMIT" >> "$GITHUB_OUTPUT"
186186
187+
build-linux-arm64-classifier:
188+
name: Build Linux ARM64 native classifier
189+
needs: prepare-release
190+
runs-on: ubuntu-24.04-arm
191+
permissions:
192+
contents: read
193+
defaults:
194+
run:
195+
shell: bash
196+
working-directory: ./java
197+
steps:
198+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
199+
with:
200+
ref: ${{ needs.prepare-release.outputs.release_tag }}
201+
fetch-depth: 1
202+
persist-credentials: false
203+
204+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
205+
with:
206+
java-version: "25"
207+
distribution: "microsoft"
208+
cache: "maven"
209+
210+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
211+
with:
212+
node-version: 22
213+
214+
- name: Build and validate linux-arm64 classifier
215+
run: |
216+
set -euo pipefail
217+
SOURCE_COMMIT=$(git rev-parse HEAD)
218+
if [ "$SOURCE_COMMIT" != "${{ needs.prepare-release.outputs.tag_commit }}" ]; then
219+
echo "::error::Checked out $SOURCE_COMMIT instead of the prepared tag commit."
220+
exit 1
221+
fi
222+
node copilot-native/scripts/validate-native-host.mjs linux-arm64
223+
mvn -B -pl copilot-native package -DskipTests -Dcopilot.native.libc=glibc
224+
VERSION="${{ needs.prepare-release.outputs.release_version }}"
225+
JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-arm64.jar"
226+
PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar"
227+
test -f "$JAR"
228+
node copilot-native/scripts/validate-native-artifact.mjs \
229+
classifier linux-arm64 "$JAR" "$(basename "$JAR")" ..
230+
node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR"
231+
MANIFEST="copilot-native/target/linux-arm64-$VERSION.sha256"
232+
HASH=$(sha256sum "$JAR" | cut -d ' ' -f 1)
233+
printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST"
234+
node copilot-native/scripts/validate-native-artifact.mjs \
235+
checksum "$JAR" "$MANIFEST" "$(basename "$JAR")"
236+
237+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
238+
with:
239+
name: java-native-linux-arm64-release-${{ github.run_id }}-${{ github.run_attempt }}
240+
path: |
241+
java/copilot-native/target/copilot-sdk-java-runtime-${{ needs.prepare-release.outputs.release_version }}-linux-arm64.jar
242+
java/copilot-native/target/linux-arm64-${{ needs.prepare-release.outputs.release_version }}.sha256
243+
if-no-files-found: error
244+
retention-days: 1
245+
187246
build-windows-classifier:
188247
name: Build Windows native classifier
189248
needs: prepare-release
@@ -302,7 +361,13 @@ jobs:
302361

303362
deploy-maven:
304363
name: Deploy Java release to Maven Central
305-
needs: [prepare-release, build-windows-classifier, build-darwin-classifier]
364+
needs:
365+
[
366+
prepare-release,
367+
build-linux-arm64-classifier,
368+
build-windows-classifier,
369+
build-darwin-classifier,
370+
]
306371
runs-on: ubuntu-latest
307372
permissions:
308373
contents: read
@@ -337,6 +402,11 @@ jobs:
337402
with:
338403
node-version: 22
339404

405+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
406+
with:
407+
name: java-native-linux-arm64-release-${{ github.run_id }}-${{ github.run_attempt }}
408+
path: ${{ runner.temp }}/java-native-linux-arm64
409+
340410
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
341411
with:
342412
name: java-native-win32-x64-release-${{ github.run_id }}-${{ github.run_attempt }}
@@ -347,6 +417,27 @@ jobs:
347417
name: java-native-darwin-arm64-release-${{ github.run_id }}-${{ github.run_attempt }}
348418
path: ${{ runner.temp }}/java-native-darwin-arm64
349419

420+
- name: Verify immutable source and Linux ARM64 classifier
421+
id: linux-arm64-artifact
422+
run: |
423+
SOURCE_COMMIT=$(git rev-parse HEAD)
424+
if [ "$SOURCE_COMMIT" != "${{ needs.prepare-release.outputs.tag_commit }}" ]; then
425+
echo "::error::Checked out $SOURCE_COMMIT instead of the prepared tag commit."
426+
exit 1
427+
fi
428+
VERSION="${{ needs.prepare-release.outputs.release_version }}"
429+
ARTIFACT_DIRECTORY="${{ runner.temp }}/java-native-linux-arm64"
430+
JAR="$ARTIFACT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-linux-arm64.jar"
431+
MANIFEST="$ARTIFACT_DIRECTORY/linux-arm64-$VERSION.sha256"
432+
test -f "$JAR"
433+
test -f "$MANIFEST"
434+
node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \
435+
checksum "$JAR" "$MANIFEST" "$(basename "$JAR")"
436+
node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \
437+
classifier linux-arm64 "$JAR" "$(basename "$JAR")" "$GITHUB_WORKSPACE"
438+
echo "linux_arm64_jar=$JAR" >> "$GITHUB_OUTPUT"
439+
echo "linux_arm64_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT"
440+
350441
- name: Verify immutable source and Windows classifier
351442
id: windows-artifact
352443
run: |
@@ -394,6 +485,7 @@ jobs:
394485
run: |
395486
VERSION="${{ needs.prepare-release.outputs.release_version }}"
396487
mvn -B deploy -DskipTests -Prelease -Dcopilot.native.libc=glibc \
488+
"-Dcopilot.native.external.linux.arm64.classifier.path=${{ steps.linux-arm64-artifact.outputs.linux_arm64_jar }}" \
397489
"-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" \
398490
"-Dcopilot.native.external.darwin.classifier.path=${{ steps.darwin-artifact.outputs.darwin_jar }}"
399491
LINUX_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-x64.jar"
@@ -431,6 +523,7 @@ jobs:
431523
echo "| Classifier | Build runner | Artifact | SHA-256 | Status |"
432524
echo "| --- | --- | --- | --- | --- |"
433525
echo "| \`linux-x64\` | \`ubuntu-latest\` | \`$(basename "$LINUX_JAR")\` | \`$LINUX_SHA\` | Published |"
526+
echo "| \`linux-arm64\` | \`ubuntu-24.04-arm\` | \`$(basename "${{ steps.linux-arm64-artifact.outputs.linux_arm64_jar }}")\` | \`${{ steps.linux-arm64-artifact.outputs.linux_arm64_sha }}\` | Published |"
434527
echo "| \`win32-x64\` | \`windows-latest\` | \`$(basename "${{ steps.windows-artifact.outputs.windows_jar }}")\` | \`${{ steps.windows-artifact.outputs.windows_sha }}\` | Published |"
435528
echo "| \`darwin-arm64\` | \`macos-26\` | \`$(basename "${{ steps.darwin-artifact.outputs.darwin_jar }}")\` | \`${{ steps.darwin-artifact.outputs.darwin_sha }}\` | Published |"
436529
} >> "$GITHUB_STEP_SUMMARY"
@@ -444,6 +537,7 @@ jobs:
444537
needs:
445538
[
446539
prepare-release,
540+
build-linux-arm64-classifier,
447541
build-windows-classifier,
448542
build-darwin-classifier,
449543
deploy-maven,

.github/workflows/java-publish-snapshot.yml

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,69 @@ jobs:
3434
SHA=$(git rev-parse HEAD)
3535
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
3636
37+
build-linux-arm64-classifier:
38+
name: Build Linux ARM64 snapshot classifier
39+
needs: resolve-source
40+
runs-on: ubuntu-24.04-arm
41+
permissions:
42+
contents: read
43+
outputs:
44+
version: ${{ steps.build.outputs.version }}
45+
defaults:
46+
run:
47+
shell: bash
48+
working-directory: ./java
49+
steps:
50+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51+
with:
52+
ref: ${{ github.sha }}
53+
fetch-depth: 1
54+
persist-credentials: false
55+
56+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
57+
with:
58+
java-version: "25"
59+
distribution: "microsoft"
60+
cache: "maven"
61+
62+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
63+
with:
64+
node-version: 22
65+
66+
- name: Build and validate linux-arm64 classifier
67+
id: build
68+
run: |
69+
set -euo pipefail
70+
SOURCE_COMMIT=$(git rev-parse HEAD)
71+
if [ "$SOURCE_COMMIT" != "${{ needs.resolve-source.outputs.source_sha }}" ]; then
72+
echo "::error::Checked out $SOURCE_COMMIT instead of the resolved snapshot source."
73+
exit 1
74+
fi
75+
node copilot-native/scripts/validate-native-host.mjs linux-arm64
76+
mvn -B -pl copilot-native package -DskipTests -Dcopilot.native.libc=glibc
77+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
78+
JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-arm64.jar"
79+
PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar"
80+
test -f "$JAR"
81+
node copilot-native/scripts/validate-native-artifact.mjs \
82+
classifier linux-arm64 "$JAR" "$(basename "$JAR")" ..
83+
node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR"
84+
MANIFEST="copilot-native/target/linux-arm64-$VERSION.sha256"
85+
HASH=$(sha256sum "$JAR" | cut -d ' ' -f 1)
86+
printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST"
87+
node copilot-native/scripts/validate-native-artifact.mjs \
88+
checksum "$JAR" "$MANIFEST" "$(basename "$JAR")"
89+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
90+
91+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
92+
with:
93+
name: java-native-linux-arm64-snapshot-${{ github.run_id }}-${{ github.run_attempt }}
94+
path: |
95+
java/copilot-native/target/copilot-sdk-java-runtime-${{ steps.build.outputs.version }}-linux-arm64.jar
96+
java/copilot-native/target/linux-arm64-${{ steps.build.outputs.version }}.sha256
97+
if-no-files-found: error
98+
retention-days: 1
99+
37100
build-windows-classifier:
38101
name: Build Windows snapshot classifier
39102
needs: resolve-source
@@ -160,7 +223,13 @@ jobs:
160223

161224
deploy-snapshot:
162225
name: Publish SNAPSHOT to Maven Central
163-
needs: [resolve-source, build-windows-classifier, build-darwin-classifier]
226+
needs:
227+
[
228+
resolve-source,
229+
build-linux-arm64-classifier,
230+
build-windows-classifier,
231+
build-darwin-classifier,
232+
]
164233
runs-on: ubuntu-latest
165234
defaults:
166235
run:
@@ -188,6 +257,11 @@ jobs:
188257
with:
189258
node-version: 22
190259

260+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
261+
with:
262+
name: java-native-linux-arm64-snapshot-${{ github.run_id }}-${{ github.run_attempt }}
263+
path: ${{ runner.temp }}/java-native-linux-arm64
264+
191265
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
192266
with:
193267
name: java-native-win32-x64-snapshot-${{ github.run_id }}-${{ github.run_attempt }}
@@ -198,8 +272,8 @@ jobs:
198272
name: java-native-darwin-arm64-snapshot-${{ github.run_id }}-${{ github.run_attempt }}
199273
path: ${{ runner.temp }}/java-native-darwin-arm64
200274

201-
- name: Verify version, source, and Windows classifier
202-
id: windows-artifact
275+
- name: Verify version, source, and Linux ARM64 classifier
276+
id: linux-arm64-artifact
203277
run: |
204278
SOURCE_COMMIT=$(git rev-parse HEAD)
205279
if [ "$SOURCE_COMMIT" != "${{ needs.resolve-source.outputs.source_sha }}" ]; then
@@ -211,6 +285,32 @@ jobs:
211285
echo "::error::This workflow only publishes SNAPSHOT versions. Current version: $VERSION"
212286
exit 1
213287
fi
288+
if [ "$VERSION" != "${{ needs.build-linux-arm64-classifier.outputs.version }}" ]; then
289+
echo "::error::Linux ARM64 classifier version does not match deploy version."
290+
exit 1
291+
fi
292+
ARTIFACT_DIRECTORY="${{ runner.temp }}/java-native-linux-arm64"
293+
JAR="$ARTIFACT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-linux-arm64.jar"
294+
MANIFEST="$ARTIFACT_DIRECTORY/linux-arm64-$VERSION.sha256"
295+
test -f "$JAR"
296+
test -f "$MANIFEST"
297+
node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \
298+
checksum "$JAR" "$MANIFEST" "$(basename "$JAR")"
299+
node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \
300+
classifier linux-arm64 "$JAR" "$(basename "$JAR")" "$GITHUB_WORKSPACE"
301+
echo "linux_arm64_jar=$JAR" >> "$GITHUB_OUTPUT"
302+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
303+
echo "linux_arm64_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT"
304+
305+
- name: Verify version, source, and Windows classifier
306+
id: windows-artifact
307+
run: |
308+
SOURCE_COMMIT=$(git rev-parse HEAD)
309+
if [ "$SOURCE_COMMIT" != "${{ needs.resolve-source.outputs.source_sha }}" ]; then
310+
echo "::error::Checked out $SOURCE_COMMIT instead of the resolved snapshot source."
311+
exit 1
312+
fi
313+
VERSION="${{ steps.linux-arm64-artifact.outputs.version }}"
214314
if [ "$VERSION" != "${{ needs.build-windows-classifier.outputs.version }}" ]; then
215315
echo "::error::Windows classifier version does not match deploy version."
216316
exit 1
@@ -257,6 +357,7 @@ jobs:
257357
run: |
258358
VERSION="${{ steps.windows-artifact.outputs.version }}"
259359
mvn -B deploy -DskipTests -Dcopilot.native.libc=glibc \
360+
"-Dcopilot.native.external.linux.arm64.classifier.path=${{ steps.linux-arm64-artifact.outputs.linux_arm64_jar }}" \
260361
"-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" \
261362
"-Dcopilot.native.external.darwin.classifier.path=${{ steps.darwin-artifact.outputs.darwin_jar }}"
262363
LINUX_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-x64.jar"
@@ -292,6 +393,7 @@ jobs:
292393
echo "| Classifier | Build runner | Artifact | SHA-256 | Status |"
293394
echo "| --- | --- | --- | --- | --- |"
294395
echo "| \`linux-x64\` | \`ubuntu-latest\` | \`$(basename "$LINUX_JAR")\` | \`$LINUX_SHA\` | Published |"
396+
echo "| \`linux-arm64\` | \`ubuntu-24.04-arm\` | \`$(basename "${{ steps.linux-arm64-artifact.outputs.linux_arm64_jar }}")\` | \`${{ steps.linux-arm64-artifact.outputs.linux_arm64_sha }}\` | Published |"
295397
echo "| \`win32-x64\` | \`windows-latest\` | \`$(basename "${{ steps.windows-artifact.outputs.windows_jar }}")\` | \`${{ steps.windows-artifact.outputs.windows_sha }}\` | Published |"
296398
echo "| \`darwin-arm64\` | \`macos-26\` | \`$(basename "${{ steps.darwin-artifact.outputs.darwin_jar }}")\` | \`${{ steps.darwin-artifact.outputs.darwin_sha }}\` | Published |"
297399
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)