From 0f8bb57f78f466b1daa18d522f2712bbc62e843d Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Mon, 23 Dec 2024 21:59:58 +1100 Subject: [PATCH] Close #360 - Release for multiple macOS versions including 13 (Intel), 14 (Apple Silicon) and 15 (Apple Silicon) --- .github/workflows/build-graal.yml | 45 ++++++++++++------- .github/workflows/release.yml | 10 ++++- .scripts/install-graal-macos.sh | 72 ++++++++++++++++++++++++------- .scripts/install-graal-ubuntu.sh | 4 +- .scripts/install.sh | 4 +- 5 files changed, 100 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-graal.yml b/.github/workflows/build-graal.yml index b55d5d6..034617c 100644 --- a/.github/workflows/build-graal.yml +++ b/.github/workflows/build-graal.yml @@ -19,18 +19,16 @@ env: jobs: graalvm_build: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os.value }} strategy: matrix: - os: [ubuntu-latest, macos-latest] - run-binary: [maven2sbt-cli, maven2sbt-cli.exe] - exclude: - - os: ubuntu-latest - run-binary: maven2sbt-cli.exe - - os: macos-latest - run-binary: maven2sbt-cli.exe - - os: windows-latest - run-binary: maven2sbt-cli + # https://github.com/actions/runner-images?tab=readme-ov-file#available-images + os: + - { name: "Ubuntu 22.04", value: "ubuntu-22.04", bin-suffix: "" } + - { name: "macOS 13", value: "macos-13", bin-suffix: "-macos-13" } + - { name: "macOS 14 Apple Silicon", value: "macos-14", bin-suffix: "-macos-14-arm64" } + - { name: "macOS 15 Apple Silicon", value: "macos-15", bin-suffix: "-macos-15-arm64" } + run-binary: [maven2sbt-cli] steps: - uses: actions/checkout@v2.3.4 @@ -53,6 +51,7 @@ jobs: CURRENT_BRANCH_NAME: ${{ github.ref }} RUN_ID: ${{ github.run_id }} RUN_NUMBER: ${{ github.run_number }} + APP_BIN_NAME: ${{ matrix.run-binary }}${{ matrix.os.bin-suffix }} run: | sbt \ -J-Xmx2048m \ @@ -61,21 +60,35 @@ jobs: test \ nativeImage + echo "rm -f modules/${{ env.PROJECT_NAME }}-*/target/scala-*/*.jar" rm -f modules/${{ env.PROJECT_NAME }}-*/target/scala-*/*.jar + echo "ls -lGh modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/" ls -lGh modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/ - sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} --version" - sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} --help" - sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} print --help" - sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} file --help" + # Change the bin file name when $matrix.run-binary is different from the $$APP_BIN_NAME + if [ "${{ matrix.run-binary }}" != "$APP_BIN_NAME" ]; then + echo "mv modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME" + mv modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME + else + echo "run-binary=${{ matrix.run-binary }} and APP_BIN_NAME=$APP_BIN_NAME are the same." + fi + + echo "ls -lGh modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/" + ls -lGh modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/ + + sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME --version" + sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME --help" + sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME print --help" + sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME file --help" graalvm_build_windows: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] - run-binary: [maven2sbt-cli] + # https://github.com/actions/runner-images?tab=readme-ov-file#available-images + os: [windows-2019] + run-binary: [maven2sbt-cli.exe] steps: - name: Configure git run: "git config --global core.autocrlf false" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a18a13c..be7ff10 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -145,7 +145,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + # https://github.com/actions/runner-images?tab=readme-ov-file#available-images + os: + - { name: "Ubuntu 22.04", value: "ubuntu-22.04", bin-suffix: "" } + - { name: "macOS 13", value: "macos-13", bin-suffix: "-macos-13" } + - { name: "macOS 14 Apple Silicon", value: "macos-14", bin-suffix: "-macos-14-arm64" } + - { name: "macOS 15 Apple Silicon", value: "macos-15", bin-suffix: "-macos-15-arm64" } run-binary: [maven2sbt-cli] steps: - uses: actions/checkout@v2.3.4 @@ -172,6 +177,7 @@ jobs: CURRENT_BRANCH_NAME: ${{ github.ref }} RUN_ID: ${{ github.run_id }} RUN_NUMBER: ${{ github.run_number }} + APP_BIN_NAME: ${{ matrix.run-binary }}${{ matrix.os.bin-suffix }} run: | sbt \ -J-XX:MaxMetaspaceSize=1024m \ @@ -186,7 +192,7 @@ jobs: ls -lGh modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/ sh -c "modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} --help" - mv modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }}-${{ matrix.os }} + mv modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/${{ matrix.run-binary }} modules/${{ env.PROJECT_NAME }}-cli/target/${{ env.GRAALVM_BIN_DIR_NAME }}/$APP_BIN_NAME sbt \ -J-XX:MaxMetaspaceSize=1024m \ diff --git a/.scripts/install-graal-macos.sh b/.scripts/install-graal-macos.sh index 6a4db39..a793d3e 100755 --- a/.scripts/install-graal-macos.sh +++ b/.scripts/install-graal-macos.sh @@ -2,31 +2,71 @@ set -eu +# Get the macOS version +macos_version=$(sw_vers -productVersion) + +# Extract the major version (e.g., 12, 13, 14) +major_version=$(echo "$macos_version" | cut -d '.' -f 1) + +echo ">>> macOS.major_version=$major_version" + +# Set the app_bin_suffix based on the macOS major version using case +case "$major_version" in + 12) + app_bin_suffix="macos12" + ;; + 13) + app_bin_suffix="macos-13" + ;; + 14 | 15) + # Get the system architecture + arch=$(uname -m) + + echo ">>> macOS.arch=${arch}" + + # Set the app_bin_suffix based on the architecture + if [ "$arch" == "x86_64" ]; then + app_bin_suffix="macos-13" + elif [ "$arch" == "arm64" ]; then + app_bin_suffix="macos-${major_version}-arm64" + else + app_bin_suffix="macos-13" + fi + ;; + *) + app_bin_suffix="macos-13" + echo "Unsupported macOS version: $macos_version so it will use $app_bin_suffix " + ;; +esac + app_executable_name=maven2sbt app_name=maven2sbt-cli app_version=${1:-1.5.0} app_package_file="${app_name}-macos-latest" -download_url="https://github.com/kevin-lee/maven2sbt/releases/download/v${app_version}/${app_package_file}" +download_url="https://github.com/kevin-lee/maven2sbt/releases/download/v${app_version}/${app_package_file}-${app_bin_suffix}" -usr_local_path="/usr/local" +usr_local_path=$HOME opt_location="${usr_local_path}/opt" app_location="${opt_location}/${app_name}" installed_app_bin_path="${app_location}/${app_executable_name}" usr_local_bin_path="${usr_local_path}/bin" app_bin_path="${usr_local_bin_path}/${app_executable_name}" -echo "app_executable_name=${app_executable_name}" -echo "app_name=${app_name}" -echo "app_version=${app_version}" -echo "app_package_file=${app_package_file}" -echo "download_url=${download_url}" - -echo "usr_local_path=${usr_local_path}" -echo "opt_location=${opt_location}" -echo "app_location=${app_location}" -echo "installed_app_bin_path=${installed_app_bin_path}" -echo "usr_local_bin_path=${usr_local_bin_path}" -echo "app_bin_path=${app_bin_path}" +echo "--------------------------------------------------------------------------------" +echo "app_executable_name = ${app_executable_name}" +echo " app_name = ${app_name}" +echo " app_bin_suffix = ${app_bin_suffix}" +echo " app_version = ${app_version}" +echo " app_package_file = ${app_package_file}" +echo " download_url = ${download_url}" +echo "--------------------------------------------------------------------------------" +echo " usr_local_path = ${usr_local_path}" +echo " opt_location = ${opt_location}" +echo " app_location = ${app_location}" +echo "installed_app_bin_path = ${installed_app_bin_path}" +echo " usr_local_bin_path = ${usr_local_bin_path}" +echo " app_bin_path = ${app_bin_path}" +echo "--------------------------------------------------------------------------------" cd /tmp @@ -35,11 +75,13 @@ curl -Lo $app_package_file $download_url ls -l $app_package_file || { echo "maven2sbt version ${app_version} doesn't seem to exist." && false ; } chmod ug+x $app_package_file +mkdir -p $opt_location +mkdir -p $usr_local_bin_path + rm -R $app_location || true mkdir -p $app_location mv $app_package_file $installed_app_bin_path -mkdir -p $usr_local_bin_path echo "" { rm $app_bin_path && { echo "The existing $app_bin_path was found so it was removed." ; } } || { echo "No existing $app_bin_path was found. It's OK. Please ignore the 'No such file or directory' message." ; } echo "" diff --git a/.scripts/install-graal-ubuntu.sh b/.scripts/install-graal-ubuntu.sh index 8be2b44..03bbd0d 100755 --- a/.scripts/install-graal-ubuntu.sh +++ b/.scripts/install-graal-ubuntu.sh @@ -35,11 +35,13 @@ curl -Lo $app_package_file $download_url ls -l $app_package_file || { echo "maven2sbt version ${app_version} doesn't seem to exist." && false ; } chmod ug+x $app_package_file +mkdir -p $opt_location +mkdir -p $usr_local_bin_path + rm -R $app_location || true mkdir -p $app_location mv $app_package_file $installed_app_bin_path -mkdir -p $usr_local_bin_path echo "" { rm $app_bin_path && { echo "The existing $app_bin_path was found so it was removed." ; } } || { echo "No existing $app_bin_path was found. It's OK. Please ignore the 'No such file or directory' message." ; } echo "" diff --git a/.scripts/install.sh b/.scripts/install.sh index 1a1636a..2029766 100755 --- a/.scripts/install.sh +++ b/.scripts/install.sh @@ -9,7 +9,7 @@ versioned_app_name="${app_name}-${app_version}" app_zip_file="${versioned_app_name}.zip" download_url="https://github.com/kevin-lee/maven2sbt/releases/download/v${app_version}/${app_zip_file}" -usr_local_path="/usr/local" +usr_local_path=$HOME opt_location="${usr_local_path}/opt" app_location="${opt_location}/${app_name}" installed_app_bin_path="${app_location}/bin/${app_executable_name}" @@ -37,6 +37,8 @@ curl -Lo $app_zip_file $download_url unzip $app_zip_file || { echo "maven2sbt version ${app_version} doesn't seem to exist." && rm $app_zip_file && false ; } mkdir -p $opt_location +mkdir -p $usr_local_bin_path + rm -R $app_location || true mv $versioned_app_name $app_location