Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 16a1382

Browse files
committed
chore: configure nyx for semantic releases
1 parent 5aca971 commit 16a1382

7 files changed

Lines changed: 146 additions & 103 deletions

File tree

.nyx.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
preset: simple
2+
releaseLenient: false
3+
releasePrefix: "v"
4+
stateFile: build/nyx-state.json
5+
scheme: SEMVER
6+
7+
changelog:
8+
path: build/CHANGELOG.md
9+
template: .nyx/CHANGELOG.tpl
10+
sections:
11+
Added: "^feat$"
12+
Fixed: "^fix$"
13+
substitutions:
14+
"(?m)#([0-9]+)(?s)": "[#%s](https://github.com/AndroidIDEOfficial/AndroidIDE/issues/%s)"
15+
16+
releaseAssets:
17+
apk:
18+
fileName: "androidide-{{version}}.apk"
19+
description: "AndroidIDE {{version}} release APK"
20+
path: app/build/outputs/apk/release/app-release.apk
21+
type: application/octet-stream
22+
23+
releaseTypes:
24+
enabled:
25+
- mainline
26+
- internal
27+
publicationServices:
28+
- github
29+
items:
30+
mainline:
31+
description: "{{#file.content}}build/CHANGELOG.md{{/file.content}}"
32+
collapseVersions: false
33+
gitPush: "{{#environment.variable}}CI{{/environment.variable}}"
34+
gitTag: "{{#environment.variable}}CI{{/environment.variable}}"
35+
publish: "{{#environment.variable}}CI{{/environment.variable}}"
36+
matchBranches: "^(master|main)$"
37+
matchWorkspaceStatus: "CLEAN"
38+
matchEnvironmentVariables:
39+
CI: "^true$"
40+
ReleaseAndroidIDE: "^true$"
41+
internal:
42+
description: "{{#file.content}}build/CHANGELOG.md{{/file.content}}"
43+
collapseVersions: true
44+
collapsedVersionQualifier: "internal"
45+
gitPush: false
46+
gitTag: false
47+
publish: false
48+
identifiers:
49+
-
50+
qualifier: "branch"
51+
value: "{{#sanitizeLower}}{{branch}}{{/sanitizeLower}}"
52+
position: "BUILD"
53+
-
54+
qualifier: "commit"
55+
value: "{{#short7}}{{releaseScope.finalCommit}}{{/short7}}"
56+
position: "BUILD"
57+
-
58+
qualifier: "timestamp"
59+
value: "{{#timestampYYYYMMDDHHMMSS}}{{timestamp}}{{/timestampYYYYMMDDHHMMSS}}"
60+
position: "BUILD"
61+
62+
services:
63+
github:
64+
type: GITHUB
65+
options:
66+
REPOSITORY_OWNER_NAME: "AndroidIDEOfficial"
67+
REPOSITORY_NAME: "AndroidIDE"
68+
AUTHENTICATION_TOKEN: "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}"

