-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add gradle task to generate app version [WPB-7289] 🍒 (#3358)
Co-authored-by: Mohamad Jaara <[email protected]> Co-authored-by: Yamil Medina <[email protected]>
- Loading branch information
1 parent
c4eaec5
commit 74c545c
Showing
12 changed files
with
178 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,13 @@ jobs: | |
echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/the.keystore | ||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
- name: Generate version file | ||
run: ./gradlew generateVersionFile | ||
- name: Upload version file as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Version File | ||
path: app/version.txt | ||
- name: build prod flavour APK | ||
run: | ||
./gradlew app:assembleProdCompatrelease | ||
|
@@ -106,7 +113,9 @@ jobs: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
build-flavour: prod | ||
build-variant: compatrelease | ||
- name: Attach APK to release | ||
- name: Attach APK and version file to release | ||
uses: softprops/[email protected] | ||
with: | ||
files: app/build/outputs/apk/prodCompatrelease/*.apk | ||
files: | | ||
app/build/outputs/apk/prodCompatrelease/*.apk | ||
app/version.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import com.wire.android.gradle.version.Versionizer | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
class AppVersionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
project.tasks.register("generateVersionFile", Task::class.java) { | ||
// clean the repo from a probably existing version.txt | ||
if (file("$projectDir/version.txt").exists()) { | ||
println("deleting existing version.txt file for safety reasons") | ||
file("$projectDir/version.txt").delete() | ||
} | ||
|
||
val currentTime = LocalDateTime.now() | ||
val versnisor = Versionizer(projectDir, currentTime) | ||
val versionCode = versnisor.versionCode | ||
val versionName = "${AndroidApp.versionName}-${AndroidApp.leastSignificantVersionCode}" | ||
val buildTime = currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) ?: error("Failed to get build time") | ||
val appName = "com.wire" | ||
// git commit hash code | ||
val gitRevision = "git rev-parse --short HEAD".execute().text.trim() | ||
println("VersionCode: $versionCode") | ||
println("VersionName: $versionName") | ||
println("Revision: $gitRevision") | ||
println("Buildtime: $buildTime") | ||
println("Application-name: $appName") | ||
|
||
// output the data to a file in app/version.txt | ||
file("$projectDir/version.txt").writeText( | ||
""" | ||
|VersionCode: $versionCode | ||
|VersionName: $versionName | ||
|Revision: $gitRevision | ||
|Buildtime: $buildTime | ||
|Application-name: $appName | ||
""".trimMargin() | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import java.io.ByteArrayOutputStream | ||
|
||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
fun String.execute(): Process { | ||
val process = ProcessBuilder(this.split(" ")) | ||
.redirectErrorStream(true) | ||
.start() | ||
process.waitFor() | ||
return process | ||
} | ||
|
||
val Process.text: String | ||
get() { | ||
val output = ByteArrayOutputStream() | ||
inputStream.copyTo(output) | ||
return output.toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VersionCode: 100018802 | ||
VersionName: 4.8.2-18802 | ||
Revision: e53642019 | ||
Buildtime: 2024-08-21 19:32:06 | ||
Application-name: com.wire |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters