v0.118.1 #2
Workflow file for this run
This file contains 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: Attach Debug APKs To Release | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
attach-apks: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ env.GITHUB_REF }} | |
- name: Build and attach APKs to release | |
shell: bash {0} | |
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 | |
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" | |
APK_VERSION_TAG="$RELEASE_VERSION_NAME+github-debug" | |
APK_BASENAME_PREFIX="termux-app_$APK_VERSION_TAG" | |
echo "Building APKs for '$RELEASE_VERSION_NAME' release" | |
export TERMUX_APK_VERSION_TAG="$APK_VERSION_TAG" # Used by app/build.gradle | |
if ! ./gradlew assembleDebug; then | |
exit_on_error "Build failed for '$RELEASE_VERSION_NAME' 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")" | |
exit_on_error "Failed to find built APK at '$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk'. Files found: "$'\n'"$files_found" | |
fi | |
done | |
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 '$RELEASE_VERSION_NAME' release." | |
fi | |
echo "Attaching APKs to github release" | |
if ! gh release upload "$RELEASE_VERSION_NAME" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_universal.apk" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_arm64-v8a.apk" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86_64.apk" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86.apk" \ | |
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_sha256sums" \ | |
; then | |
exit_on_error "Attach APKs to release failed for '$RELEASE_VERSION_NAME' release." | |
fi |