116 lines
4.6 KiB
YAML
116 lines
4.6 KiB
YAML
name: Build and Customize Android App from Release
|
|
|
|
on:
|
|
workflow_dispatch: # Allows manual triggering of the workflow
|
|
|
|
jobs:
|
|
build-and-customize:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Step 1: Download the latest release tarball
|
|
- name: Download Latest Release
|
|
run: |
|
|
curl -s https://api.github.com/repos/jellyfin/jellyfin-androidtv/releases/latest \
|
|
| jq -r '.tarball_url' \
|
|
| xargs curl -L -o latest-release.tar.gz
|
|
|
|
# Step 2: Extract the tarball
|
|
- name: Extract Release Tarball
|
|
run: |
|
|
mkdir -p app-release
|
|
tar -xzf latest-release.tar.gz --strip-components=1 -C app-release
|
|
|
|
# Step 3: Parse version.txt
|
|
- name: Parse version.txt
|
|
id: parse_version
|
|
run: |
|
|
# Read values from version.txt
|
|
APPLICATION_ID=$(grep '^APPLICATION_ID=' version.txt | cut -d '=' -f 2)
|
|
VERSION_NAME=$(grep '^VERSION_NAME=' version.txt | cut -d '=' -f 2)
|
|
VERSION_CODE=$(grep '^VERSION_CODE=' version.txt | cut -d '=' -f 2)
|
|
|
|
# Export values as environment variables
|
|
echo "APPLICATION_ID=$APPLICATION_ID" >> $GITHUB_ENV
|
|
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
|
|
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
|
|
|
|
# Step 4: Replace assets in app/src/main/
|
|
- name: Replace Assets
|
|
run: |
|
|
cp -r res/mipmap/* app-release/app/src/main/res/mipmap/
|
|
cp -r res/drawable/* app-release/app/src/main/res/drawable/
|
|
cp -r res/drawable-v24/* app-release/app/src/main/res/drawable-v24/
|
|
|
|
# Step 5: Replace strings in app/src/main/res/values/strings.xml
|
|
- name: Update strings.xml
|
|
run: |
|
|
sed -i 's/Jellyfin/AlaskarTV/g' app-release/app/src/main/res/values/strings.xml
|
|
|
|
# Step 6: Update build.gradle.kts with version info
|
|
- name: Update build.gradle.kts
|
|
env:
|
|
APPLICATION_ID: ${{ env.APPLICATION_ID }}
|
|
VERSION_NAME: ${{ env.VERSION_NAME }}
|
|
VERSION_CODE: ${{ env.VERSION_CODE }}
|
|
run: |
|
|
sed -i "s/applicationId = \".*\"/applicationId = \"$APPLICATION_ID\"/" app-release/app/build.gradle.kts
|
|
sed -i "s/versionName = \".*\"/versionName = \"$VERSION_NAME\"/" app-release/app/build.gradle.kts
|
|
sed -i "s/versionCode = .*/versionCode = $VERSION_CODE/" app-release/app/build.gradle.kts
|
|
|
|
# Step 7: Update about.kt
|
|
- name: Update about.kt
|
|
run: |
|
|
sed -i 's/title = ".*"/title = "AlaskarTV app version"/' app-release/app/src/main/java/org/jellyfin/androidtv/ui/preference/category/about.kt
|
|
sed -i 's/content = ".*"/content = "alaskartv-androidtv ${BuildConfig.VERSION_NAME} ${BuildConfig.BUILD_TYPE}"/' app-release/app/src/main/java/org/jellyfin/androidtv/ui/preference/category/about.kt
|
|
sed -i 's/icon = .*/icon = R.drawable.app_icon_foreground_monochrome/' app-release/app/src/main/java/org/jellyfin/androidtv/ui/preference/category/about.kt
|
|
|
|
# Step 8: Set up Java and Gradle
|
|
- name: Set up Java
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
|
|
- name: Cache Gradle dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.gradle/caches
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
|
|
# Step 9: Build the APK
|
|
- name: Build APK
|
|
run: |
|
|
cd app-release
|
|
./gradlew assembleRelease
|
|
|
|
|
|
# Step 10: Upload APK as Artifact
|
|
- name: Upload APK as Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: unsigned-apk
|
|
path: app-release/app/build/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release.apk
|
|
|
|
# # Step 10: Sign the APK
|
|
# - name: Sign APK
|
|
# env:
|
|
# KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
# KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
|
|
# KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
|
|
# run: |
|
|
# jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \
|
|
# -keystore $KEYSTORE_FILE \
|
|
# app-release/app/build/outputs/apk/release/app-release-unsigned.apk \
|
|
# $KEYSTORE_ALIAS
|
|
|
|
# # Step 11: (Optional) Upload to Play Store
|
|
# - name: Upload to Play Store
|
|
# uses: r0adkll/upload-google-play@v1
|
|
# with:
|
|
# serviceAccountJson: ${{ secrets.PLAY_STORE_SERVICE_ACCOUNT }}
|
|
# packageName: ${{ env.APPLICATION_ID }}
|
|
# releaseFiles: app-release/app/build/outputs/apk/release/app-release.apk
|
|
|