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

Commit

Permalink
chore: configure nyx for semantic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Jan 6, 2023
1 parent 5aca971 commit 16a1382
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 103 deletions.
68 changes: 68 additions & 0 deletions .nyx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
preset: simple
releaseLenient: false
releasePrefix: "v"
stateFile: build/nyx-state.json
scheme: SEMVER

changelog:
path: build/CHANGELOG.md
template: .nyx/CHANGELOG.tpl
sections:
Added: "^feat$"
Fixed: "^fix$"
substitutions:
"(?m)#([0-9]+)(?s)": "[#%s](https://github.com/AndroidIDEOfficial/AndroidIDE/issues/%s)"

releaseAssets:
apk:
fileName: "androidide-{{version}}.apk"
description: "AndroidIDE {{version}} release APK"
path: app/build/outputs/apk/release/app-release.apk
type: application/octet-stream

releaseTypes:
enabled:
- mainline
- internal
publicationServices:
- github
items:
mainline:
description: "{{#file.content}}build/CHANGELOG.md{{/file.content}}"
collapseVersions: false
gitPush: "{{#environment.variable}}CI{{/environment.variable}}"
gitTag: "{{#environment.variable}}CI{{/environment.variable}}"
publish: "{{#environment.variable}}CI{{/environment.variable}}"
matchBranches: "^(master|main)$"
matchWorkspaceStatus: "CLEAN"
matchEnvironmentVariables:
CI: "^true$"
ReleaseAndroidIDE: "^true$"
internal:
description: "{{#file.content}}build/CHANGELOG.md{{/file.content}}"
collapseVersions: true
collapsedVersionQualifier: "internal"
gitPush: false
gitTag: false
publish: false
identifiers:
-
qualifier: "branch"
value: "{{#sanitizeLower}}{{branch}}{{/sanitizeLower}}"
position: "BUILD"
-
qualifier: "commit"
value: "{{#short7}}{{releaseScope.finalCommit}}{{/short7}}"
position: "BUILD"
-
qualifier: "timestamp"
value: "{{#timestampYYYYMMDDHHMMSS}}{{timestamp}}{{/timestampYYYYMMDDHHMMSS}}"
position: "BUILD"

services:
github:
type: GITHUB
options:
REPOSITORY_OWNER_NAME: "AndroidIDEOfficial"
REPOSITORY_NAME: "AndroidIDE"
AUTHENTICATION_TOKEN: "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}"
23 changes: 23 additions & 0 deletions .nyx/CHANGELOG.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# AndroidIDE Changelog

