Skip to content

Commit

Permalink
Feat: Adds possibility to use PR number as version code (#652)
Browse files Browse the repository at this point in the history
Co-authored-by: Simone Basso <[email protected]>
  • Loading branch information
aanorbel and bassosimone committed Feb 9, 2024
1 parent 6af25fd commit 5658922
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/firebase-app-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,30 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
- name: Resolve PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
# Can be "open", "closed", or "all". Defaults to "open".
state: open
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: build release
- name: Build `DevFullDebug` variant
if: success() && steps.findPr.outputs.number
run: ./gradlew clean assembleDevFullDebug
- name: upload artifact to Firebase App Distribution
env:
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- name: Upload artifact to Firebase App Distribution
uses: wzieba/[email protected]
id: uploadArtifact
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: app/build/outputs/apk/devFull/debug/app-dev-full-debug.apk
file: app/build/outputs/apk/devFull/debug/app-dev-full-debug.apk
- name: Write Summary
run: |
echo "View this release in the Firebase console: ${{ steps.uploadArtifact.outputs.FIREBASE_CONSOLE_URI }}" >> $GITHUB_STEP_SUMMARY
20 changes: 15 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ android {
dev {
dimension 'testing'
applicationIdSuffix '.dev'
versionNameSuffix "-beta.1"
versionCode versionCodeDate()
versionNameSuffix resolveVersionSuffix('beta')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-dev"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.dev'
resValue "string", "APP_NAME", "OONI Dev"
Expand All @@ -65,8 +65,8 @@ android {
experimental {
dimension 'testing'
applicationIdSuffix '.experimental'
versionNameSuffix "-experimental.1"
versionCode versionCodeDate()
versionNameSuffix resolveVersionSuffix('experimental')
versionCode resolveVersionCode()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-experimental"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.experimental'
resValue "string", "APP_NAME", "OONI Exp"
Expand Down Expand Up @@ -173,10 +173,20 @@ dependencies {
kaptAndroidTest libs.google.dagger.compiler
}

static def versionCodeDate() {
static def resolveVersionCode() {
if(System.getenv("PR_NUMBER") != null) {
return System.getenv("PR_NUMBER").toInteger()
}
return new Date().format("yyyyMMdd").toInteger()
}

static def resolveVersionSuffix(String variant) {
if(System.getenv("PR_NUMBER") != null){
return "-${variant}.${System.getenv("PR_NUMBER")}"
}
return "-${variant}.1"
}

if (!getGradle().getStartParameter().getTaskRequests()
.toString().contains("Fdroid")){
apply plugin: 'com.google.gms.google-services'
Expand Down

0 comments on commit 5658922

Please sign in to comment.