Skip to content

Commit

Permalink
Fix release APK build process (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
javulticat committed Jan 4, 2024
1 parent 4cf8911 commit 6a238e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
steps:
- name: Checkout code repository
uses: actions/checkout@v4
- name: Decode keystore
id: keystore
uses: timheuer/base64-to-file@v1
with:
fileName: keystore.jks
encodedString: ${{ secrets.ENCODED_KEYSTORE }}
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand All @@ -24,6 +30,10 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build release APK
env:
KEYSTORE_FILE: ${{ steps.keystore.outputs.filePath }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
run: ./gradlew clean assembleRelease
- name: Upload APK artifact
uses: actions/upload-artifact@v4
Expand Down
24 changes: 20 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ android {
}
}

signingConfigs {
release {
if (System.getenv("KEYSTORE_FILE")) {
storeFile file(System.getenv("KEYSTORE_FILE"))
storePassword System.getenv("KEYSTORE_PASSWORD")
keyAlias System.getenv("KEY_ALIAS")
keyPassword System.getenv("KEYSTORE_PASSWORD")
}
}
}

buildTypes {
debug {
debuggable true

// suffix the app id and the app name with git branch name
def workingBranch = getGitWorkingBranch()
def normalizedWorkingBranch = workingBranch.replaceFirst("^[^A-Za-z]+", "").replaceAll("[^0-9A-Za-z]+", "")
if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") {
if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev" || workingBranch == "sponsorblock") {
// default values when branch name could not be determined or is master or dev
applicationIdSuffix ".debug"
resValue "string", "app_name", "NewPipe SponsorBlock Debug"
Expand All @@ -51,6 +62,9 @@ android {
}

release {
if (System.getenv("KEYSTORE_FILE")) {
signingConfig signingConfigs.release
}
if (System.properties.containsKey('packageSuffix')) {
applicationIdSuffix System.getProperty('packageSuffix')
resValue "string", "app_name", "NewPipe SponsorBlock" + System.getProperty('packageSuffix')
Expand All @@ -60,10 +74,12 @@ android {
shrinkResources false // disabled to fix F-Droid's reproducible build
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
archivesBaseName = "NewPipe_x_SponsorBlock"
android.applicationVariants.all { variant ->
applicationVariants.all { variant ->
variant.outputs.all { output ->
def forkRevision = 2
outputFileName = "${archivesBaseName}_v${variant.versionName}-${forkRevision}.apk"
if (variant.name == "release") {
def forkRevision = 2
outputFileName = "${archivesBaseName}_v${variant.versionName}-${forkRevision}.apk"
}
}
}
}
Expand Down

0 comments on commit 6a238e2

Please sign in to comment.