From f1fb91448cfbaf34abd180779a3fba813b85af3e Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Thu, 16 May 2024 20:12:34 +0200 Subject: [PATCH] refactor: make workflows repo agnostic (#5) * chore: make workflows repo agnostic * fix: idiotism * fix: patcher hardcodes file name * fix: more idiotism * fix: pro tip, don't do stuff on the go on the phone you'll forget a lot of stuff * fix: use correct context value * chore: cleanup * chore: cleanup more stuff --------- Co-authored-by: Adrian Castro --- .github/workflows/build.yml | 20 +++++------ .github/workflows/release.yml | 67 ++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d51902..7ba37a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Pyoncord +name: Build on: workflow_dispatch: @@ -9,10 +9,6 @@ on: required: true type: string -env: - upstream_heads: - DEB_FILE_NAME: - jobs: build-tweak: runs-on: macos-14 @@ -92,28 +88,30 @@ jobs: run: | curl -L -o ipa-icons.zip https://raw.githubusercontent.com/pyoncord/assets/main/ipa-icons.zip - - name: Extract Package and Version + - name: Extract Values run: | + NAME=$(grep '^Name:' control | cut -d ' ' -f 2) PACKAGE=$(grep '^Package:' control | cut -d ' ' -f 2) VERSION=$(grep '^Version:' control | cut -d ' ' -f 2) DEB_FILE_NAME="${PACKAGE}_${VERSION}_iphoneos-arm.deb" echo "DEB_FILE_NAME=$DEB_FILE_NAME" >> $GITHUB_ENV + echo "APP_NAME=$NAME" >> $GITHUB_ENV - name: Inject tweak run: | mkdir -p ${{ github.workspace }}/build git clone https://github.com/Al4ise/Azule.git ./Azule/azule -i discord.ipa -o ${{ github.workspace }}/build -f ${{ github.workspace }}/dev.theos.orion14_1.0.1_iphoneos-arm.deb ${{ github.workspace }}/${{ env.DEB_FILE_NAME }} - mv "${{ github.workspace }}/build/"*.ipa "${{ github.workspace }}/build/Pyoncord.ipa" + mv "${{ github.workspace }}/build/"*.ipa "${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa" - name: Patch Discord working-directory: patcher run : | - ./patcher -d ${{ github.workspace }}/build/Pyoncord.ipa -i ./ipa-icons.zip - mv -f ./Pyoncord.ipa "${{ github.workspace }}/build/Pyoncord.ipa" + ./patcher -d ${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa -i ./ipa-icons.zip + mv -f ./*.ipa "${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa" - - name: Upload Pyoncord.ipa as artifact + - name: Upload ipa as artifact uses: actions/upload-artifact@v4 with: name: ipa - path: ${{ github.workspace }}/build/Pyoncord.ipa + path: ${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59831e6..57fc042 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Pyoncord +name: Release on: workflow_dispatch: @@ -8,13 +8,7 @@ on: default: "" required: true type: string - -env: - upstream_heads: - DISCORD_VERSION: - DEB_FILE_NAME: - ROOTLESS_DEB_FILE_NAME: - + jobs: build-tweak: runs-on: macos-14 @@ -94,33 +88,37 @@ jobs: run: | curl -L -o ipa-icons.zip https://raw.githubusercontent.com/pyoncord/assets/main/ipa-icons.zip - - name: Extract Package and Version + - name: Extract Values run: | + NAME=$(grep '^Name:' control | cut -d ' ' -f 2) PACKAGE=$(grep '^Package:' control | cut -d ' ' -f 2) VERSION=$(grep '^Version:' control | cut -d ' ' -f 2) DEB_FILE_NAME="${PACKAGE}_${VERSION}_iphoneos-arm.deb" echo "DEB_FILE_NAME=$DEB_FILE_NAME" >> $GITHUB_ENV + ROOTLESS_DEB_FILE_NAME="${PACKAGE}_${VERSION}_iphoneos-arm64.deb" + echo "ROOTLESS_DEB_FILE_NAME=$ROOTLESS_DEB_FILE_NAME" >> $GITHUB_ENV + echo "APP_NAME=$NAME" >> $GITHUB_ENV - name: Inject tweak run: | mkdir -p ${{ github.workspace }}/build git clone https://github.com/Al4ise/Azule.git ./Azule/azule -i discord.ipa -o ${{ github.workspace }}/build -f ${{ github.workspace }}/dev.theos.orion14_1.0.1_iphoneos-arm.deb ${{ github.workspace }}/${{ env.DEB_FILE_NAME }} - mv "${{ github.workspace }}/build/"*.ipa "${{ github.workspace }}/build/Pyoncord.ipa" + mv "${{ github.workspace }}/build/"*.ipa "${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa" - name: Patch Discord working-directory: patcher run : | - ./patcher -d ${{ github.workspace }}/build/Pyoncord.ipa -i ./ipa-icons.zip - mv -f ./Pyoncord.ipa "${{ github.workspace }}/build/Pyoncord.ipa" + ./patcher -d ${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa -i ./ipa-icons.zip + mv -f ./*.ipa "${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa" - - name: Upload Pyoncord.ipa as artifact + - name: Upload ipa as artifact uses: actions/upload-artifact@v4 with: name: ipa - path: ${{ github.workspace }}/build/Pyoncord.ipa + path: ${{ github.workspace }}/build/${{ env.APP_NAME }}.ipa - release-pyoncord: + release-app: runs-on: macos-14 needs: build-ipa permissions: @@ -129,21 +127,26 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - merge-multiple: true - - - name: Extract Package File Names and Discord Version + + - name: Extract Values run: | + NAME=$(grep '^Name:' control | cut -d ' ' -f 2) PACKAGE=$(grep '^Package:' control | cut -d ' ' -f 2) VERSION=$(grep '^Version:' control | cut -d ' ' -f 2) DEB_FILE_NAME="${PACKAGE}_${VERSION}_iphoneos-arm.deb" echo "DEB_FILE_NAME=$DEB_FILE_NAME" >> $GITHUB_ENV ROOTLESS_DEB_FILE_NAME="${PACKAGE}_${VERSION}_iphoneos-arm64.deb" echo "ROOTLESS_DEB_FILE_NAME=$ROOTLESS_DEB_FILE_NAME" >> $GITHUB_ENV - unzip -q Pyoncord.ipa + echo "APP_NAME=$NAME" >> $GITHUB_ENV + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Extract Discord Version + run: | + unzip -q ${{ env.APP_NAME }}.ipa DISCORD_VERSION=$(plutil -p Payload/Discord.app/Info.plist | grep CFBundleShortVersionString | cut -d '"' -f 4) echo "DISCORD_VERSION=$DISCORD_VERSION" >> $GITHUB_ENV @@ -154,7 +157,7 @@ jobs: files: | ${{ env.DEB_FILE_NAME }} ${{ env.ROOTLESS_DEB_FILE_NAME }} - Pyoncord.ipa + ${{ env.APP_NAME }}.ipa generate_release_notes: true fail_on_unmatched_files: true token: ${{ env.GITHUB_TOKEN }} @@ -164,11 +167,16 @@ jobs: app-repo: continue-on-error: true runs-on: macos-14 - needs: release-pyoncord + needs: release-app steps: - name: Checkout code uses: actions/checkout@v4 + - name: Extract App Name + run: | + NAME=$(grep '^Name:' control | cut -d ' ' -f 2) + echo "APP_NAME=$NAME" >> $GITHUB_ENV + - name: Download IPA artifact uses: actions/download-artifact@v4 with: @@ -176,15 +184,16 @@ jobs: - name: Update app-repo.json run: | - unzip -q Pyoncord.ipa + unzip -q ${{ env.APP_NAME }}.ipa VERSION=$(plutil -p Payload/Discord.app/Info.plist | grep CFBundleShortVersionString | cut -d '"' -f 4) DATE=$(date -u +"%Y-%m-%d") - IPA_SIZE=$(ls -l Pyoncord.ipa | awk '{print $5}') - NEW_ENTRY=$(jq -n --arg version "$VERSION" --arg date "$DATE" --arg size "$IPA_SIZE" --arg downloadURL "https://github.com/pyoncord/PyoncordTweak/releases/download/v$VERSION/Pyoncord.ipa" '{version: $version, date: $date, size: ($size | tonumber), downloadURL: $downloadURL}') + IPA_SIZE=$(ls -l ${{ env.APP_NAME }}.ipa | awk '{print $5}') + NEW_ENTRY=$(jq -n --arg version "$VERSION" --arg date "$DATE" --arg size "$IPA_SIZE" --arg downloadURL "https://github.com/${{ github.repository }}/releases/download/v$VERSION/${{ env.APP_NAME }}.ipa" '{version: $version, date: $date, size: ($size | tonumber), downloadURL: $downloadURL}') jq --argjson newEntry "$NEW_ENTRY" '.apps[0].versions |= [$newEntry] + .' app-repo.json > temp.json && mv temp.json app-repo.json - uses: EndBug/add-and-commit@v9 with: default_author: github_actions message: "chore: update app-repo.json" - add: app-repo.json \ No newline at end of file + add: app-repo.json +