diff --git a/buildspec.yaml b/buildspec.yaml index a283bf6..149f8e5 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -5,8 +5,7 @@ phases: install: commands: - - softwareupdate --install-rosetta - - curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL + - code/ci_actions/00_install_rosetta.sh pre_build: commands: diff --git a/code/ci_actions/00_install_rosetta.sh b/code/ci_actions/00_install_rosetta.sh new file mode 100755 index 0000000..0be3680 --- /dev/null +++ b/code/ci_actions/00_install_rosetta.sh @@ -0,0 +1,32 @@ +# Determine the architecture of the macOS device +processorBrand=$(/usr/sbin/sysctl -n machdep.cpu.brand_string) +if [[ "${processorBrand}" = *"Apple"* ]]; then + echo "Apple Processor is present." +else + echo "Apple Processor is not present. Rosetta not required." + exit 0 +fi + +# Check if Rosetta is installed +checkRosettaStatus=$(/bin/launchctl list | /usr/bin/grep "com.apple.oahd-root-helper") +RosettaFolder="/Library/Apple/usr/share/rosetta" +if [[ -e "${RosettaFolder}" && "${checkRosettaStatus}" != "" ]]; then + echo "Rosetta Folder exists and Rosetta Service is running. Exiting..." + exit 0 +else + echo "Rosetta Folder does not exist or Rosetta service is not running. Installing Rosetta..." +fi + +# Install Rosetta +/usr/sbin/softwareupdate --install-rosetta --agree-to-license + +# Check the result of Rosetta install command +if [[ $? -eq 0 ]]; then + echo "Rosetta installed successfully." + exit 0 +else + echo "Rosetta installation failed." + exit 1 + +fi +exit 0 \ No newline at end of file diff --git a/code/ci_actions/02_amplify.sh b/code/ci_actions/02_amplify.sh index d200f88..52dc167 100755 --- a/code/ci_actions/02_amplify.sh +++ b/code/ci_actions/02_amplify.sh @@ -12,8 +12,13 @@ if [ -f $AMPLIFY_STANDALONE ]; then elif [ -f $AMPLIFY_BREW ]; then AMPLIFY_CLI=$AMPLIFY_BREW else - echo "🛑 Amplify CLI not found" - exit 1 + echo "Amplify CLI not found, installing it" + curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL + if [ -f $AMPLIFY_STANDALONE ]; then + AMPLIFY_CLI=$AMPLIFY_STANDALONE + elif + echo "🛑 Amplify CLI not found, abording" + exit 1 fi echo "Using amplify at $AMPLIFY_CLI"