diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ac8f3bc..60e674b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,18 +57,27 @@ on: required: true default: true type: boolean + compression: + description: "Compression Algorithm" + required: true + default: "ZIP" + type: choice + options: + - ZIP + - 7-Zip + - XZ title: - description: "Release title" + description: "Release Title" required: true default: "WSA" type: string tag: - description: "Release tag name" + description: "Release Tag Name" required: true default: "WSA" type: string prerelease: - description: "Release as prerelease" + description: "Release as Prerelease" required: false default: false type: boolean @@ -85,7 +94,7 @@ jobs: - name: Install Dependencies working-directory: ./scripts run: | - sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf e2fsprogs python3-pip aria2 attr + sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf e2fsprogs python3-pip aria2 p7zip-full attr xz-utils python3 -m pip install requests cp -r ../wine/.cache/* ~/.cache winetricks msxml6 @@ -95,7 +104,7 @@ jobs: DOWNLOAD_DIR=../download DOWNLOAD_CONF_NAME=download.list - declare -A opts=( ["ARCH,x86_64"]="x64" ["ARCH,ARM64"]="arm64" ["RELEASE_TYPE,General Availability Channel"]="retail" ["RELEASE_TYPE,Release Preview Channel"]="RP" ["RELEASE_TYPE,Beta Channel"]="WIS" ["RELEASE_TYPE,Dev Channel"]="WIF" ["MAGISK_VER,Stable"]="stable" ["MAGISK_VER,Beta"]="beta" ["MAGISK_VER,Canary"]="canary" ["MAGISK_VER,Debug"]="debug" ["MAGISK_VER,Custom"]="--magisk-custom" ["GAPPS_VAR,None"]="none" ["GAPPS_VAR,Pico"]="pico" ["GAPPS_VAR,Full"]="full" ["REMOVE_AMAZON,true"]="--remove-amazon" ["REMOVE_AMAZON,false"]="" ) + declare -A opts=( ["ARCH,x86_64"]="x64" ["ARCH,ARM64"]="arm64" ["RELEASE_TYPE,General Availability Channel"]="retail" ["RELEASE_TYPE,Release Preview Channel"]="RP" ["RELEASE_TYPE,Beta Channel"]="WIS" ["RELEASE_TYPE,Dev Channel"]="WIF" ["MAGISK_VER,Stable"]="stable" ["MAGISK_VER,Beta"]="beta" ["MAGISK_VER,Canary"]="canary" ["MAGISK_VER,Debug"]="debug" ["MAGISK_VER,Custom"]="--magisk-custom" ["GAPPS_VAR,None"]="none" ["GAPPS_VAR,Pico"]="pico" ["GAPPS_VAR,Full"]="full" ["REMOVE_AMAZON,true"]="--remove-amazon" ["REMOVE_AMAZON,false"]="" ["COMPRESSION,7-Zip"]="7z" ["COMPRESSION,XZ"]="xz") ARCH="${opts[ARCH,${{ inputs.arch }}]}" @@ -204,6 +213,10 @@ jobs: REMOVE_AMAZON="${opts[REMOVE_AMAZON,${{ inputs.remove_amazon }}]}" + # if [[ "${{ inputs.compression }}" != "ZIP" ]]; then + # COMPRESSION="--compress --compress-format ${opts[COMPRESSION,${{ inputs.compression }}]}" + # fi + if [[ "${{ inputs.gapps_var }}" == "Custom"* ]]; then echo "Generate Download Links" python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" @@ -219,7 +232,7 @@ jobs: OFFLINE="--offline" fi - COMMAND_LINE=(--arch "$ARCH" --release-type "$RELEASE_TYPE" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VAR" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$CUSTOM_MAGISK" "$OFFLINE") + COMMAND_LINE=(--arch "$ARCH" --release-type "$RELEASE_TYPE" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VAR" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$CUSTOM_MAGISK" "$OFFLINE" "$COMPRESSION") echo "COMMAND_LINE=${COMMAND_LINE[*]}" chmod +x ./build.sh @@ -252,16 +265,24 @@ jobs: else amazon="_Amazon-AppStore" fi + echo "release_asset_name=WSA_${{ env.WSA_VER }}_${{ inputs.arch }}$magiskVer$gappsVar${amazon}" >> $GITHUB_ENV - name: Compress Asset working-directory: ./output run: | find ./ -maxdepth 1 -type d -not -path './' -exec mv "{}" WSA \; - zip -qrv "${{ env.release_asset_name }}.zip" ./* + + if [[ "${{ inputs.compression }}" == "ZIP" ]]; then + zip -qrv "${{ env.release_asset_name }}.zip" ./* + elif [[ "${{ inputs.compression }}" == "7-Zip" ]]; then + 7z a "${{ env.release_asset_name }}.7z" ./* + else + tar -cP -I 'xz -9 -T0' -f "${{ env.release_asset_name }}.tar.xz" ./* + fi - name: Upload Asset uses: softprops/action-gh-release@v1 with: - files: ./output/${{ env.release_asset_name }}.zip + files: ./output/${{ env.release_asset_name }}.* name: ${{ inputs.title }} tag_name: ${{ inputs.tag }} prerelease: ${{ inputs.prerelease }} diff --git a/scripts/build.sh b/scripts/build.sh index 7df4315..bcbb3ea 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -148,6 +148,12 @@ ROOT_SOL_MAP=( "magisk" "none" ) + +COMPRESS_FORMAT_MAP=( + "7z" + "xz" +) + ARR_TO_STR() { local arr=("$@") local joined @@ -190,9 +196,15 @@ usage() { Possible values: $(ARR_TO_STR "${ROOT_SOL_MAP[@]}") Default: $ROOT_SOL + --compress-format + Compress format of output file. + If this option is not specified and --compress is not specified, the generated file will not be compressed + + Possible values: $(ARR_TO_STR "${COMPRESS_FORMAT_MAP[@]}") + Additional Options: - --remove-amazon Remove Amazon AppStore from the system - --compress Compress the WSA + --remove-amazon Remove Amazon Appstore from the system + --compress Compress the WSA, The default format is 7z, you can use the format specified by --compress-format --offline Build WSA offline --magisk-custom Install custom Magisk --debug Debug build mode @@ -213,6 +225,7 @@ ARGUMENT_LIST=( "gapps-brand:" "gapps-variant:" "root-sol:" + "compress-format:" "remove-amazon" "compress" "offline" @@ -240,6 +253,7 @@ while [[ $# -gt 0 ]]; do --gapps-brand ) GAPPS_BRAND="$2"; shift 2 ;; --gapps-variant ) GAPPS_VARIANT="$2"; shift 2 ;; --root-sol ) ROOT_SOL="$2"; shift 2 ;; + --compress-format ) COMPRESS_FORMAT="$2"; shift 2 ;; --remove-amazon ) REMOVE_AMAZON="remove"; shift ;; --compress ) COMPRESS_OUTPUT="yes"; shift ;; --offline ) OFFLINE="on"; shift ;; @@ -252,20 +266,22 @@ done check_list() { local input=$1 - local name=$2 - shift - local arr=("$@") - local list_count=${#arr[@]} - for i in "${arr[@]}"; do - if [ "$input" == "$i" ]; then - echo "INFO: $name: $input" - break - fi - ((list_count--)) - if (("$list_count" <= 0)); then - exit_with_message "Invalid $name: $input" - fi - done + if [ -n "$input" ]; then + local name=$2 + shift + local arr=("$@") + local list_count=${#arr[@]} + for i in "${arr[@]}"; do + if [ "$input" == "$i" ]; then + echo "INFO: $name: $input" + break + fi + ((list_count--)) + if (("$list_count" <= 0)); then + exit_with_message "Invalid $name: $input" + fi + done + fi } check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}" @@ -274,6 +290,7 @@ check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}" check_list "$GAPPS_BRAND" "GApps Brand" "${GAPPS_BRAND_MAP[@]}" check_list "$GAPPS_VARIANT" "GApps Variant" "${GAPPS_VARIANT_MAP[@]}" check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}" +check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}" if [ "$DEBUG" ]; then set -x @@ -836,10 +853,20 @@ fi if [ ! -d "$OUTPUT_DIR" ]; then mkdir -p "$OUTPUT_DIR" fi -if [ "$COMPRESS_OUTPUT" ]; then - rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort +if [ "$COMPRESS_OUTPUT" ] || [ -n "$COMPRESS_FORMAT" ]; then mv "$WORK_DIR/wsa/$ARCH" "$WORK_DIR/wsa/$artifact_name" - 7z a "$OUTPUT_DIR"/"$artifact_name.7z" "$WORK_DIR/wsa/$artifact_name" || abort + if [ "$COMPRESS_FORMAT" = "7z" ]; then + rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort + echo "Compressing with 7z" + 7z a "$OUTPUT_DIR"/"$artifact_name.7z" "$WORK_DIR/wsa/$artifact_name" || abort + elif [ "$COMPRESS_FORMAT" = "xz" ]; then + rm -f "${OUTPUT_DIR:?}"/"$artifact_name.tar.xz" || abort + echo "Compressing with tar xz" + if ! (tar -cP -I 'xz -9 -T0' -f "$OUTPUT_DIR"/"$artifact_name.tar.xz" "$WORK_DIR/wsa/$artifact_name"); then + echo "Out of memory? Trying again with single threads..." + tar -cPJvf "$OUTPUT_DIR"/"$artifact_name.tar.xz" "$WORK_DIR/wsa/$artifact_name" || abort + fi + fi else rm -rf "${OUTPUT_DIR:?}/${artifact_name}" || abort cp -r "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_DIR/$artifact_name" || abort