From 2e21c8d1bb0438bfb877a940cf0111fd64df8dbc Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 28 Nov 2021 15:46:06 -0500 Subject: [PATCH] Sign APKs in individual jobs --- .github/scripts/create-repo.sh | 16 +++++--- .github/scripts/sign-apks.sh | 11 +---- .github/workflows/build_pull_request.yml | 15 ++----- .github/workflows/build_push.yml | 52 ++++++++++++------------ 4 files changed, 42 insertions(+), 52 deletions(-) diff --git a/.github/scripts/create-repo.sh b/.github/scripts/create-repo.sh index 37f228bb6..23de7afd6 100755 --- a/.github/scripts/create-repo.sh +++ b/.github/scripts/create-repo.sh @@ -1,18 +1,24 @@ #!/bin/bash set -e +shopt -s globstar nullglob extglob TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)" mkdir -p repo/apk mkdir -p repo/icon - -cp -f apk/* repo/apk - cd repo -APKS=( ../apk/*".apk" ) +APKS=( ../../apk/**/*".apk" ) + +# Fail if too little extensions seem to have been built +if [ "${#APKS[@]}" -le "1" ]; then + echo "Insufficient amount of APKs found. Please check the project configuration." + exit 1 +fi for APK in ${APKS[@]}; do + cp $APK ./apk + FILENAME=$(basename ${APK}) BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)" @@ -31,7 +37,7 @@ for APK in ${APKS[@]}; do unzip -p $APK $ICON > icon/${FILENAME%.*}.png SOURCE_INFO=$(jq ".[\"$PKGNAME\"]" < ../output.json) - + # Fixes the language code without needing to update the packages. SOURCE_LEN=$(echo $SOURCE_INFO | jq length) diff --git a/.github/scripts/sign-apks.sh b/.github/scripts/sign-apks.sh index 34775f70b..3ec8f01ea 100755 --- a/.github/scripts/sign-apks.sh +++ b/.github/scripts/sign-apks.sh @@ -4,17 +4,8 @@ shopt -s globstar nullglob extglob TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)" -# Get APKs from previous jobs' artifacts -cp -R ~/apk-artifacts/ $PWD APKS=( **/*".apk" ) - -# Fail if too little extensions seem to have been built -if [ "${#APKS[@]}" -le "1" ]; then - echo "Insufficient amount of APKs found. Please check the project configuration." - exit 1 -else - echo "Signing ${#APKS[@]} APKs" -fi +echo "Signing ${#APKS[@]} APKs" # Take base64 encoded key input and put it into a file STORE_PATH=$PWD/signingkey.jks diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 437998457..3e429b0d1 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -36,25 +36,19 @@ jobs: cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties - name: Generate sources from the multi-source library - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "true" with: arguments: :multisrc:generateExtensions - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true - name: Build "${{ matrix.lang }}" extensions - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "true" CI_MATRIX_LANG: ${{ matrix.lang }} with: arguments: assembleRelease - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true build_individual: name: Build individual modules @@ -78,12 +72,9 @@ jobs: cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties - name: Build "${{ matrix.lang }}" extensions - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "false" CI_MATRIX_LANG: ${{ matrix.lang }} with: arguments: assembleRelease - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index afb084814..d0d646cb4 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -44,31 +44,35 @@ jobs: cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties - name: Generate sources from the multi-source library - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "true" with: arguments: :multisrc:generateExtensions - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true - name: Build "${{ matrix.lang }}" extensions - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "true" CI_MATRIX_LANG: ${{ matrix.lang }} with: arguments: assembleRelease - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true + + - name: Sign APKs + if: "github.repository == 'tachiyomiorg/tachiyomi-extensions'" + run: | + ./.github/scripts/sign-apks.sh \ + ${{ secrets.SIGNING_KEY }} \ + ${{ secrets.ALIAS }} \ + ${{ secrets.KEY_STORE_PASSWORD }} \ + ${{ secrets.KEY_PASSWORD }} - name: Upload "${{ matrix.lang }}" APKs + if: "github.repository == 'tachiyomiorg/tachiyomi-extensions'" uses: actions/upload-artifact@v2 with: name: "multisrc-${{ matrix.lang }}-apks" - path: "**/*.apk" + path: "apk/*.apk" retention-days: 1 build_individual: @@ -93,21 +97,28 @@ jobs: cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties - name: Build "${{ matrix.lang }}" extensions - uses: gradle/gradle-command-action@v1 + uses: gradle/gradle-command-action@v2 env: CI_MULTISRC: "false" CI_MATRIX_LANG: ${{ matrix.lang }} with: arguments: assembleRelease - distributions-cache-enabled: true - dependencies-cache-enabled: true - configuration-cache-enabled: true + + - name: Sign APKs + if: "github.repository == 'tachiyomiorg/tachiyomi-extensions'" + run: | + ./.github/scripts/sign-apks.sh \ + ${{ secrets.SIGNING_KEY }} \ + ${{ secrets.ALIAS }} \ + ${{ secrets.KEY_STORE_PASSWORD }} \ + ${{ secrets.KEY_PASSWORD }} - name: Upload "${{ matrix.lang }}" APKs + if: "github.repository == 'tachiyomiorg/tachiyomi-extensions'" uses: actions/upload-artifact@v2 with: name: "individual-${{ matrix.lang }}-apks" - path: "**/*.apk" + path: "apk/*.apk" retention-days: 1 publish_repo: @@ -121,7 +132,7 @@ jobs: - name: Download APK artifacts uses: actions/download-artifact@v2 with: - path: ~/apk-artifacts + path: apk - name: Checkout master branch uses: actions/checkout@v2 @@ -134,21 +145,12 @@ jobs: with: java-version: 11 - - name: Sign APKs - run: | - cd master - ./.github/scripts/sign-apks.sh \ - ${{ secrets.SIGNING_KEY }} \ - ${{ secrets.ALIAS }} \ - ${{ secrets.KEY_STORE_PASSWORD }} \ - ${{ secrets.KEY_PASSWORD }} - - name: Run inspector run: | cd master INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/tachiyomiorg/tachiyomi-extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')" curl -L "$INSPECTOR_LINK" -o ./Inspector.jar - java -jar ./Inspector.jar "apk" "output.json" "tmp" + java -jar ./Inspector.jar "../apk" "output.json" "tmp" - name: Create repo artifacts run: |