.nyx/CHANGELOG.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# AndroidIDE Changelog
2+
3+
{{#releases}}
4+
## [{{name}}](https://github.com/AndroidIDEOfficial/AndroidIDE/releases/tag/{{name}}) ({{date}})
5+
6+
{{#sections}}
7+
### {{name}}
8+
9+
{{#commits}}
10+
* [{{#short5}}{{SHA}}{{/short5}}](https://github.com/AndroidIDEOfficial/AndroidIDE/commit/{{SHA}}) {{message.shortMessage}} ({{authorAction.identity.name}})
11+
12+
{{/commits}}
13+
{{^commits}}
14+
No changes.
15+
{{/commits}}
16+
{{/sections}}
17+
{{^sections}}
18+
No changes.
19+
{{/sections}}
20+
{{/releases}}
21+
{{^releases}}
22+
No releases.
23+
{{/releases}}

annotation-ksp/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ plugins {
2121

2222

2323
group = "com.itsaky.androidide.annotations"
24-
version = BuildConfig.versionName
2524

2625
dependencies {
2726
implementation(kotlin("stdlib"))

build-logic/ide/src/main/kotlin/BuildConfig.kt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@
1515
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
import com.itsaky.androidide.CI
1918
import org.gradle.api.JavaVersion
19+
import org.gradle.api.Project
2020

2121
/**
2222
* Build configuration for the IDE.
2323
*
2424
* @author Akash Yadav
2525
*/
2626
object BuildConfig {
27-
28-
/**
29-
* AndroidIDE's package name.
30-
*/
27+
28+
/** AndroidIDE's package name. */
3129
const val packageName = "com.itsaky.androidide"
3230

3331
/** The compile SDK version. */
@@ -45,23 +43,7 @@ object BuildConfig {
4543
/** The version code. */
4644
const val versionCode = 214
4745

48-
/**
49-
* The version name for the IDE. When in CI build, includes the [releaseVersionName], branch name
50-
* and the short commit hash.
51-
*/
52-
val versionName by lazy {
53-
var version = releaseVersionName
54-
if (CI.isCiBuild) {
55-
// e.g. 2.1.2-beta_main-d5e9c9ea
56-
version += "_${CI.branchName}-${CI.commitHash}"
57-
}
58-
version
59-
}
60-
6146
/** The source and target Java compatibility. */
6247
val javaVersion = JavaVersion.VERSION_11
6348
val javaVersionMajor = 11
64-
65-
/** The release version name. */
66-
const val releaseVersionName = "2.1.4-beta"
6749
}

build-logic/ide/src/main/kotlin/com/itsaky/androidide/CI.kt

Lines changed: 0 additions & 52 deletions
This file was deleted.

build.gradle.kts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.android.build.gradle.BaseExtension
1919
import com.itsaky.androidide.plugins.AndroidIDEPlugin
20+
import com.mooltiverse.oss.nyx.state.State
2021

2122
@Suppress("DSL_SCOPE_VIOLATION")
2223
plugins {
@@ -26,11 +27,7 @@ plugins {
2627
alias(libs.plugins.kotlin) apply false
2728
}
2829

29-
buildscript {
30-
dependencies {
31-
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
32-
}
33-
}
30+
buildscript { dependencies { classpath("com.google.android.gms:oss-licenses-plugin:0.10.6") } }
3431

3532
fun Project.configureBaseExtension() {
3633
extensions.findByType(BaseExtension::class)?.run {
@@ -41,14 +38,14 @@ fun Project.configureBaseExtension() {
4138
minSdk = BuildConfig.minSdk
4239
targetSdk = BuildConfig.targetSdk
4340
versionCode = BuildConfig.versionCode
44-
versionName = BuildConfig.versionName
41+
versionName = rootProject.version.toString()
4542
}
4643

4744
compileOptions {
4845
sourceCompatibility = BuildConfig.javaVersion
4946
targetCompatibility = BuildConfig.javaVersion
5047
}
51-
48+
5249
buildTypes.getByName("debug") { isMinifyEnabled = false }
5350
buildTypes.getByName("release") {
5451
isMinifyEnabled = true
@@ -62,10 +59,9 @@ fun Project.configureBaseExtension() {
6259
}
6360

6461
subprojects {
65-
apply {
66-
plugin(AndroidIDEPlugin::class.java)
67-
}
62+
apply { plugin(AndroidIDEPlugin::class.java) }
6863

64+
version = rootProject.version
6965
plugins.withId("com.android.application") { configureBaseExtension() }
7066
plugins.withId("com.android.library") { configureBaseExtension() }
7167

settings.gradle.kts

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@file:Suppress("UnstableApiUsage")
22

3+
import com.mooltiverse.oss.nyx.gradle.NyxExtension
4+
import com.mooltiverse.oss.nyx.services.github.GitHub
5+
36
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
47

58
pluginManagement {
@@ -11,27 +14,21 @@ pluginManagement {
1114
}
1215
}
1316

17+
plugins { id("com.mooltiverse.oss.nyx") version "1.3.0" }
18+
19+
extensions.configure<NyxExtension> {
20+
configurationFile.set(".nyx.yml")
21+
}
22+
1423
dependencyResolutionManagement {
1524
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
1625
repositories {
1726
google()
1827
mavenCentral()
19-
20-
maven {
21-
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
22-
}
23-
24-
maven {
25-
url = uri("https://jitpack.io")
26-
}
27-
28-
maven {
29-
url = uri("https://repo.gradle.org/gradle/libs-releases/")
30-
}
31-
32-
maven {
33-
url = uri("https://repo.eclipse.org/content/repositories/lemminx-snapshots/")
34-
}
28+
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
29+
maven { url = uri("https://jitpack.io") }
30+
maven { url = uri("https://repo.gradle.org/gradle/libs-releases/") }
31+
maven { url = uri("https://repo.eclipse.org/content/repositories/lemminx-snapshots/") }
3532
}
3633
}
3734

@@ -57,15 +54,12 @@ include(
5754
":treeview",
5855
":uidesigner",
5956
":xml-inflater",
60-
6157
":gradle-plugin",
62-
6358
":lsp:api",
6459
":lsp:models",
6560
":lsp:java",
6661
":lsp:xml",
6762
":lsp:testing",
68-
6963
":subprojects:aaptcompiler",
7064
":subprojects:builder-model-impl",
7165
":subprojects:classfile",
@@ -88,3 +82,36 @@ include(
8882
":subprojects:xml-formatter",
8983
":subprojects:xml-utils"
9084
)
85+
86+
/**
87+
* Information about the CI build.
88+
*
89+
* @author Akash Yadav
90+
*/
91+
object CI {
92+
93+
/** The short commit hash. */
94+
val commitHash by lazy {
95+
val sha = System.getenv("GITHUB_SHA") ?: return@lazy ""
96+
shortSha(sha)
97+
}
98+
99+
/** Name of the current branch. */
100+
val branchName by lazy {
101+
System.getenv("GITHUB_REF_NAME") ?: "main" // by default, 'main'
102+
}
103+
104+
/** Whether the current build is a CI build. */
105+
val isCiBuild by lazy { "true" == System.getenv("CI") }
106+
107+
private fun shortSha(sha: String): String {
108+
return ProcessBuilder("git", "rev-parse", "--short", sha)
109+
.directory(File("."))
110+
.redirectErrorStream(true)
111+
.start()
112+
.inputStream
113+
.bufferedReader()
114+
.readText()
115+
.trim()
116+
}
117+
}

0 commit comments

Comments
 (0)