IPA to DEB repository #13
This file contains hidden or 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
| name: IPA to DEB repository | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ipa_urls: | |
| description: "Direct IPA URLs, one per line" | |
| required: true | |
| type: string | |
| release_tag: | |
| description: "Release category" | |
| required: true | |
| default: "application" | |
| type: choice | |
| options: | |
| - game | |
| - application | |
| concurrency: | |
| group: package-index | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| IPA_URLS: ${{ inputs.ipa_urls }} | |
| RELEASE_TAG: ${{ inputs.release_tag }} | |
| REPOSITORY: ${{ github.repository }} | |
| SERVER_URL: ${{ github.server_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install package tools | |
| run: sudo apt-get update && sudo apt-get install --yes aria2 dpkg-dev | |
| - name: Download and convert IPA files | |
| run: | | |
| set -euo pipefail | |
| mkdir -p work/ipa work/deb | |
| while IFS= read -r url; do | |
| url="${url#${url%%[![:space:]]*}}" | |
| url="${url%${url##*[![:space:]]}}" | |
| [ -z "$url" ] && continue | |
| case "$url" in | |
| https://*|http://*) ;; | |
| *) echo "Invalid URL: $url" >&2; exit 1 ;; | |
| esac | |
| name="$(basename "${url%%\?*}")" | |
| [[ "$name" == *.ipa ]] || { echo "URL is not an IPA: $url" >&2; exit 1; } | |
| aria2c -s16 -x16 --allow-overwrite=true \ | |
| --dir=work/ipa --out="$name" "$url" | |
| done <<< "$IPA_URLS" | |
| ./ipa2deb work/ipa work/deb \ | |
| "dopaemon <polarisdp@gmail.com>" \ | |
| "$SERVER_URL/$REPOSITORY" | |
| compgen -G 'work/deb/*.deb' > /dev/null || { | |
| echo "No DEB was generated" >&2 | |
| exit 1 | |
| } | |
| - name: Create or update Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| gh release view "$RELEASE_TAG" >/dev/null 2>&1 || \ | |
| gh release create "$RELEASE_TAG" --title "$RELEASE_TAG" \ | |
| --notes "Packages generated by the IPA to DEB workflow." | |
| gh release upload "$RELEASE_TAG" work/deb/*.deb --clobber | |
| - name: Rebuild Packages metadata | |
| run: scripts/update-packages.sh | |
| - name: Commit Packages metadata | |
| run: | | |
| set -euo pipefail | |
| git config user.name dopaemon | |
| git config user.email polarisdp@gmail.com | |
| git add Packages Packages.gz | |
| if git diff --cached --quiet; then | |
| echo "Packages metadata unchanged" | |
| exit 0 | |
| fi | |
| git commit -s -m "Update package index for $RELEASE_TAG" | |
| git push origin HEAD:main |