IPA Down #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: expandtab tabstop=2 shiftwidth=2 | |
name: IPA Down | |
env: | |
PYTHONIOENCODING: utf-8 | |
# Allow Release | |
permissions: write-all | |
on: | |
workflow_dispatch: | |
inputs: | |
appleId: | |
description: 'Apple ID Account' | |
required: true | |
appleIdPwd: | |
description: 'Apple ID Password' | |
required: true | |
operation: | |
description: 'Operation to do, choices: lookup, historyver, download, historyver_id, download_id' | |
appBundleId: | |
description: 'AppStore Bundle-ID (needed when using non-*_id operations)' | |
required: false | |
appCountry: | |
description: 'AppStore Country (needed when using non-*_id operations)' | |
required: false | |
default: 'JP' | |
appVerId: | |
description: 'App Version Id Number (for downloading history versions)' | |
required: false | |
appId: | |
description: 'App Id Number (needed when using *_id operations)' | |
required: false | |
debug_enabled: | |
description: 'Run the build with RDP debugging enabled' | |
required: false | |
default: false | |
itunes_debug_enabled: | |
description: 'Run the build with ngrok debugging enabled' | |
required: false | |
default: false | |
jobs: | |
download_ipa: | |
name: 'IPATool Operations' | |
runs-on: "windows-latest" | |
steps: | |
- name: Masking inputs | |
run: | | |
SECRET_VALUE=$(cat $GITHUB_EVENT_PATH | jq -r '.inputs.appleId' ) | |
echo "::add-mask::$SECRET_VALUE" | |
SECRET_VALUE=$(cat $GITHUB_EVENT_PATH | jq -r '.inputs.appleIdPwd' ) | |
echo "::add-mask::$SECRET_VALUE" | |
shell: bash | |
- name: Set up git repository | |
uses: actions/checkout@v2 | |
- name: Setup ipatool-py | |
run: | | |
git clone -b itunes_server https://github.com/NyaMisty/ipatool-py | |
pip3 install -r ipatool-py/requirements.txt | |
mkdir -p ipaDown | |
shell: bash | |
- name: Setup iTunes Header Service | |
uses: NyaMisty/actions-iTunes-header@master | |
if: ${{ github.event.inputs.operation != 'lookup' }} | |
with: | |
apple_id: ${{ github.event.inputs.appleId }} | |
apple_id_pwd: ${{ github.event.inputs.appleIdPwd }} | |
ngrok_token: ${{ secrets.NGROK_AUTH_TOKEN }} | |
- name: Execute operation | |
id: operation | |
run: | | |
# available operations: lookup, historyver, download, historyver_id, download_id | |
op=${{ github.event.inputs.operation }} | |
if [[ "$op" == "lookup" ]]; then | |
if [[ "${{ github.event.inputs.appBundleId }}" != "" ]]; then | |
python3 ipatool-py/main.py --json lookup --get-verid -b ${{ github.event.inputs.appBundleId }} -c ${{ github.event.inputs.appCountry }} | |
else | |
python3 ipatool-py/main.py --json lookup --get-verid -i ${{ github.event.inputs.appId }} -c ${{ github.event.inputs.appCountry }} | |
fi | |
elif [[ "$op" == historyver* ]]; then | |
if [[ "$op" == "historyver" ]]; then | |
python3 ipatool-py/main.py --json lookup -b ${{ github.event.inputs.appBundleId }} -c ${{ github.event.inputs.appCountry }} \ | |
historyver -s http://127.0.0.1:9000 | |
elif [[ "$op" == "historyver_id" ]]; then | |
python3 ipatool-py/main.py --json historyver -s http://127.0.0.1:9000 --appId ${{ github.event.inputs.id }} | |
fi | |
elif [[ "$op" == download* ]]; then | |
if [[ "${{ github.event.inputs.appVerId }}" == "" ]]; then | |
appVerCmd="" | |
else | |
appVerCmd="--appVerId ${{ github.event.inputs.appVerId }}" | |
fi | |
if [[ "$op" == "download" ]]; then | |
output=$(python3 ipatool-py/main.py --json lookup -b ${{ github.event.inputs.appBundleId }} -c ${{ github.event.inputs.appCountry }} \ | |
download -o ipaDown -s http://127.0.0.1:9000 $appVerCmd) | |
elif [[ "$op" == "download_id" ]]; then | |
output=$(python3 ipatool-py/main.py --json download -o ipaDown -s http://127.0.0.1:9000 --appId ${{ github.event.inputs.id }} $appVerCmd) | |
fi | |
echo "Got Downloading JSON result: $output" | |
echo "::set-output name=needIPARelease::1" | |
echo "::set-output name=appName::$(echo "$output" | jq -r '.appName')" | |
echo "::set-output name=appBundleId::$(echo "$output" | jq -r '.appBundleId')" | |
echo "::set-output name=appVer::$(echo "$output" | jq -r '.appVer')" | |
echo "::set-output name=appId::$(echo "$output" | jq -r '.appId')" | |
echo "::set-output name=appVerId::$(echo "$output" | jq -r '.appVerId')" | |
else | |
echo "Unknown Operation: $op" | |
fi | |
shell: bash | |
- name: "Upload package" | |
uses: NyaMisty/upload-artifact-as-is@master | |
with: | |
path: ipaDown\* | |
- name: Split ipa | |
if: ${{ steps.operation.outputs.needIPARelease == '1' }} | |
run: | | |
mkdir -p ipaDown_split | |
(cd ipaDown; find . -name "*.ipa" -size +1879048192b -exec split --bytes=1879048192 --suffix-length=3 --numeric-suffix {} ../ipaDown_split/{}. \;) | |
(cd ipaDown; find . -name "*.ipa" -not -size +1879048192b -exec cp -r {} ../ipaDown_split \;) | |
shell: bash | |
- name: Pushing to release | |
if: ${{ steps.operation.outputs.needIPARelease == 1 }} | |
uses: ncipollo/release-action@v1 | |
with: | |
name: "IPADown: ${{ steps.operation.outputs.appName }} - ${{ steps.operation.outputs.appVer }}" | |
body: >- | |
${{ format(fromJSON('"appName: {0}\nappBundleId: {1}\nappVer: {2}\nappId: {3}\nappVerId: {4}\n"'), | |
steps.operation.outputs.appName, | |
steps.operation.outputs.appBundleId, | |
steps.operation.outputs.appVer, | |
steps.operation.outputs.appId, | |
steps.operation.outputs.appVerId | |
) }} | |
commit: ${{ github.sha }} | |
tag: "${{ steps.operation.outputs.appBundleId }}-${{ steps.operation.outputs.appId }}-${{ steps.operation.outputs.appVerId }}" | |
artifacts: ipaDown_split\* | |
allowUpdates: true | |
removeArtifacts: true | |
replacesArtifacts: true |