{{#releases}}
## [{{name}}](https://github.com/AndroidIDEOfficial/AndroidIDE/releases/tag/{{name}}) ({{date}})

{{#sections}}
### {{name}}

{{#commits}}
* [{{#short5}}{{SHA}}{{/short5}}](https://github.com/AndroidIDEOfficial/AndroidIDE/commit/{{SHA}}) {{message.shortMessage}} ({{authorAction.identity.name}})

{{/commits}}
{{^commits}}
No changes.
{{/commits}}
{{/sections}}
{{^sections}}
No changes.
{{/sections}}
{{/releases}}
{{^releases}}
No releases.
{{/releases}}
1 change: 0 additions & 1 deletion annotation-ksp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ plugins {


group = "com.itsaky.androidide.annotations"
version = BuildConfig.versionName

dependencies {
implementation(kotlin("stdlib"))
Expand Down
24 changes: 3 additions & 21 deletions build-logic/ide/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/

import com.itsaky.androidide.CI
import org.gradle.api.JavaVersion
import org.gradle.api.Project

/**
* Build configuration for the IDE.
*
* @author Akash Yadav
*/
object BuildConfig {

/**
* AndroidIDE's package name.
*/

/** AndroidIDE's package name. */
const val packageName = "com.itsaky.androidide"

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

/**
* The version name for the IDE. When in CI build, includes the [releaseVersionName], branch name
* and the short commit hash.
*/
val versionName by lazy {
var version = releaseVersionName
if (CI.isCiBuild) {
// e.g. 2.1.2-beta_main-d5e9c9ea
version += "_${CI.branchName}-${CI.commitHash}"
}
version
}

/** The source and target Java compatibility. */
val javaVersion = JavaVersion.VERSION_11
val javaVersionMajor = 11

/** The release version name. */
const val releaseVersionName = "2.1.4-beta"
}
52 changes: 0 additions & 52 deletions build-logic/ide/src/main/kotlin/com/itsaky/androidide/CI.kt

This file was deleted.

16 changes: 6 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.android.build.gradle.BaseExtension
import com.itsaky.androidide.plugins.AndroidIDEPlugin
import com.mooltiverse.oss.nyx.state.State

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
Expand All @@ -26,11 +27,7 @@ plugins {
alias(libs.plugins.kotlin) apply false
}

buildscript {
dependencies {
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
}
}
buildscript { dependencies { classpath("com.google.android.gms:oss-licenses-plugin:0.10.6") } }

fun Project.configureBaseExtension() {
extensions.findByType(BaseExtension::class)?.run {
Expand All @@ -41,14 +38,14 @@ fun Project.configureBaseExtension() {
minSdk = BuildConfig.minSdk
targetSdk = BuildConfig.targetSdk
versionCode = BuildConfig.versionCode
versionName = BuildConfig.versionName
versionName = rootProject.version.toString()
}

compileOptions {
sourceCompatibility = BuildConfig.javaVersion
targetCompatibility = BuildConfig.javaVersion
}

buildTypes.getByName("debug") { isMinifyEnabled = false }
buildTypes.getByName("release") {
isMinifyEnabled = true
Expand All @@ -62,10 +59,9 @@ fun Project.configureBaseExtension() {
}

subprojects {
apply {
plugin(AndroidIDEPlugin::class.java)
}
apply { plugin(AndroidIDEPlugin::class.java) }

version = rootProject.version
plugins.withId("com.android.application") { configureBaseExtension() }
plugins.withId("com.android.library") { configureBaseExtension() }

Expand Down
65 changes: 46 additions & 19 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@file:Suppress("UnstableApiUsage")

import com.mooltiverse.oss.nyx.gradle.NyxExtension
import com.mooltiverse.oss.nyx.services.github.GitHub

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

pluginManagement {
Expand All @@ -11,27 +14,21 @@ pluginManagement {
}
}

plugins { id("com.mooltiverse.oss.nyx") version "1.3.0" }

extensions.configure<NyxExtension> {
configurationFile.set(".nyx.yml")
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

maven {
url = uri("https://jitpack.io")
}

maven {
url = uri("https://repo.gradle.org/gradle/libs-releases/")
}

maven {
url = uri("https://repo.eclipse.org/content/repositories/lemminx-snapshots/")
}
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://repo.gradle.org/gradle/libs-releases/") }
maven { url = uri("https://repo.eclipse.org/content/repositories/lemminx-snapshots/") }
}
}

Expand All @@ -57,15 +54,12 @@ include(
":treeview",
":uidesigner",
":xml-inflater",

":gradle-plugin",

":lsp:api",
":lsp:models",
":lsp:java",
":lsp:xml",
":lsp:testing",

":subprojects:aaptcompiler",
":subprojects:builder-model-impl",
":subprojects:classfile",
Expand All @@ -88,3 +82,36 @@ include(
":subprojects:xml-formatter",
":subprojects:xml-utils"
)

/**
* Information about the CI build.
*
* @author Akash Yadav
*/
object CI {

/** The short commit hash. */
val commitHash by lazy {
val sha = System.getenv("GITHUB_SHA") ?: return@lazy ""
shortSha(sha)
}

/** Name of the current branch. */
val branchName by lazy {
System.getenv("GITHUB_REF_NAME") ?: "main" // by default, 'main'
}

/** Whether the current build is a CI build. */
val isCiBuild by lazy { "true" == System.getenv("CI") }

private fun shortSha(sha: String): String {
return ProcessBuilder("git", "rev-parse", "--short", sha)
.directory(File("."))
.redirectErrorStream(true)
.start()
.inputStream
.bufferedReader()
.readText()
.trim()
}
}

0 comments on commit 16a1382

Please sign in to comment.