Skip to content

Commit

Permalink
Migrate to cthing-projectversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
baron1405 committed May 26, 2024
1 parent 8f5b1c5 commit ff4e580
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Changed

- Use cthing-projectversion library `ProjectVersion` object for project version

## [1.0.1] - 2024-04-18

### Added
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ This project is released on the [Gradle Plugin Portal](https://plugins.gradle.or
Perform the following steps to create a release.

- Commit all changes for the release
- In the `build.gradle.kts` file
- Ensure that `baseVersion` is set to the version for the release. The project follows [semantic versioning](https://semver.org/).
- Set `isSnapshot` to `false`
- In the `build.gradle.kts` file, edit the `ProjectVersion` object
- Set the version for the release. The project follows [semantic versioning](https://semver.org/).
- Set the build type to `BuildType.release`
- Commit the changes
- Wait until CI successfully builds the release candidate
- Verify GitHub Actions build is successful
Expand All @@ -214,9 +214,9 @@ Perform the following steps to create a release.
- Wait for the plugin to be reviewed and made available by the Gradle team
- In a browser, go to the project on GitHub
- Generate a release with the tag `<version>`
- In the build.gradle.kts file
- Increment the `baseVersion` patch number
- Set `isSnapshot` to `true`
- In the build.gradle.kts file, edit the `ProjectVersion` object
- Increment the version patch number
- Set the build type to `BuildType.snapshot`
- Update the `CHANGELOG.md` with the changes in the release and prepare for next release changes
- Update the `Usage` section in the `README.md` with the latest artifact release version
- Commit these changes
21 changes: 14 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.Confidence
import org.cthing.projectversion.BuildType
import org.cthing.projectversion.ProjectVersion
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand All @@ -19,12 +21,16 @@ plugins {
alias(libs.plugins.versions)
}

val baseVersion = "1.0.2"
val isSnapshot = true
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.cthingProjectVersion)
}
}

val isCIServer = System.getenv("CTHING_CI") != null
val buildNumber = if (isCIServer) System.currentTimeMillis().toString() else "0"
version = if (isSnapshot) "$baseVersion-$buildNumber" else baseVersion
version = ProjectVersion("1.0.2", BuildType.snapshot)
group = "org.cthing"
description = "A Gradle plugin for counting lines of code."

Expand Down Expand Up @@ -157,7 +163,7 @@ tasks {

publishPlugins {
doFirst {
if (isSnapshot) {
if ((version as ProjectVersion).isSnapshotBuild) {
throw GradleException("Cannot publish a developer build to the Gradle Plugin Portal")
}
if (!project.hasProperty("gradle.publish.key") || !project.hasProperty("gradle.publish.secret")) {
Expand Down Expand Up @@ -205,7 +211,8 @@ tasks {
}

publishing {
val repoUrl = if (isSnapshot) findProperty("cthing.nexus.snapshotsUrl") else findProperty("cthing.nexus.candidatesUrl")
val repoUrl = if ((version as ProjectVersion).isSnapshotBuild)
findProperty("cthing.nexus.snapshotsUrl") else findProperty("cthing.nexus.candidatesUrl")
if (repoUrl != null) {
repositories {
maven {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
assertJ = "org.assertj:assertj-core:3.25.3"
commonsIO = "commons-io:commons-io:2.15.1"
cthingAnnots = "org.cthing:cthing-annotations:1.0.0"
cthingProjectVersion = "org.cthing:cthing-projectversion:1.0.0"
escapers = "org.cthing:escapers:1.0.0"
jacksonCoreUtils = "com.github.java-json-tools:jackson-coreutils:2.0"
jacksonCore = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" }
Expand Down

0 comments on commit ff4e580

Please sign in to comment.