From 755b752a95a0d1c15662713b38a7476b746a1e95 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Tue, 16 Apr 2024 12:29:39 +0500 Subject: [PATCH] Reverted: Revert "ci: use termux/upload-release-actions to attach debug builds to new releases" This reverts commit 2ac7fd1e565872d10b91157022485c13ab179524. Do not use `upload-release-action` for uploading artifacts and generating checksum and instead keep using standard `sha256sum` and internal github tools. `upload-release-action` also generates checksum in the wrong format, check https://github.com/termux/termux-app/pull/3241#discussion_r1106019790. --- .../attach_debug_apks_to_release.yml | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/.github/workflows/attach_debug_apks_to_release.yml b/.github/workflows/attach_debug_apks_to_release.yml index 8c1ff0e015..a17b326443 100644 --- a/.github/workflows/attach_debug_apks_to_release.yml +++ b/.github/workflows/attach_debug_apks_to_release.yml @@ -6,7 +6,7 @@ on: - published jobs: - build: + attach-apks: runs-on: ubuntu-latest strategy: fail-fast: false @@ -21,15 +21,23 @@ jobs: with: ref: ${{ env.GITHUB_REF }} - - name: Build + - name: Build and attach APKs to release shell: bash {0} env: PACKAGE_VARIANT: ${{ matrix.package_variant }} run: | + exit_on_error() { + echo "$1" + echo "Deleting '$RELEASE_VERSION_NAME' release and '$GITHUB_REF' tag" + hub release delete "$RELEASE_VERSION_NAME" + git push --delete origin "$GITHUB_REF" + exit 1 + } + + echo "Setting vars" RELEASE_VERSION_NAME="${GITHUB_REF/refs\/tags\//}" if ! printf "%s" "${RELEASE_VERSION_NAME/v/}" | grep -qP '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'; then - echo "The versionName '${RELEASE_VERSION_NAME/v/}' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html." - exit 1 + exit_on_error "The versionName '${RELEASE_VERSION_NAME/v/}' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html." fi APK_DIR_PATH="./app/build/outputs/apk/debug" @@ -39,35 +47,38 @@ jobs: echo "Building APKs for 'APK_VERSION_TAG' release" export TERMUX_APK_VERSION_TAG="$APK_VERSION_TAG" # Used by app/build.gradle export TERMUX_PACKAGE_VARIANT="${{ env.PACKAGE_VARIANT }}" # Used by app/build.gradle - ./gradlew assembleDebug + if ! ./gradlew assembleDebug; then + exit_on_error "Build failed for '$APK_VERSION_TAG' release." + fi echo "Validating APKs" for abi in universal arm64-v8a armeabi-v7a x86_64 x86; do if ! test -f "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk"; then files_found="$(ls "$APK_DIR_PATH")" - echo "Failed to find built APK at '$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk'. Files found: "$'\n'"$files_found" - exit 1 + exit_on_error "Failed to find built APK at '$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk'. Files found: "$'\n'"$files_found" fi done - - name: Upload APKs to GitHub artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.package_variant }} - path: ./app/build/outputs/apk/debug/*.apk - upload: - runs-on: ubuntu-latest - needs: build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Download artifact - uses: actions/download-artifact@v4 - - name: Upload APKs to release - uses: termux/upload-release-action@v4.2.0 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: "**/*.apk" - file_glob: true - release_name: - tag: ${{ github.event.release.tag_name }} - checksums: sha256,sha512,md5 + + echo "Generating sha25sums file" + if ! (cd "$APK_DIR_PATH"; sha256sum \ + "${APK_BASENAME_PREFIX}_universal.apk" \ + "${APK_BASENAME_PREFIX}_arm64-v8a.apk" \ + "${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \ + "${APK_BASENAME_PREFIX}_x86_64.apk" \ + "${APK_BASENAME_PREFIX}_x86.apk" \ + > "${APK_BASENAME_PREFIX}_sha256sums"); then + exit_on_error "Generate sha25sums failed for '$APK_VERSION_TAG' release." + fi + + echo "Attaching APKs to github release" + if ! hub release edit \ + -m "" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_universal.apk" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_arm64-v8a.apk" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86_64.apk" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86.apk" \ + -a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_sha256sums" \ + "$RELEASE_VERSION_NAME"; then + exit_on_error "Attach APKs to release failed for '$APK_VERSION_TAG' release." + fi