Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pegakmop authored Oct 3, 2024
0 parents commit 4fd375a
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 0 deletions.
153 changes: 153 additions & 0 deletions .github/workflows/ipa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# 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
67 changes: 67 additions & 0 deletions .github/workflows/ipa_shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# vim: expandtab tabstop=2 shiftwidth=2
name: IPA Download Shell

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
itunes_debug_enabled:
description: 'Run the build with ngrok debugging enabled'
required: false
default: false

jobs:
ipadown_shell:
name: 'IPA Download Shell'
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 https://github.com/NyaMisty/ipatool-py
mkdir -p ipaDown
shell: bash

- name: Setup iTunes Header Service
uses: NyaMisty/actions-iTunes-header@master
with:
apple_id: ${{ github.event.inputs.appleId }}
apple_id_pwd: ${{ github.event.inputs.appleIdPwd }}
ngrok_token: ${{ secrets.NGROK_AUTH_TOKEN }}

#- uses: NyaMisty/reverse-rdp-windows-github-actions-ng@master
# if: ${{ always() && github.event_name == 'workflow_dispatch' && github.event.inputs.itunes_debug_enabled }}
# with:
# ngrok-token: ${{ secrets.NGROK_AUTH_TOKEN }}
# password: Aa123456
# foreground: false

# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: "Upload package"
uses: NyaMisty/upload-artifact-as-is@master
with:
path: ipaDown\*
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# action-ipadown

Download old versions of app using Github Actions, without computers!

**Warning: NOT supporting 2FA accounts currently**

## Use Cases

- Buy & Download App
- Download Old Versions of App
- Query Version History of App
- Lookup app information based on bundleID or appID

## Usage

1. Fork this repo
2. Enable Actions in forked repo
- Click Actions in toolbar
- Click `I understand my workflows, go ahead and enable them`
![image](https://user-images.githubusercontent.com/5344431/167505409-ef077008-2450-4e2d-9d43-2067244ac931.png)
3. Run Action
- Click `IPA Down` in left list:
![image](https://user-images.githubusercontent.com/5344431/167505630-1a741d9c-69de-470c-978e-1b8944dcfd3b.png)
- Click `Run workflow` at right:
![image](https://user-images.githubusercontent.com/5344431/167505748-52e0bba9-b9ec-44e1-9370-4452d3c3c66b.png)
- Enter Apple ID, Password, Operation and corresponding parameters (like bundleID)
- Click `Run workflow`
- Find output files in Actions artifact or Release
![image](https://user-images.githubusercontent.com/5344431/167506938-c3e3529c-ee91-4661-a251-a12a2d0576cb.png)
- If the actions fails at `Setup iTunes Header Service`, please retry 1~2 times before submitting issue

## Operations

There are currently five operations: lookup, historyver, download, historyver_id, download_id

- lookup: query information of app based on bundleID
- historyver: query history appVerID by bundleID (with historyver_id querys by appID)
- download: download IPA by bundleID (download_id uses appID) & appVerID (optional, defaults to newest version)

To use these operations, enter your app informations like this:
- Using Bundle ID:
![image](https://user-images.githubusercontent.com/5344431/167506427-1503417c-112f-4c45-b82b-7887f05b0dac.png)
- Using appID:
![image](https://user-images.githubusercontent.com/5344431/167506645-d29db175-ab38-45d3-b224-6cc94131e61d.png)
- Also giving appVerID:
![image](https://user-images.githubusercontent.com/5344431/167506870-8dcaa565-3bd1-424e-a9d2-eed00bd4cffb.png)

## Credits

- ipatool-py: https://github.com/NyaMisty/ipatool-py
- actions-iTunes-header: https://github.com/NyaMisty/actions-iTunes-header

0 comments on commit 4fd375a

Please sign in to comment.