|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - master
|
7 |
| - - android-10 |
8 | 7 | pull_request:
|
9 | 8 | branches:
|
10 | 9 | - master
|
11 |
| - - android-10 |
12 | 10 |
|
13 | 11 | jobs:
|
14 | 12 | build:
|
15 | 13 | runs-on: ubuntu-latest
|
16 | 14 | steps:
|
17 |
| - - name: Clone repository |
18 |
| - uses: actions/checkout@v2 |
19 |
| - - name: Build |
20 |
| - run: | |
21 |
| - ./gradlew assembleDebug |
22 |
| - - name: Store generated universal APK file |
23 |
| - uses: actions/upload-artifact@v2 |
24 |
| - with: |
25 |
| - name: termux-app-universal |
26 |
| - path: | |
27 |
| - ./app/build/outputs/apk/debug/termux-app-universal-debug.apk |
28 |
| - ./app/build/outputs/apk/debug/output-metadata.json |
29 |
| - - name: Store generated arm64-v8a APK file |
30 |
| - uses: actions/upload-artifact@v2 |
31 |
| - with: |
32 |
| - name: termux-app-arm64-v8a |
33 |
| - path: | |
34 |
| - ./app/build/outputs/apk/debug/termux-app-arm64-v8a-debug.apk |
35 |
| - ./app/build/outputs/apk/debug/output-metadata.json |
36 |
| - - name: Store generated armeabi-v7a APK file |
37 |
| - uses: actions/upload-artifact@v2 |
38 |
| - with: |
39 |
| - name: termux-app-armeabi-v7a |
40 |
| - path: | |
41 |
| - ./app/build/outputs/apk/debug/termux-app-armeabi-v7a-debug.apk |
42 |
| - ./app/build/outputs/apk/debug/output-metadata.json |
43 |
| - - name: Store generated x86_64 APK file |
44 |
| - uses: actions/upload-artifact@v2 |
45 |
| - with: |
46 |
| - name: termux-app-x86_64 |
47 |
| - path: | |
48 |
| - ./app/build/outputs/apk/debug/termux-app-x86_64-debug.apk |
49 |
| - ./app/build/outputs/apk/debug/output-metadata.json |
50 |
| - - name: Store generated x86 APK file |
51 |
| - uses: actions/upload-artifact@v2 |
52 |
| - with: |
53 |
| - name: termux-app-x86 |
54 |
| - path: | |
55 |
| - ./app/build/outputs/apk/debug/termux-app-x86-debug.apk |
56 |
| - ./app/build/outputs/apk/debug/output-metadata.json |
| 15 | + - name: Clone repository |
| 16 | + uses: actions/checkout@v2 |
| 17 | + |
| 18 | + - name: Build APKs |
| 19 | + shell: bash {0} |
| 20 | + run: | |
| 21 | + exit_on_error() { echo "$1"; exit 1; } |
| 22 | +
|
| 23 | + echo "Setting vars" |
| 24 | + # Set RELEASE_VERSION_NAME to "<CURRENT_VERSION_NAME>+<last_commit_hash>" |
| 25 | + CURRENT_VERSION_NAME_REGEX='\s+versionName "([^"]+)"$' |
| 26 | + CURRENT_VERSION_NAME="$(grep -m 1 -E "$CURRENT_VERSION_NAME_REGEX" ./app/build.gradle | sed -r "s/$CURRENT_VERSION_NAME_REGEX/\1/")" |
| 27 | + RELEASE_VERSION_NAME="v$CURRENT_VERSION_NAME+${GITHUB_SHA:0:7}" # The "+" is necessary so that versioning precedence is not affected |
| 28 | + 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 |
| 29 | + 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." |
| 30 | + fi |
| 31 | +
|
| 32 | + APK_DIR_PATH="./app/build/outputs/apk/debug" |
| 33 | + APK_VERSION_TAG="$RELEASE_VERSION_NAME-github-debug" # Note the "-", GITHUB_SHA will already have "+" before it |
| 34 | + APK_BASENAME_PREFIX="termux-app_$APK_VERSION_TAG" |
| 35 | +
|
| 36 | + # Used by attachment steps later |
| 37 | + echo "APK_DIR_PATH=$APK_DIR_PATH" >> $GITHUB_ENV |
| 38 | + echo "APK_VERSION_TAG=$APK_VERSION_TAG" >> $GITHUB_ENV |
| 39 | + echo "APK_BASENAME_PREFIX=$APK_BASENAME_PREFIX" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + echo "Building APKs for '$RELEASE_VERSION_NAME' build" |
| 42 | + export TERMUX_APP_VERSION_NAME="${RELEASE_VERSION_NAME/v/}" # Used by app/build.gradle |
| 43 | + export TERMUX_APK_VERSION_TAG="$APK_VERSION_TAG" # Used by app/build.gradle |
| 44 | + if ! ./gradlew assembleDebug; then |
| 45 | + exit_on_error "Build failed for '$RELEASE_VERSION_NAME' build." |
| 46 | + fi |
| 47 | +
|
| 48 | + echo "Validating APKs" |
| 49 | + for abi in universal arm64-v8a armeabi-v7a x86_64 x86; do |
| 50 | + if ! test -f "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk"; then |
| 51 | + files_found="$(ls "$APK_DIR_PATH")" |
| 52 | + exit_on_error "Failed to find built APK at '$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk'. Files found: "$'\n'"$files_found" |
| 53 | + fi |
| 54 | + done |
| 55 | +
|
| 56 | + echo "Generating sha25sums file" |
| 57 | + if ! (cd "$APK_DIR_PATH"; sha256sum \ |
| 58 | + "${APK_BASENAME_PREFIX}_universal.apk" \ |
| 59 | + "${APK_BASENAME_PREFIX}_arm64-v8a.apk" \ |
| 60 | + "${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \ |
| 61 | + "${APK_BASENAME_PREFIX}_x86_64.apk" \ |
| 62 | + "${APK_BASENAME_PREFIX}_x86.apk" \ |
| 63 | + > sha256sums); then |
| 64 | + exit_on_error "Generate sha25sums failed for '$RELEASE_VERSION_NAME' release." |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Attach universal APK file |
| 68 | + uses: actions/upload-artifact@v2 |
| 69 | + with: |
| 70 | + name: ${{ env.APK_BASENAME_PREFIX }}_universal |
| 71 | + path: | |
| 72 | + ${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_universal.apk |
| 73 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
| 74 | +
|
| 75 | + - name: Attach arm64-v8a APK file |
| 76 | + uses: actions/upload-artifact@v2 |
| 77 | + with: |
| 78 | + name: ${{ env.APK_BASENAME_PREFIX }}_arm64-v8a |
| 79 | + path: | |
| 80 | + ${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_arm64-v8a.apk |
| 81 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
| 82 | +
|
| 83 | + - name: Attach armeabi-v7a APK file |
| 84 | + uses: actions/upload-artifact@v2 |
| 85 | + with: |
| 86 | + name: ${{ env.APK_BASENAME_PREFIX }}_armeabi-v7a |
| 87 | + path: | |
| 88 | + ${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_armeabi-v7a.apk |
| 89 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
| 90 | +
|
| 91 | + - name: Attach x86_64 APK file |
| 92 | + uses: actions/upload-artifact@v2 |
| 93 | + with: |
| 94 | + name: ${{ env.APK_BASENAME_PREFIX }}_x86_64 |
| 95 | + path: | |
| 96 | + ${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_x86_64.apk |
| 97 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
| 98 | +
|
| 99 | + - name: Attach x86 APK file |
| 100 | + uses: actions/upload-artifact@v2 |
| 101 | + with: |
| 102 | + name: ${{ env.APK_BASENAME_PREFIX }}_x86 |
| 103 | + path: | |
| 104 | + ${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_x86.apk |
| 105 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
| 106 | +
|
| 107 | + - name: Attach sha256sums file |
| 108 | + uses: actions/upload-artifact@v2 |
| 109 | + with: |
| 110 | + name: sha256sums |
| 111 | + path: | |
| 112 | + ${{ env.APK_DIR_PATH }}/sha256sums |
| 113 | + ${{ env.APK_DIR_PATH }}/output-metadata.json |
0 commit comments