Skip to content

Commit

Permalink
use build number and version from github
Browse files Browse the repository at this point in the history
  • Loading branch information
lhns committed Nov 26, 2021
1 parent 90870cd commit de4ef8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
[ "${{ secrets.RELEASE_STORE_BASE64}}" == "" ] || echo "${{ secrets.RELEASE_STORE_BASE64}}" | base64 -d > keystore.jks
- name: Build with Gradle
env:
CI_VERSION: ${{ github.ref }}
CI_BUILD_NUMBER: ${{ github.run_id }}
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
run: echo "${{ secrets.RELEASE_STORE_BASE64}}" | base64 -d > keystore.jks
- name: Build with Gradle
env:
CI_VERSION: ${{ github.ref }}
CI_BUILD_NUMBER: ${{ github.run_id }}
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
Expand Down
14 changes: 12 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.0'
}

def getBuildNumber = { ->
System.getenv('CI_BUILD_NUMBER')?.toInteger() ?: 1
}

def getVersion = { ->
def matcher = System.getenv('CI_VERSION') =~ /refs\/tags\/(.*)/
if (matcher.find()) matcher.group(1)
else "0.0.1-SNAPSHOT"
}

android {
compileSdkVersion 30

defaultConfig {
applicationId "de.lolhens.resticui"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode getBuildNumber()
versionName getVersion()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down

0 comments on commit de4ef8f

Please sign in to comment.