-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
166 lines (141 loc) · 4.59 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import com.darkrockstudios.build.configureRelease
import com.darkrockstudios.build.parseSemVar
import com.darkrockstudios.build.writeChangelogMarkdown
import com.darkrockstudios.build.writeSemvar
group = "com.darkrockstudios.apps.hammer"
version = libs.versions.app.get()
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath(libs.moko.resources.generator)
classpath(libs.kotlinx.atomicfu.plugin)
classpath(libs.jetbrains.kover)
}
}
val xlibs = extensions.getByType<VersionCatalogsExtension>().named("libs")
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
tasks.withType<Test> {
useJUnitPlatform()
}
dependencies {
enforcedPlatform(xlibs.findLibrary("junit.bom").get())
}
}
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.jetbrains.compose) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.buildconfig) apply false
alias(libs.plugins.moko.resources) apply false
alias(libs.plugins.aboutlibraries.plugin) apply false
alias(libs.plugins.jetbrains.kover)
alias(libs.plugins.kotlinx.atomicfu)
}
dependencies {
//kover(project(":base"))
kover(project(":common"))
kover(project(":server"))
}
kover {
reports {
total {
}
}
}
tasks.register("prepareForRelease") {
doLast {
val releaseInfo =
configureRelease(libs.versions.app.get()) ?: error("Failed to configure new release")
println("Creating new release")
val versionCode = releaseInfo.semVar.createVersionCode(true, 0)
// Write the new version number
val versionsPath = "gradle/libs.versions.toml".replace("/", File.separator)
val versionsFile = project.rootDir.resolve(versionsPath)
writeSemvar(libs.versions.app.get(), releaseInfo.semVar, versionsFile)
// Google Play has a hard limit of 500 characters
val truncatedChangelog = if (releaseInfo.changeLog.length > 500) {
"${releaseInfo.changeLog.take(480)}... and more"
} else {
releaseInfo.changeLog
}
// Write the Fastlane changelog file
val rootDir: File = project.rootDir
val changelogsPath =
"fastlane/metadata/android/en-US/changelogs".replace("/", File.separator)
val changeLogsDir = rootDir.resolve(changelogsPath)
val changeLogFile = File(changeLogsDir, "$versionCode.txt")
changeLogFile.writeText(truncatedChangelog)
println("Changelog for version ${releaseInfo.semVar} written to $changelogsPath/$versionCode.txt")
// Write the Global changelog file
val globalChangelogFile = File("${project.rootDir}/CHANGELOG.md")
writeChangelogMarkdown(releaseInfo, globalChangelogFile)
// Commit the changes to the repo
exec { commandLine = listOf("git", "add", changeLogFile.absolutePath) }
exec { commandLine = listOf("git", "add", versionsFile.absolutePath) }
exec { commandLine = listOf("git", "add", globalChangelogFile.absolutePath) }
exec {
commandLine =
listOf("git", "commit", "-m", "Prepared for release: v${releaseInfo.semVar}")
}
// Merge develop into release
exec { commandLine = listOf("git", "checkout", "release") }
exec { commandLine = listOf("git", "merge", "develop") }
// Create the release tag
exec {
commandLine =
listOf("git", "tag", "-a", "v${releaseInfo.semVar}", "-m", releaseInfo.changeLog)
}
// Push and begin the release process
exec { commandLine = listOf("git", "push", "origin", "--all") }
exec { commandLine = listOf("git", "push", "origin", "--tags") }
// Leave the repo back on develop
exec { commandLine = listOf("git", "checkout", "develop") }
}
}
tasks.register("publishFdroid") {
doLast {
val semvarStr = libs.versions.app.get()
val curSemVar = parseSemVar(semvarStr)
val versionCode = curSemVar.createVersionCode(true, 0)
val tag = "fdroid-${versionCode}"
exec {
commandLine = listOf(
"git",
"config",
"--global",
"user.email",
"github-actions[bot]@users.noreply.github.com"
)
}
exec {
commandLine = listOf("git", "config", "--global", "user.name", "github-actions[bot]")
}
exec { commandLine = listOf("git", "fetch", "origin", "release") }
exec { commandLine = listOf("git", "checkout", "release") }
exec {
commandLine = listOf(
"git",
"tag",
"-a",
tag,
"-m",
"FDroid release tag for $semvarStr"
)
}
exec { commandLine = listOf("git", "push", "origin", "tag", tag) }
}
}