From 9095941fd143a6b81478371d5ab3daa29d2ab119 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Thu, 11 May 2023 17:36:53 +0200 Subject: Update release workflow & Add jobs for macOS (#4837) * Add build config and extra args to create_macos_build.sh * Use matrix strategy for releases * Add macOS jobs Co-authored-by: Mary * Fix wrong version argument * Fix check for the correct amount of args * Install latest rcodesign release Co-authored-by: Mary * Set executable bits for PR builds on linux --------- Co-authored-by: Mary --- distribution/macos/create_macos_build.sh | 113 +++++++++++++++++++++++++++++ distribution/macos/create_macos_release.sh | 105 --------------------------- 2 files changed, 113 insertions(+), 105 deletions(-) create mode 100755 distribution/macos/create_macos_build.sh delete mode 100755 distribution/macos/create_macos_release.sh (limited to 'distribution') diff --git a/distribution/macos/create_macos_build.sh b/distribution/macos/create_macos_build.sh new file mode 100755 index 00000000..1a5a3873 --- /dev/null +++ b/distribution/macos/create_macos_build.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +set -e + +if [ "$#" -lt 7 ]; then + echo "usage " + exit 1 +fi + +mkdir -p "$1" +mkdir -p "$2" +mkdir -p "$3" + +BASE_DIR=$(readlink -f "$1") +TEMP_DIRECTORY=$(readlink -f "$2") +OUTPUT_DIRECTORY=$(readlink -f "$3") +ENTITLEMENTS_FILE_PATH=$(readlink -f "$4") +VERSION=$5 +SOURCE_REVISION_ID=$6 +CONFIGURATION=$7 +EXTRA_ARGS=$8 + +if [ "$VERSION" == "1.1.0" ]; +then + RELEASE_TAR_FILE_NAME=Ryujinx-$CONFIGURATION-$VERSION+$SOURCE_REVISION_ID-macos_universal.app.tar +else + RELEASE_TAR_FILE_NAME=Ryujinx-$VERSION-macos_universal.app.tar +fi + +ARM64_APP_BUNDLE="$TEMP_DIRECTORY/output_arm64/Ryujinx.app" +X64_APP_BUNDLE="$TEMP_DIRECTORY/output_x64/Ryujinx.app" +UNIVERSAL_APP_BUNDLE="$OUTPUT_DIRECTORY/Ryujinx.app" +EXECUTABLE_SUB_PATH=Contents/MacOS/Ryujinx + +rm -rf "$TEMP_DIRECTORY" +mkdir -p "$TEMP_DIRECTORY" + +DOTNET_COMMON_ARGS="-p:DebugType=embedded -p:Version=$VERSION -p:SourceRevisionId=$SOURCE_REVISION_ID --self-contained true $EXTRA_ARGS" + +dotnet restore +dotnet build -c $CONFIGURATION src/Ryujinx.Ava +dotnet publish -c $CONFIGURATION -r osx-arm64 -o "$TEMP_DIRECTORY/publish_arm64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava +dotnet publish -c $CONFIGURATION -r osx-x64 -o "$TEMP_DIRECTORY/publish_x64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava + +# Get rid of the support library for ARMeilleure for x64 (that's only for arm64) +rm -rf "$TEMP_DIRECTORY/publish_x64/libarmeilleure-jitsupport.dylib" + +# Get rid of libsoundio from arm64 builds as we don't have a arm64 variant +# TODO: remove this once done +rm -rf "$TEMP_DIRECTORY/publish_arm64/libsoundio.dylib" + +pushd "$BASE_DIR/distribution/macos" +./create_app_bundle.sh "$TEMP_DIRECTORY/publish_x64" "$TEMP_DIRECTORY/output_x64" "$ENTITLEMENTS_FILE_PATH" +./create_app_bundle.sh "$TEMP_DIRECTORY/publish_arm64" "$TEMP_DIRECTORY/output_arm64" "$ENTITLEMENTS_FILE_PATH" +popd + +rm -rf "$UNIVERSAL_APP_BUNDLE" +mkdir -p "$OUTPUT_DIRECTORY" + +# Let's copy one of the two different app bundle and remove the executable +cp -R "$ARM64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" +rm "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" + +# Make it libraries universal +python3 "$BASE_DIR/distribution/macos/construct_universal_dylib.py" "$ARM64_APP_BUNDLE" "$X64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" "**/*.dylib" + +if ! [ -x "$(command -v lipo)" ]; +then + if ! [ -x "$(command -v llvm-lipo-14)" ]; + then + LIPO=llvm-lipo + else + LIPO=llvm-lipo-14 + fi +else + LIPO=lipo +fi + +# Make the executable universal +$LIPO "$ARM64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" "$X64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -output "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -create + +# Patch up the Info.plist to have appropriate version +sed -r -i.bck "s/\%\%RYUJINX_BUILD_VERSION\%\%/$VERSION/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist" +sed -r -i.bck "s/\%\%RYUJINX_BUILD_GIT_HASH\%\%/$SOURCE_REVISION_ID/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist" +rm "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist.bck" + +# Now sign it +if ! [ -x "$(command -v codesign)" ]; +then + if ! [ -x "$(command -v rcodesign)" ]; + then + echo "Cannot find rcodesign on your system, please install rcodesign." + exit 1 + fi + + # NOTE: Currently require https://github.com/indygreg/apple-platform-rs/pull/44 to work on other OSes. + # cargo install --git "https://github.com/marysaka/apple-platform-rs" --branch "fix/adhoc-app-bundle" apple-codesign --bin "rcodesign" + echo "Using rcodesign for ad-hoc signing" + rcodesign sign --entitlements-xml-path "$ENTITLEMENTS_FILE_PATH" "$UNIVERSAL_APP_BUNDLE" +else + echo "Using codesign for ad-hoc signing" + codesign --entitlements "$ENTITLEMENTS_FILE_PATH" -f --deep -s - "$UNIVERSAL_APP_BUNDLE" +fi + +echo "Creating archive" +pushd "$OUTPUT_DIRECTORY" +tar --exclude "Ryujinx.app/Contents/MacOS/Ryujinx" -cvf $RELEASE_TAR_FILE_NAME Ryujinx.app 1> /dev/null +python3 "$BASE_DIR/distribution/misc/add_tar_exec.py" $RELEASE_TAR_FILE_NAME "Ryujinx.app/Contents/MacOS/Ryujinx" "Ryujinx.app/Contents/MacOS/Ryujinx" +gzip -9 < $RELEASE_TAR_FILE_NAME > $RELEASE_TAR_FILE_NAME.gz +rm $RELEASE_TAR_FILE_NAME +popd + +echo "Done" \ No newline at end of file diff --git a/distribution/macos/create_macos_release.sh b/distribution/macos/create_macos_release.sh deleted file mode 100755 index 59eb1efd..00000000 --- a/distribution/macos/create_macos_release.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -set -e - -if [ "$#" -ne 6 ]; then - echo "usage " - exit 1 -fi - -mkdir -p "$1" -mkdir -p "$2" -mkdir -p "$3" - -BASE_DIR=$(readlink -f "$1") -TEMP_DIRECTORY=$(readlink -f "$2") -OUTPUT_DIRECTORY=$(readlink -f "$3") -ENTITLEMENTS_FILE_PATH=$(readlink -f "$4") -VERSION=$5 -SOURCE_REVISION_ID=$6 - -RELEASE_TAR_FILE_NAME=Ryujinx-$VERSION-macos_universal.app.tar -ARM64_APP_BUNDLE="$TEMP_DIRECTORY/output_arm64/Ryujinx.app" -X64_APP_BUNDLE="$TEMP_DIRECTORY/output_x64/Ryujinx.app" -UNIVERSAL_APP_BUNDLE="$OUTPUT_DIRECTORY/Ryujinx.app" -EXECUTABLE_SUB_PATH=Contents/MacOS/Ryujinx - -rm -rf "$TEMP_DIRECTORY" -mkdir -p "$TEMP_DIRECTORY" - -DOTNET_COMMON_ARGS="-p:DebugType=embedded -p:Version=$VERSION -p:SourceRevisionId=$SOURCE_REVISION_ID --self-contained true" - -dotnet restore -dotnet build -c Release src/Ryujinx.Ava -dotnet publish -c Release -r osx-arm64 -o "$TEMP_DIRECTORY/publish_arm64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava -dotnet publish -c Release -r osx-x64 -o "$TEMP_DIRECTORY/publish_x64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava - -# Get rid of the support library for ARMeilleure for x64 (that's only for arm64) -rm -rf "$TEMP_DIRECTORY/publish_x64/libarmeilleure-jitsupport.dylib" - -# Get rid of libsoundio from arm64 builds as we don't have a arm64 variant -# TODO: remove this once done -rm -rf "$TEMP_DIRECTORY/publish_arm64/libsoundio.dylib" - -pushd "$BASE_DIR/distribution/macos" -./create_app_bundle.sh "$TEMP_DIRECTORY/publish_x64" "$TEMP_DIRECTORY/output_x64" "$ENTITLEMENTS_FILE_PATH" -./create_app_bundle.sh "$TEMP_DIRECTORY/publish_arm64" "$TEMP_DIRECTORY/output_arm64" "$ENTITLEMENTS_FILE_PATH" -popd - -rm -rf "$UNIVERSAL_APP_BUNDLE" -mkdir -p "$OUTPUT_DIRECTORY" - -# Let's copy one of the two different app bundle and remove the executable -cp -R "$ARM64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" -rm "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" - -# Make it libraries universal -python3 "$BASE_DIR/distribution/macos/construct_universal_dylib.py" "$ARM64_APP_BUNDLE" "$X64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" "**/*.dylib" - -if ! [ -x "$(command -v lipo)" ]; -then - if ! [ -x "$(command -v llvm-lipo-14)" ]; - then - LIPO=llvm-lipo - else - LIPO=llvm-lipo-14 - fi -else - LIPO=lipo -fi - -# Make it the executable universal -$LIPO "$ARM64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" "$X64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -output "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -create - -# Patch up the Info.plist to have appropriate version -sed -r -i.bck "s/\%\%RYUJINX_BUILD_VERSION\%\%/$VERSION/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist" -sed -r -i.bck "s/\%\%RYUJINX_BUILD_GIT_HASH\%\%/$SOURCE_REVISION_ID/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist" -rm "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist.bck" - -# Now sign it -if ! [ -x "$(command -v codesign)" ]; -then - if ! [ -x "$(command -v rcodesign)" ]; - then - echo "Cannot find rcodesign on your system, please install rcodesign." - exit 1 - fi - - # NOTE: Currently require https://github.com/indygreg/apple-platform-rs/pull/44 to work on other OSes. - # cargo install --git "https://github.com/marysaka/apple-platform-rs" --branch "fix/adhoc-app-bundle" apple-codesign --bin "rcodesign" - echo "Usign rcodesign for ad-hoc signing" - rcodesign sign --entitlements-xml-path "$ENTITLEMENTS_FILE_PATH" "$UNIVERSAL_APP_BUNDLE" -else - echo "Usign codesign for ad-hoc signing" - codesign --entitlements "$ENTITLEMENTS_FILE_PATH" -f --deep -s - "$UNIVERSAL_APP_BUNDLE" -fi - -echo "Creating archive" -pushd "$OUTPUT_DIRECTORY" -tar --exclude "Ryujinx.app/Contents/MacOS/Ryujinx" -cvf $RELEASE_TAR_FILE_NAME Ryujinx.app 1> /dev/null -python3 "$BASE_DIR/distribution/misc/add_tar_exec.py" $RELEASE_TAR_FILE_NAME "Ryujinx.app/Contents/MacOS/Ryujinx" "Ryujinx.app/Contents/MacOS/Ryujinx" -gzip -9 < $RELEASE_TAR_FILE_NAME > $RELEASE_TAR_FILE_NAME.gz -rm $RELEASE_TAR_FILE_NAME -popd - -echo "Done" \ No newline at end of file -- cgit v1.2.3