chore: configure nyx for semantic releases

This commit is contained in:
Akash Yadav
2023-01-06 20:26:23 +05:30
parent 5aca971af1
commit 16a1382584
7 changed files with 146 additions and 103 deletions
+68
View File
@@ -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
View File
@@ -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
View File
@@ -21,7 +21,6 @@ plugins {
group = "com.itsaky.androidide.annotations"
version = BuildConfig.versionName
dependencies {
implementation(kotlin("stdlib"))
+3 -21
View File
@@ -15,8 +15,8 @@
* 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.
@@ -24,10 +24,8 @@ import org.gradle.api.JavaVersion
* @author Akash Yadav
*/
object BuildConfig {
/**
* AndroidIDE's package name.
*/
/** AndroidIDE's package name. */
const val packageName = "com.itsaky.androidide"
/** The compile SDK version. */
@@ -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"
}
@@ -1,52 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE 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.
*
* AndroidIDE 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 AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide
import java.io.File
/**
* Information about the CI build.
*
* @author Akash Yadav
*/
object CI {
/** The short commit hash. */
val commitHash by lazy {
val sha = System.getenv("GITHUB_SHA")
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()
}
}
+6 -10
View File
@@ -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 {
@@ -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 {
@@ -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
@@ -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() }
+46 -19
View File
@@ -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 {
@@ -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/") }
}
}
@@ -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",
@@ -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()
}
}