π A sample project using Firebase app distribution plugin
Launch your app quickly and simply.
π μμΈν μ€λͺ μ λΈλ‘κ·Έμμ νμΈνμ€ μ μμ΅λλ€.
- Collect change logs from git and convert into a release notes.
- Increase version from a property file.
- Commit the version property file and tag with new version on git.
- Build APK with new version
- Upload and distribute the APK with release notes created from git logs.
- Run task
_1_updateVersion
- Run task
_2_buildAndDistribute
- ?
- PROFIT!!
- Get last git tag.
- Collect git logs from last tag to latest commit.
- Write into a text file.
def createReleaseNote() {
def lastTag = {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--abbrev=0'
standardOutput = stdout
}
return stdout.toString().trim()
}
def stdout = new ByteArrayOutputStream()
exec {
// %h : git revision tag
// %s : git log message
// e.g) --format=%s : feat(res): Some description
// e.g) --format=%h %s : d23ad2f feat(res): Some description
commandLine 'git', 'log', "${lastTag()}..HEAD", '--oneline', '--format=%s'
standardOutput = stdout
}
def text = stdout.toString().trim()
new File("${rootDir}", "RELEASE_NOTE.txt").text = text
return text
}
- Maintain version with properties
def versionProp = {
def versionProp = new Properties()
versionProp.load(new FileInputStream("$project.rootDir/version.properties"))
versionProp.each { prop ->
project.ext.set(prop.key, prop.value)
}
return versionProp
}
def verCode = {
def prop = versionProp()
return Integer.valueOf("${prop['version_code']}")
}
def verName = {
def prop = versionProp()
return "${prop['version_name']}"
}
- When bump to next version...
def updateVersionProperties(name, code) {
def versionProp = new File("${rootDir}", 'version.properties')
def newVersion = name.substring(0, name.lastIndexOf('.')) +
".${Integer.valueOf(name.split('\\.').last()) + 1}"
versionProp.text = "version_name=${newVersion}\n" +
"version_code=${code + 1}"
}
def gitCommitAndTagVersion(releaseNote, verName) {
try {
exec { commandLine 'git', 'reset', 'HEAD' }
exec { commandLine 'git', 'add', "${rootDir}/version.properties" }
exec { commandLine 'git', 'commit', '-m', "v${verName} is released\n\n${releaseNote}" }
exec { commandLine 'git', 'tag', "v${verName}" }
}
catch (Exception e) {
e.printStackTrace()
}
}
- Add classpath firebase plugin into
build.gradle
(root).
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.google.firebase:firebase-appdistribution-gradle:2.1.0'
}
}
- Apply firebase plugin
plugins {
id 'com.google.firebase.appdistribution'
}
android {
...
buildTypes {
...
debug {
...
firebaseAppDistribution {
releaseNotesFile = "${rootDir}/RELEASE_NOTE.txt"
testers = "qatester@test.moc"
}
}
}
}
- Run task
appDistributionUploadDebug
or create a task depends on it.
MIT License
Copyright (c) 2021 Haenala Shin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.