WSABuilds/.github/workflows/build.yaml

268 lines
13 KiB
YAML
Raw Normal View History

2022-08-29 23:32:14 +02:00
name: Build MagiskOnWSA
on:
workflow_dispatch:
inputs:
arch:
description: "WSA Architecture"
required: true
2022-08-30 04:05:55 +02:00
default: "x86_64"
2022-08-29 23:32:14 +02:00
type: choice
options:
2022-08-30 04:05:55 +02:00
- x86_64
- ARM64
2022-08-29 23:32:14 +02:00
release_type:
description: "WSA Release Channel"
required: true
default: "Dev Channel"
type: choice
options:
- General Availability Channel
- Release Preview Channel
- Beta Channel
- Dev Channel
magisk_ver:
description: "Magisk Version"
required: true
default: "Stable"
type: choice
options:
- None
- Stable
- Beta
- Canary
- Debug
- Custom
2022-08-29 23:32:14 +02:00
magisk_url:
description: "Custom Magisk APK/ZIP URL"
required: false
type: string
gapps_var:
description: "GApps Variant"
required: true
2022-09-12 21:13:39 +02:00
default: "MindTheGapps"
2022-08-29 23:32:14 +02:00
type: choice
options:
- None
2022-09-04 23:41:28 +02:00
- Pico
- Full
2022-09-12 21:13:39 +02:00
- MindTheGapps
- Custom (OpenGApps)
- Custom (MindTheGapps)
gapps_url:
description: "Custom GApps ZIP URL"
2022-08-29 23:32:14 +02:00
required: false
type: string
remove_amazon:
description: "Remove Amazon AppStore"
2022-09-13 06:49:03 +02:00
required: true
2022-08-29 23:32:14 +02:00
default: true
type: boolean
2022-09-15 08:19:12 +02:00
title:
description: "Release title"
required: true
default: "WSA"
type: string
2022-09-08 21:22:54 +02:00
tag:
description: "Release tag name"
2022-09-13 06:49:03 +02:00
required: true
2022-09-08 21:22:54 +02:00
default: "WSA"
type: string
2022-09-08 21:31:15 +02:00
prerelease:
description: "Release as prerelease"
required: false
default: false
type: boolean
2022-08-29 23:32:14 +02:00
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
2022-08-30 00:22:15 +02:00
- name: Checkout
uses: actions/checkout@v3
2022-08-29 23:32:14 +02:00
- name: Install Dependencies
2022-08-30 01:10:44 +02:00
working-directory: ./scripts
2022-08-29 23:32:14 +02:00
run: |
sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf e2fsprogs python3-pip aria2 attr
2022-08-29 23:32:14 +02:00
python3 -m pip install requests
cp -r ../wine/.cache/* ~/.cache
winetricks msxml6
- name: Build MagiskOnWSA
2022-08-30 01:10:44 +02:00
working-directory: ./scripts
2022-08-29 23:32:14 +02:00
run: |
DOWNLOAD_DIR=../download
DOWNLOAD_CONF_NAME=download.list
2022-08-30 00:38:06 +02:00
2022-09-04 23:41:28 +02:00
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"]="" )
2022-08-30 00:38:06 +02:00
2022-08-29 23:32:14 +02:00
ARCH="${opts[ARCH,${{ inputs.arch }}]}"
2022-08-30 00:38:06 +02:00
2022-08-29 23:32:14 +02:00
RELEASE_TYPE="${opts[RELEASE_TYPE,${{ inputs.release_type }}]}"
2022-08-30 00:38:06 +02:00
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.magisk_ver }}" != "None" ]]; then
2022-08-29 23:32:14 +02:00
ROOT_SOL="magisk"
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.magisk_ver }}" != "Custom" ]]; then
2022-08-29 23:32:14 +02:00
MAGISK_VER="${opts[MAGISK_VER,${{ inputs.magisk_ver }}]}"
else
echo "${{ inputs.magisk_url }}" > "$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_custom_magisk_download.log" -x16 -s16 -j5 -c -R -m0 --async-dns=false --check-integrity --continue --allow-overwrite --conditional-get -d"$DOWNLOAD_DIR" -o magisk-debug.zip -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then
echo "Magisk download error!"
2022-08-29 23:32:14 +02:00
exit 1
fi
CUSTOM_MAGISK="${opts[MAGISK_VER,Custom]}"
2022-08-29 23:32:14 +02:00
MAGISK_VER="${opts[MAGISK_VER,Debug]}"
fi
else
ROOT_SOL="none"
MAGISK_VER="${opts[MAGISK_VER,Stable]}"
fi
2022-08-30 00:38:06 +02:00
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.arch }}" == "x86_64" ]]; then
2022-08-30 03:24:10 +02:00
GAPPS_VAR="${opts[GAPPS_VAR,${{ inputs.gapps_var }}]}"
2022-08-29 23:32:14 +02:00
else
2022-08-30 03:24:10 +02:00
# TODO: keep it 11.0 since official opengapps does not support 12+ yet
# As soon as opengapps is available for 12+, we need to get the sdk/release from build.prop and download the corresponding version
2022-09-12 21:13:39 +02:00
if [[ "${{ inputs.gapps_var }}" != "None" ]]; then
2022-09-04 23:41:28 +02:00
GAPPS_VAR="${opts[GAPPS_VAR,Pico]}"
2022-08-30 03:24:10 +02:00
else
GAPPS_VAR="${opts[GAPPS_VAR,${{ inputs.gapps_var }}]}"
fi
2022-08-29 23:32:14 +02:00
fi
2022-08-30 00:38:06 +02:00
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.gapps_var }}" != "None" ]]; then
2022-09-12 21:13:39 +02:00
if [[ "${{ inputs.gapps_var }}" != *"MindTheGapps"* ]]; then
2022-08-29 23:32:14 +02:00
GAPPS_BRAND="OpenGApps"
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.gapps_var }}" == "Custom (OpenGApps)" ]]; then
if [[ -z "${${{ inputs.gapps_url }}+x}" ]]; then
GAPPS_VARIANT_MAP=(
"super"
"stock"
"full"
"mini"
"micro"
"nano"
"pico"
"tvstock"
"tvmini"
)
for file in "$DOWNLOAD_DIR"/OpenGApps-"$ARCH"-*.zip; do
GAPPS_VAR=${file%%\.*}
GAPPS_VAR=${GAPPS_VAR##*-}
list_count=${#GAPPS_VARIANT_MAP[@]}
for i in "${GAPPS_VARIANT_MAP[@]}"; do
2022-09-04 23:58:06 +02:00
if [[ "$GAPPS_VAR" == "$i" ]]; then
echo "INFO: GApps Variant: $GAPPS_VAR"
valid_gapps_var="true"
break
fi
((list_count--))
if (("$list_count" <= 0)); then
echo "Invalid GApps Variant: $GAPPS_VAR"
fi
done
if [[ "$valid_gapps_var" == "true" ]]; then
break
fi
done
if [[ "$valid_gapps_var" != "true" ]]; then
echo "Missing OpenGApps file!"
exit 1
fi
echo "opengapps_var=${GAPPS_VAR^}" >> $GITHUB_ENV
else
GAPPS_VAR="pico"
echo "${{ inputs.gapps_url }}" > -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_gapps_download.log" -x16 -s16 -j5 -c -R -m0 --async-dns=false --check-integrity --continue --allow-overwrite --conditional-get -d"$DOWNLOAD_DIR" -o OpenGApps-"$ARCH"-"$GAPPS_VAR".zip -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then
echo "OpenGApps download error!"
exit 1
fi
echo "opengapps_var=custom" >> $GITHUB_ENV
fi
fi
2022-08-29 23:32:14 +02:00
else
2022-09-12 21:13:39 +02:00
GAPPS_VAR="pico"
GAPPS_BRAND="MindTheGapps"
if [[ "${{ inputs.gapps_var }}" == "Custom (MindTheGapps)" ]]; then
if [[ -n "${${{ inputs.gapps_url }}+x}" ]]; then
echo "${{ inputs.gapps_url }}" > -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"
2022-08-29 23:32:14 +02:00
2022-09-12 21:13:39 +02:00
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_gapps_download.log" -x16 -s16 -j5 -c -R -m0 --async-dns=false --check-integrity --continue --allow-overwrite --conditional-get -d"$DOWNLOAD_DIR" -o MindTheGapps-"$ARCH".zip -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then
echo "MindTheGapps download error!"
exit 1
fi
fi
2022-08-29 23:32:14 +02:00
fi
fi
else
2022-09-08 22:04:35 +02:00
GAPPS_VAR="pico"
GAPPS_BRAND="none"
2022-08-29 23:32:14 +02:00
fi
2022-08-30 00:38:06 +02:00
2022-08-29 23:32:14 +02:00
REMOVE_AMAZON="${opts[REMOVE_AMAZON,${{ inputs.remove_amazon }}]}"
2022-08-30 00:38:06 +02:00
2022-09-12 21:13:39 +02:00
if [[ "${{ inputs.gapps_var }}" == "Custom"* ]]; then
echo "Generate Download Links"
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME"
2022-09-04 23:58:06 +02:00
if [[ "${{ inputs.magisk_ver }}" != "Custom" ]]; then
python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME"
fi
echo "Download Artifacts"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 --async-dns=false --check-integrity --continue --allow-overwrite --conditional-get -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then
echo "Artifact download error!"
exit 1
fi
OFFLINE="--offline"
fi
2022-08-30 00:38:06 +02:00
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")
2022-08-29 23:32:14 +02:00
echo "COMMAND_LINE=${COMMAND_LINE[*]}"
2022-08-30 01:15:17 +02:00
2022-08-30 01:16:56 +02:00
chmod +x ./build.sh
2022-08-29 23:32:14 +02:00
./build.sh "${COMMAND_LINE[@]}"
- name: Generate Release Asset Name
2022-08-30 01:10:44 +02:00
working-directory: ./output
2022-08-29 23:32:14 +02:00
run: |
2022-08-30 02:31:10 +02:00
declare -A magisk_vers=( ["Stable"]="stable" ["Beta"]="beta" ["Canary"]="canary" ["Debug"]="debug" )
2022-08-30 03:55:19 +02:00
if [[ "${{ inputs.magisk_ver }}" == "None" ]]; then
magiskVer=""
elif [[ "${{ inputs.magisk_ver }}" == "Custom" ]]; then
magiskVer="_Magisk-Custom"
2022-08-29 23:32:14 +02:00
else
magiskVer="_Magisk-$(curl -s https://raw.githubusercontent.com/topjohnwu/magisk-files/master/${magisk_vers[${{ inputs.magisk_ver }}]}.json | jq -r ".magisk.version")"
2022-08-29 23:32:14 +02:00
fi
2022-08-30 03:49:47 +02:00
if [[ "${{ inputs.gapps_var }}" == "None" ]]; then
gappsVar=""
2022-09-12 21:13:39 +02:00
elif [[ "${{ inputs.gapps_var }}" == *"MindTheGapps"* ]]; then
gappsVar="_MindTheGapps"
elif [[ "${{ inputs.gapps_var }}" == "Custom (OpenGApps)" ]]; then
2022-09-08 23:43:38 +02:00
gappsVar="_OpenGApps-${{ env.opengapps_var }}"
2022-08-29 23:32:14 +02:00
else
2022-09-08 23:43:38 +02:00
gappsVar="_OpenGApps-${{ inputs.gapps_var }}"
2022-08-29 23:32:14 +02:00
fi
2022-08-30 03:24:10 +02:00
if [[ "${{ inputs.remove_amazon }}" == "true" ]]; then
amazon=""
2022-08-29 23:32:14 +02:00
else
amazon="_Amazon-AppStore"
2022-08-29 23:32:14 +02:00
fi
2022-09-08 23:40:41 +02:00
echo "release_asset_name=WSA_${{ env.WSA_VER }}_${{ inputs.arch }}$magiskVer$gappsVar${amazon}" >> $GITHUB_ENV
2022-08-29 23:32:14 +02:00
- name: Compress Asset
2022-08-30 01:10:44 +02:00
working-directory: ./output
2022-08-29 23:32:14 +02:00
run: |
2022-08-30 00:13:07 +02:00
find ./ -maxdepth 1 -type d -not -path './' -exec mv "{}" WSA \;
2022-08-29 23:32:14 +02:00
zip -qrv "${{ env.release_asset_name }}.zip" ./*
- name: Upload Asset
uses: softprops/action-gh-release@v1
with:
2022-08-30 01:12:39 +02:00
files: ./output/${{ env.release_asset_name }}.zip
2022-09-15 08:19:12 +02:00
name: ${{ inputs.title }}
2022-09-08 21:22:54 +02:00
tag_name: ${{ inputs.tag }}
2022-09-08 21:31:15 +02:00
prerelease: ${{ inputs.prerelease }}