Skip to content

Commit

Permalink
Merge pull request #267 from eighthave/set-versionName-from-git-tags
Browse files Browse the repository at this point in the history
Set versionName from git tags
  • Loading branch information
n8fr8 committed Oct 7, 2019
2 parents 4150ef6 + 04bdf16 commit bf72040
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'


// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")
Expand All @@ -12,6 +13,16 @@ if (keystorePropertiesFile.canRead()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

/* gets the version name from the latest Git tag, stripping the leading v off */
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
return stdout.toString().trim()
}

android {
signingConfigs {
release {
Expand All @@ -28,6 +39,7 @@ android {
buildToolsVersion '29.0.0'
defaultConfig {
applicationId "org.torproject.android"
versionName getVersionName()
minSdkVersion 16
targetSdkVersion 29
}
Expand Down Expand Up @@ -62,7 +74,7 @@ android {
applicationId 'org.torproject.android'
targetSdkVersion 28
versionCode 16123000
versionName '16.1.2-RC-2-tor-0.4.1.5-rc'
versionName getVersionName()
archivesBaseName = "Orbot-$versionName"
}
}
Expand Down
6 changes: 3 additions & 3 deletions make-release-build
Expand Up @@ -6,9 +6,9 @@ set -e
set -x

# make sure we're on a signed tag that matches the version name
versionName=`sed -n 's,.*versionName="\([^"]*\)".*,\1,p' app/src/main/AndroidManifest.xml`
describe=`git describe`
if [ $versionName != $describe ]; then
describe=`git describe --tags --always`
versionName=`echo $describe | sed 's,-[0-9][0-9]*-g.*,,'`
if [ "$versionName" != "$describe" ]; then
echo "WARNING: building $describe, which is not the latest release ($versionName)"
else
# make a clearer warning above by putting this here
Expand Down

0 comments on commit bf72040

Please sign in to comment.