name: Build Phone APK on: push: branches: [ "main" ] paths-ignore: [ "README.md", "images/**", ".github/*.sh", ".github/workflows/smoke.yml", ".github/workflows/pr-check.yml", ".github/workflows/beta.yml" ] workflow_dispatch: # One build at a time: a slower older build must never finish last and become the "latest" release concurrency: group: phone-build cancel-in-progress: false permissions: contents: write jobs: build: runs-on: ubuntu-latest env: HAS_SIGNING_KEY: ${{ secrets.PHONE_SIGNING_KEY != '' }} steps: - name: Checkout Code uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 # history and tags for the release notes # Phone changes to the MediaServiceCore submodule (Shorts feed) - name: Apply submodule patches run: git -C MediaServiceCore apply --ignore-whitespace --whitespace=nowarn ../.github/patches/mediaservicecore.patch - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' cache: 'gradle' - name: Version name id: get_version run: | sed -i "s/versionName \"\(.*\)\"/versionName \"\1-phone-${{ github.run_number }}\"/" smarttubetv/build.gradle echo "VERSION_NAME=$(grep "versionName" smarttubetv/build.gradle | head -n 1 | awk -F'"' '{print $2}')" >> $GITHUB_OUTPUT # Same key every build, so new APKs install as updates over old ones. - name: Configure signing if: ${{ env.HAS_SIGNING_KEY == 'true' }} run: | echo "${{ secrets.PHONE_SIGNING_KEY }}" | base64 --decode > ${{ github.workspace }}/phone.p12 echo "storePassword=${{ secrets.PHONE_KEY_PASSWORD }}" > keystore.properties echo "keyAlias=smarttubephone" >> keystore.properties echo "keyPassword=${{ secrets.PHONE_KEY_PASSWORD }}" >> keystore.properties echo "storeFile=${{ github.workspace }}/phone.p12" >> keystore.properties - name: Build run: | chmod +x gradlew ./gradlew assembleStphoneRelease - name: Collect APK id: collect run: | mkdir -p out # 32.72-phone-81 -> StreamTube-Phone-32.72.81-arm64.apk (also -arm32 and -universal) FILE_VERSION=$(echo "${{ steps.get_version.outputs.VERSION_NAME }}" | sed 's/-phone-/./') SRC=./smarttubetv/build/outputs/apk/stphone/release for PAIR in arm64:arm64-v8a arm32:armeabi-v7a universal:universal; do ARCH=${PAIR%%:*} cp $SRC/*_${PAIR#*:}.apk "out/StreamTube-Phone-${FILE_VERSION}-${ARCH}.apk" # The same APK under a fixed name: the direct download link and the in-app updater (builds 80+) cp "out/StreamTube-Phone-${FILE_VERSION}-${ARCH}.apk" "out/StreamTube-${ARCH}.apk" done # Builds from before the rename (SmartTube-Phone-arm64.apk) cp out/StreamTube-arm64.apk out/SmartTube-Phone-arm64.apk APK="StreamTube-Phone-${FILE_VERSION}-arm64.apk" echo "APK=$APK" >> $GITHUB_OUTPUT echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_OUTPUT - name: Show signer and version run: | BT=$(ls -d $ANDROID_HOME/build-tools/* | sort -V | tail -n 1) $BT/apksigner verify --print-certs "out/${{ steps.collect.outputs.APK }}" | grep -E "SHA-256|DN" for APK in out/StreamTube-Phone-*.apk; do echo "$APK" $BT/aapt dump badging "$APK" | grep -E "^package|native-code" done ls -l out sha256sum out/*.apk - name: Upload build artifact uses: actions/upload-artifact@v4 with: name: StreamTube_${{ steps.get_version.outputs.VERSION_NAME }} path: out/StreamTube-Phone-*.apk if-no-files-found: error # "What's new" for the release (shown on the app's update screen): app changes since the previous build. No other # apps are named there: phrases like "as in " are taken out of the commit titles. - name: Release notes run: | PREV=$(git describe --tags --abbrev=0 --match 'build-*' HEAD 2>/dev/null || true) { echo "StreamTube: a YouTube client for Android phones, built on SmartTube." echo "" # A table, not a list: the app's update screen shows "- " and "* " lines as changes echo "| APK | For |" echo "|---|---|" echo "| StreamTube-arm64.apk | Almost every phone (64-bit ARM) |" echo "| StreamTube-arm32.apk | Older or budget phones with a 32-bit processor |" echo "| StreamTube-universal.apk | Any device, also x86 emulators and Chromebooks (bigger download) |" echo "" echo "What's new" if [ -n "$PREV" ]; then git log --no-merges --format='- %s' "$PREV..HEAD" | grep -viE '^- (CI|README|Smoke|Emulator)' \ | sed -E "s/[[:space:]]*(exactly[[:space:]]+)?(as|like)[[:space:]]+(in[[:space:]]+)?NewTube('s)?//Ig" \ | grep -vi 'newtube' | head -n 30 || true fi } > release_notes.md cat release_notes.md # Public, sign-in free download: releases/latest/download/StreamTube-.apk (and the old name, for old builds) - name: Publish release uses: softprops/action-gh-release@v2 with: tag_name: build-${{ github.run_number }} name: StreamTube ${{ steps.get_version.outputs.VERSION_NAME }} body_path: release_notes.md files: | out/StreamTube-Phone-*.apk out/StreamTube-arm64.apk out/StreamTube-arm32.apk out/StreamTube-universal.apk out/SmartTube-Phone-arm64.apk make_latest: true