Skip to content

Commit

Permalink
feat(build,docs): bootstrap build, clarify docs (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrawford-figure authored Oct 16, 2024
1 parent d431764 commit a516c60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
25 changes: 0 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ plugins {
}

group = "com.figure.gradle.semver"
version = "2.0.1"

val testImplementation: Configuration by configurations.getting

Expand Down Expand Up @@ -68,24 +67,6 @@ dependencies {
functionalTestImplementation(libs.testkit.support)
}

@DisableCachingByDefault
abstract class WriteVersionToFile : DefaultTask() {
@get:Input
abstract val versionProperty: Property<String>

init {
group = "build"
description = "Writes the project version to build/semver/semver.properties"
}

@TaskAction
fun writeVersion() {
val versionFile = File("build/semver/semver.properties")
versionFile.parentFile.mkdirs()
versionFile.writeText("version=${versionProperty.get()}")
}
}

tasks {
withType<KotlinCompile>().configureEach {
compilerOptions {
Expand All @@ -112,7 +93,6 @@ tasks {

check {
dependsOn("detekt")
dependsOn("writeVersionToFile")
}

withType<Detekt>().configureEach {
Expand All @@ -135,11 +115,6 @@ tasks {
description = "Check all code using configured linters. Runs 'spotlessCheck'"
dependsOn("spotlessCheck")
}

// Temporary solution until this plugin can be bootstrapped with itself
register<WriteVersionToFile>("writeVersionToFile") {
versionProperty = project.version.toString()
}
}

idea {
Expand Down
16 changes: 13 additions & 3 deletions docs/for-major-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ Latest tag: `v2.0.0`
Latest v1 tag: `v1.5.9`

???+ note "Important Note"
If no stage or modifier is provided, a default of `auto` used.
If no stage or modifier is provided, a default of `auto` used.

| Command | Next Version |
|-------------------------------------------------------------------------------------|--------------|
| `./gradlew -Psemver.forMajorVersion=1` | 1.5.10 |
| `./gradlew -Psemver.forMajorVersion=1` -Psemver.modifier=minor | 1.6.0 |
| `./gradlew -Psemver.forMajorVersion=1` -Psemver.modifier=minor -Psemver.modifier=rc | 1.6.0-rc.1 |
| `./gradlew -Psemver.forMajorVersion=1 -Psemver.modifier=minor` | 1.6.0 |
| `./gradlew -Psemver.forMajorVersion=1 -Psemver.modifier=minor -Psemver.modifier=rc` | 1.6.0-rc.1 |

### Suggested Workflow

1. Identify and checkout the latest tag for the major version you want to
target.
2. Create a new branch for your changes off the tag (e.g. `release/v1.x`).
3. Make your changes and commit them to your new branch.
4. Execute gradle build, publish, and release steps with
`-Psemver.forMajorVersion=<your-major-version>` to target the historical
major version line.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencyResolutionManagement {

plugins {
id("com.gradle.develocity") version "3.18.1"
id("com.figure.gradle.semver") version "2.0.1"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

Expand Down

0 comments on commit a516c60

Please sign in to comment.