Skip to content

Commit

Permalink
Merge pull request #189 from Tribler/fix/actions
Browse files Browse the repository at this point in the history
Make actions use correct `versionCode`
  • Loading branch information
InvictusRMC authored Feb 28, 2024
2 parents c6dc49e + e9d11a3 commit 87fb215
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/apk_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/checkout_submodules

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'

- name: Build debug APK
run: ./gradlew assembleDebug
run: ./gradlew assembleDebug --no-daemon

- name: Upload APK
uses: actions/upload-artifact@v1
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/apk_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/checkout_submodules

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'

- name: Build release APK
run: |
echo $KEYSTORE_FILE | base64 -d > app/build.keystore
./gradlew assembleRelease \
--no-daemon \
-Pandroid.injected.signing.store.file=$(pwd)/app/build.keystore \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/apk_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ jobs:
name: apk_build
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/pull/${{github.event.pull_request.number}}/merge

- uses: ./.github/actions/checkout_submodules

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'

- name: Build release APK
run: |
echo $KEYSTORE_FILE | base64 -d > app/build.keystore
./gradlew assembleRelease \
--no-daemon \
-Pandroid.injected.signing.store.file=$(pwd)/app/build.keystore \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ jobs:
- uses: ./.github/actions/checkout_submodules

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

# TODO: Without this step, the Gradle check task fails with the following error:
# Execution failed for task ':common:verifyDebugDatabaseMigration'.
# > A failure occurred while executing app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction
# > No suitable driver found for jdbc:sqlite:
- name: Run verifyDebugDatabase
run: bash ./gradlew verifyDebugDatabaseMigration
cache: 'gradle'

- name: Run check
run: bash ./gradlew check
run: ./gradlew check --no-daemon

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand Down
9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ ktlint {

// Generate a version code from git commit count
static def generateVersionCode() {
return "git rev-list HEAD --count".execute().text.trim().toInteger()
// Unix
def result = "git rev-list HEAD --count".execute().text.trim()
// Windows
if (result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim()
if (result.empty) throw new RuntimeException("Could not generate versioncode: ${result.text}")
println("Generated the following version code: " + result.toInteger())
return result.toInteger()
}


Expand All @@ -46,7 +52,6 @@ android {

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
keyAlias "trustchain"
Expand Down

0 comments on commit 87fb215

Please sign in to comment.