Skip to content

Commit

Permalink
Close #360 - Release for multiple macOS versions including 13 (Intel)…
Browse files Browse the repository at this point in the history
…, 14 (Apple Silicon) and 15 (Apple Silicon)
  • Loading branch information
kevin-lee committed Dec 24, 2024
1 parent a2c3b60 commit 0f8bb57
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 35 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/build-graal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -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 \
Expand All @@ -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"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
72 changes: 57 additions & 15 deletions .scripts/install-graal-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 ""
Expand Down
4 changes: 3 additions & 1 deletion .scripts/install-graal-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
4 changes: 3 additions & 1 deletion .scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0f8bb57

Please sign in to comment.