2024-12-15 02:31:56 +00:00
|
|
|
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:
|
2024-12-15 03:01:19 +00:00
|
|
|
|
|
|
|
- name: Checkout Repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-12-15 02:31:56 +00:00
|
|
|
# Step 1: Download the latest release tarball
|
|
|
|
- name: Download Latest Release
|
|
|
|
run: |
|
2024-12-15 02:35:57 +00:00
|
|
|
curl -s https://api.github.com/repos/jellyfin/jellyfin-androidtv/releases/latest \
|
2024-12-15 02:31:56 +00:00
|
|
|
| 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: |
|
2024-12-15 04:41:11 +00:00
|
|
|
rm -r app-release/app/src/main/res/mipmap-*
|
2024-12-15 02:57:45 +00:00
|
|
|
cp -r res/* app-release/app/src/main/res
|
2024-12-15 02:31:56 +00:00
|
|
|
|
2024-12-15 15:16:29 +00:00
|
|
|
# Step 5: Changes
|
2024-12-15 02:31:56 +00:00
|
|
|
- name: Update strings.xml
|
|
|
|
run: |
|
2024-12-15 02:57:45 +00:00
|
|
|
sed -i 's/Jellyfin/AlaskarTV/g' app-release/app/src/main/res/values/strings.xml
|
2024-12-15 02:31:56 +00:00
|
|
|
|
|
|
|
- name: Update build.gradle.kts
|
|
|
|
env:
|
|
|
|
APPLICATION_ID: ${{ env.APPLICATION_ID }}
|
|
|
|
VERSION_NAME: ${{ env.VERSION_NAME }}
|
|
|
|
VERSION_CODE: ${{ env.VERSION_CODE }}
|
|
|
|
run: |
|
2024-12-15 15:45:40 +00:00
|
|
|
sed -i 's/applicationId = namespace/applicationId = "'"$APPLICATION_ID"'"/' app-release/app/build.gradle.kts
|
|
|
|
sed -i 's/versionName = .*/versionName = "'"$VERSION_NAME"'"/' app-release/app/build.gradle.kts
|
2024-12-15 02:57:45 +00:00
|
|
|
sed -i "s/versionCode = .*/versionCode = $VERSION_CODE/" app-release/app/build.gradle.kts
|
2024-12-15 15:16:29 +00:00
|
|
|
sed -i "s/setProperty(\"archivesBaseName\", \".*\")/setProperty(\"archivesBaseName\", \"alaskartv-androidtv-v$VERSION_NAME\")/" app-release/app/build.gradle.kts
|
2024-12-15 02:31:56 +00:00
|
|
|
|
|
|
|
- name: Update about.kt
|
|
|
|
run: |
|
2024-12-15 21:57:45 +00:00
|
|
|
sed -i '0,/link {/{
|
|
|
|
n; s/title = ".*"/title = "AlaskarTV app version"/
|
2024-12-15 21:54:09 +00:00
|
|
|
n; s/content = ".*"/content = "alaskartv-androidtv ${BuildConfig.VERSION_NAME} ${BuildConfig.BUILD_TYPE}"/
|
|
|
|
n; s/icon = .*/icon = R.drawable.app_icon_foreground_monochrome/
|
|
|
|
}' app-release/app/src/main/java/org/jellyfin/androidtv/ui/preference/category/about.kt
|
2024-12-15 03:54:32 +00:00
|
|
|
|
2024-12-15 15:16:29 +00:00
|
|
|
- name: Update UserPreferences.kt
|
|
|
|
run: |
|
|
|
|
sed -i 's/booleanPreference("trick_play_enabled", false)/booleanPreference("trick_play_enabled", true)/' \
|
|
|
|
app-release/app/src/main/java/org/jellyfin/androidtv/preference/UserPreferences.kt
|
2024-12-15 03:54:32 +00:00
|
|
|
|
2024-12-15 15:16:29 +00:00
|
|
|
sed -i 's/enumPreference("app_theme", AppTheme.DARK)/enumPreference("app_theme", AppTheme.MUTED_PURPLE)/' \
|
|
|
|
app-release/app/src/main/java/org/jellyfin/androidtv/preference/UserPreferences.kt
|
2024-12-15 03:54:32 +00:00
|
|
|
|
2024-12-15 04:40:29 +00:00
|
|
|
- name: Check files
|
|
|
|
run: |
|
2024-12-15 15:16:29 +00:00
|
|
|
echo "Updated Changes"
|
2024-12-15 03:54:32 +00:00
|
|
|
cat app-release/app/build.gradle.kts
|
2024-12-15 04:40:29 +00:00
|
|
|
cat app-release/app/src/main/res/values/strings.xml
|
2024-12-15 15:16:29 +00:00
|
|
|
cat app-release/app/src/main/java/org/jellyfin/androidtv/preference/UserPreferences.kt
|
|
|
|
cat app-release/app/src/main/java/org/jellyfin/androidtv/ui/preference/category/about.kt
|
2024-12-15 04:40:29 +00:00
|
|
|
|
|
|
|
|
2024-12-15 02:31:56 +00:00
|
|
|
|
2024-12-15 15:16:29 +00:00
|
|
|
# Step 6: Set up Java and Gradle
|
2024-12-15 02:31:56 +00:00
|
|
|
- name: Set up Java
|
2024-12-15 04:18:13 +00:00
|
|
|
uses: actions/setup-java@v4
|
2024-12-15 02:31:56 +00:00
|
|
|
with:
|
2024-12-15 14:17:17 +00:00
|
|
|
distribution: temurin
|
2024-12-15 14:46:10 +00:00
|
|
|
java-version: 21
|
2024-12-15 04:26:12 +00:00
|
|
|
|
|
|
|
- name: Cache Gradle dependencies
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: ~/.gradle/caches
|
2024-12-15 21:03:44 +00:00
|
|
|
key: ${{ runner.os }}-gradle-21release-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
2024-12-15 04:26:12 +00:00
|
|
|
restore-keys: |
|
2024-12-15 21:03:44 +00:00
|
|
|
${{ runner.os }}-gradle-21release-
|
2024-12-15 02:31:56 +00:00
|
|
|
|
2024-12-15 15:16:29 +00:00
|
|
|
# Step 7: Build the APK
|
2024-12-15 02:31:56 +00:00
|
|
|
- name: Build APK
|
|
|
|
run: |
|
|
|
|
cd app-release
|
2024-12-15 21:03:44 +00:00
|
|
|
./gradlew assembleRelease
|
2024-12-15 02:31:56 +00:00
|
|
|
|
2024-12-15 03:30:37 +00:00
|
|
|
- name: Find APK Files
|
|
|
|
run: find app-release -name "*.apk"
|
2024-12-15 02:31:56 +00:00
|
|
|
|
2024-12-15 21:03:44 +00:00
|
|
|
# Step 8: Sign
|
|
|
|
- name: Decode Keystore
|
|
|
|
env:
|
|
|
|
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
|
|
|
|
run: |
|
|
|
|
echo "$KEYSTORE_FILE" | base64 -d > keystore.jks
|
2024-12-15 05:01:07 +00:00
|
|
|
|
2024-12-15 21:54:09 +00:00
|
|
|
# # Step 9: Sign the APK
|
|
|
|
# - name: Sign APK
|
|
|
|
# env:
|
|
|
|
# KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
|
|
# KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
|
|
|
|
# KEY_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
|
|
# run: |
|
|
|
|
# jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \
|
|
|
|
# -keystore keystore.jks \
|
|
|
|
# -storepass "$KEYSTORE_PASSWORD" \
|
|
|
|
# -keypass "$KEYSTORE_PASSWORD" \
|
|
|
|
# app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-unsigned.apk \
|
|
|
|
# "$KEYSTORE_ALIAS"
|
|
|
|
#
|
|
|
|
# # Step 9: Verify APK Signature
|
|
|
|
# - name: Verify APK Signature
|
|
|
|
# run: |
|
|
|
|
# jarsigner -verify -verbose -certs \
|
|
|
|
# app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-unsigned.apk
|
|
|
|
|
|
|
|
- name: Sign APK with apksigner
|
2024-12-15 21:03:44 +00:00
|
|
|
env:
|
|
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
2024-12-15 21:21:05 +00:00
|
|
|
KEY_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
2024-12-15 21:54:09 +00:00
|
|
|
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
|
2024-12-15 21:03:44 +00:00
|
|
|
run: |
|
2024-12-15 21:54:09 +00:00
|
|
|
apksigner sign --ks keystore.jks \
|
|
|
|
--ks-key-alias "$KEYSTORE_ALIAS" \
|
|
|
|
--ks-pass env:KEYSTORE_PASSWORD \
|
|
|
|
--key-pass env:KEY_PASSWORD \
|
|
|
|
--out app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release.apk \
|
|
|
|
app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-unsigned.apk
|
|
|
|
|
2024-12-15 21:03:44 +00:00
|
|
|
- name: Verify APK Signature
|
|
|
|
run: |
|
2024-12-15 21:54:09 +00:00
|
|
|
apksigner verify --verbose app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release.apk
|
2024-12-15 21:03:44 +00:00
|
|
|
|
|
|
|
# Step 10: Rename Signed APK
|
|
|
|
- name: Rename Signed APK
|
|
|
|
run: |
|
|
|
|
mv app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-unsigned.apk \
|
|
|
|
app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-signed.apk
|
|
|
|
|
|
|
|
# Step 11: Upload Signed APK as Artifact
|
|
|
|
- name: Upload Signed APK
|
2024-12-15 04:40:29 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2024-12-15 02:31:56 +00:00
|
|
|
with:
|
2024-12-15 21:03:44 +00:00
|
|
|
name: signed-apk
|
|
|
|
path: app-release/app/build/outputs/apk/release/alaskartv-androidtv-v${{ env.VERSION_NAME }}-release-signed.apk
|
|
|
|
|
2024-12-15 04:53:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|