From dc24484a96532336ec73182fb74a4d20257a1b7e Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Thu, 8 Aug 2024 20:21:21 +0200 Subject: [PATCH 1/5] refactor: Simplify printing error --- src/main/java/it/mulders/mcs/App.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/mulders/mcs/App.java b/src/main/java/it/mulders/mcs/App.java index 1715519..2333a6d 100644 --- a/src/main/java/it/mulders/mcs/App.java +++ b/src/main/java/it/mulders/mcs/App.java @@ -49,8 +49,9 @@ private static void setUpProxy() { System.setProperty("https.proxyPort", Integer.toString(uri.getPort())); } } catch (URISyntaxException e) { - System.err.println("Error while setting up proxy from environment: HTTP_PROXY=[%s], HTTPS_PROXY=[%s]" - .formatted(httpProxy, httpsProxy)); + System.err.printf( + "Error while setting up proxy from environment: HTTP_PROXY=[%s], HTTPS_PROXY=[%s]%n", + httpProxy, httpsProxy); } } From 5c82762b7fad7e197b690b399f907ebb2fad6f02 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Fri, 9 Aug 2024 17:09:16 +0200 Subject: [PATCH 2/5] feat: Add Linux/ARM64 binaries --- .github/workflows/early-access.yml | 12 +++++++----- .github/workflows/release.yml | 12 +++++++----- jreleaser.yml | 12 ++++++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index b622ca4..25ba882 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -17,11 +17,13 @@ jobs: strategy: fail-fast: true matrix: - os: [ ubuntu-latest, macOS-12, macos-14, windows-latest ] + os: [ ubuntu-latest, linux-arm64, macOS-12, macos-14, windows-latest ] gu-binary: [ gu, gu.cmd ] exclude: - os: ubuntu-latest gu-binary: gu.cmd + - os: linux-arm64 + gu-binary: gu.cmd - os: macOS-12 gu-binary: gu.cmd - os: macos-14 @@ -71,7 +73,7 @@ jobs: make install echo "TOOLCHAIN_DIR=$TOOLCHAIN_DIR" >> $GITHUB_OUTPUT - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' - name: Cache Maven packages id: restore-maven-package-cache @@ -86,12 +88,12 @@ jobs: PATH=${TOOLCHAIN_DIR}/bin:$PATH; mvn -B -Pnative package env: TOOLCHAIN_DIR: ${{ steps.prepare-musl.outputs.TOOLCHAIN_DIR }} - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' - name: Build static native image for Windows / macOS run: | mvn -B -Pnative package - if: matrix.os != 'ubuntu-latest' + if: matrix.os != 'ubuntu-latest' && matrix.os != 'linux-arm64' - name: Create distribution run: mvn -B -Pdist package -DskipTests @@ -134,7 +136,7 @@ jobs: - name: Move build artifacts to correct folder run: | - targets=("ubuntu-latest" "macOS-latest" "macos-14" "windows-latest") + targets=("ubuntu-latest" "linux-arm64" "macOS-latest" "macos-14" "windows-latest") mkdir -p artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca1111d..76be447 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,11 +70,13 @@ jobs: strategy: fail-fast: true matrix: - os: [ ubuntu-latest, macOS-12, macos-14, windows-latest ] + os: [ ubuntu-latest, linux-arm64, macOS-12, macos-14, windows-latest ] gu-binary: [ gu, gu.cmd ] exclude: - os: ubuntu-latest gu-binary: gu.cmd + - os: linux-arm64 + gu-binary: gu.cmd - os: macOS-12 gu-binary: gu.cmd - os: macos-14 @@ -130,7 +132,7 @@ jobs: make install echo "TOOLCHAIN_DIR=$TOOLCHAIN_DIR" >> $GITHUB_OUTPUT - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' - name: Cache Maven packages uses: actions/cache@v4.0.2 @@ -144,12 +146,12 @@ jobs: PATH=${TOOLCHAIN_DIR}/bin:$PATH; mvn -B -Pnative package env: TOOLCHAIN_DIR: ${{ steps.prepare-musl.outputs.TOOLCHAIN_DIR }} - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' - name: Build static native image for Windows / macOS run: | mvn -B -Pnative package - if: matrix.os != 'ubuntu-latest' + if: matrix.os != 'ubuntu-latest' && matrix.os != 'linux-arm64' - name: Create distribution run: mvn -B -Pdist package -DskipTests @@ -208,7 +210,7 @@ jobs: - name: Move build artifacts to correct folder run: | - targets=("ubuntu-latest" "macOS-latest" "macos-14" "windows-latest") + targets=("ubuntu-latest" "linux-arm64" "macOS-latest" "macos-14" "windows-latest") mkdir -p artifacts diff --git a/jreleaser.yml b/jreleaser.yml index 1bd272e..4cc04c1 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -73,8 +73,8 @@ distributions: localPlugs: - network architectures: - - buildOn: [amd64] - runOn: [amd64] + - buildOn: [amd64, arm64] + runOn: [amd64, arm64] repository: active: RELEASE name: mcs-snap @@ -91,10 +91,18 @@ distributions: platform: linux-x86_64 extraProperties: graalVMNativeImage: true + - path: ./{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-linux-arm64.zip + platform: linux-arm64 + extraProperties: + graalVMNativeImage: true - path: ./{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-linux-x86_64.tar.gz platform: linux-x86_64 extraProperties: graalVMNativeImage: true + - path: ./{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-linux-arm64.tar.gz + platform: linux-arm64 + extraProperties: + graalVMNativeImage: true - path: ./{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-windows-x86_64.zip platform: windows-x86_64 - path: ./{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-osx-x86_64.zip From c7e1bd1cdbc8b3519c5094ab36ea1e28396396d1 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Fri, 9 Aug 2024 17:29:02 +0200 Subject: [PATCH 3/5] feat: Download correct musl toolchain --- .github/workflows/early-access.yml | 21 ++++++++++++++++++--- .github/workflows/release.yml | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index 25ba882..e09211e 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -58,14 +58,27 @@ jobs: run: | TMP_DIR=$(mktemp -d) pushd $TMP_DIR - curl -LOJ http://more.musl.cc/10/x86_64-linux-musl/x86_64-linux-musl-native.tgz - tar -xvf x86_64-linux-musl-native.tgz + case $MATRIX_OS in + ubuntu-latest) + curl -LOJ https://musl.cc/x86_64-linux-musl-native.tgz + tar -xvf x86_64-linux-musl-native.tgz + TOOLCHAIN_DIR=$TMP_DIR/x86_64-linux-musl-native + ;; + linux-arm64) + curl -LOJ https://musl.cc/aarch64-linux-musl-native.tgz + tar -xvf aarch64-linux-musl-native.tgz + TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native + ;; + *) + echo 'Unexpected CPU architecture! + exit 1 + ;; + esac curl -LOJ https://zlib.net/fossils/zlib-1.3.tar.gz tar -xzf zlib-1.3.tar.gz cd zlib-1.3 - TOOLCHAIN_DIR=$TMP_DIR/x86_64-linux-musl-native CC=$TOOLCHAIN_DIR/bin/gcc ./configure --prefix=$TOOLCHAIN_DIR --static @@ -74,6 +87,8 @@ jobs: echo "TOOLCHAIN_DIR=$TOOLCHAIN_DIR" >> $GITHUB_OUTPUT if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' + env: + MATRIX_OS: ${{ matrix.os }} - name: Cache Maven packages id: restore-maven-package-cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 76be447..5eaf489 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,14 +117,27 @@ jobs: run: | TMP_DIR=$(mktemp -d) pushd $TMP_DIR - curl -LOJ http://more.musl.cc/10/x86_64-linux-musl/x86_64-linux-musl-native.tgz - tar -xvf x86_64-linux-musl-native.tgz + case $MATRIX_OS in + ubuntu-latest) + curl -LOJ https://musl.cc/x86_64-linux-musl-native.tgz + tar -xvf x86_64-linux-musl-native.tgz + TOOLCHAIN_DIR=$TMP_DIR/x86_64-linux-musl-native + ;; + linux-arm64) + curl -LOJ https://musl.cc/aarch64-linux-musl-native.tgz + tar -xvf aarch64-linux-musl-native.tgz + TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native + ;; + *) + echo 'Unexpected CPU architecture! + exit 1 + ;; + esac curl -LOJ https://zlib.net/fossils/zlib-1.3.tar.gz tar -xzf zlib-1.3.tar.gz cd zlib-1.3 - TOOLCHAIN_DIR=$TMP_DIR/x86_64-linux-musl-native CC=$TOOLCHAIN_DIR/bin/gcc ./configure --prefix=$TOOLCHAIN_DIR --static @@ -133,6 +146,8 @@ jobs: echo "TOOLCHAIN_DIR=$TOOLCHAIN_DIR" >> $GITHUB_OUTPUT if: matrix.os == 'ubuntu-latest' || matrix.os == 'linux-arm64' + env: + MATRIX_OS: ${{ matrix.os }} - name: Cache Maven packages uses: actions/cache@v4.0.2 From 57b4338595b06c51e9ec31264ed153be664b4ffe Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Fri, 9 Aug 2024 17:35:14 +0200 Subject: [PATCH 4/5] fix: Typo in script --- .github/workflows/early-access.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index e09211e..a30fdc7 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -70,7 +70,7 @@ jobs: TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native ;; *) - echo 'Unexpected CPU architecture! + echo 'Unexpected CPU architecture!' exit 1 ;; esac diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5eaf489..2fad47d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,7 +129,7 @@ jobs: TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native ;; *) - echo 'Unexpected CPU architecture! + echo 'Unexpected CPU architecture!' exit 1 ;; esac From d08c5678a6336ca62d8c92b5ffc2dc2a3a5c61ef Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Mon, 12 Aug 2024 13:59:24 +0200 Subject: [PATCH 5/5] fix: Symlink x86_64-linux-musl-gcc to aarch64-linux-musl-gcc GraalVM's native-image expects the former to be present. See https://www.graalvm.org/dev/reference-manual/native-image/guides/build-static-executables/ --- .github/workflows/early-access.yml | 3 +++ .github/workflows/release.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index a30fdc7..222aa92 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -68,6 +68,9 @@ jobs: curl -LOJ https://musl.cc/aarch64-linux-musl-native.tgz tar -xvf aarch64-linux-musl-native.tgz TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native + # Symlink x86_64-linux-musl-gcc to aarch64-linux-musl-gcc as native-image expects the former to be present + # See https://www.graalvm.org/dev/reference-manual/native-image/guides/build-static-executables/ + ln -s $TOOLCHAIN_DIR/bin/aarch64-linux-musl-gcc $TOOLCHAIN_DIR/bin/x86_64-linux-musl-gcc ;; *) echo 'Unexpected CPU architecture!' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fad47d..c95a5cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -127,6 +127,9 @@ jobs: curl -LOJ https://musl.cc/aarch64-linux-musl-native.tgz tar -xvf aarch64-linux-musl-native.tgz TOOLCHAIN_DIR=$TMP_DIR/aarch64-linux-musl-native + # Symlink x86_64-linux-musl-gcc to aarch64-linux-musl-gcc as native-image expects the former to be present + # See https://www.graalvm.org/dev/reference-manual/native-image/guides/build-static-executables/ + ln -s $TOOLCHAIN_DIR/bin/aarch64-linux-musl-gcc $TOOLCHAIN_DIR/bin/x86_64-linux-musl-gcc ;; *) echo 'Unexpected CPU architecture!'