Skip to content

Commit

Permalink
#806 | project.version set when updateProjectVersionAfterRelease flag…
Browse files Browse the repository at this point in the history
… is enabled
  • Loading branch information
bgalek committed Sep 2, 2024
1 parent ec7fe55 commit 96eda73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ abstract class ReleasePlugin implements Plugin<Project> {
group = 'Release'
description = 'Performs release - creates tag and pushes it to remote.'
dependsOn(VERIFY_RELEASE_TASK)
if (versionConfig.updateProjectVersionAfterRelease.get()) {
project.logger.quiet("Project version will be updated after release.")
finalizedBy(project.tasks.assemble)
}

Check warning on line 47 in src/main/groovy/pl/allegro/tech/build/axion/release/ReleasePlugin.groovy

View check run for this annotation

Codecov / codecov/patch

src/main/groovy/pl/allegro/tech/build/axion/release/ReleasePlugin.groovy#L45-L47

Added lines #L45 - L47 were not covered by tests
}

project.tasks.register(CREATE_RELEASE_TASK, CreateReleaseTask) {
group = 'Release'
description = 'Performs first stage of release - creates tag.'
dependsOn(VERIFY_RELEASE_TASK)
if (versionConfig.updateProjectVersionAfterRelease.get()) {
project.logger.quiet("Project version will be updated after release.")
finalizedBy(project.tasks.assemble)
}

Check warning on line 57 in src/main/groovy/pl/allegro/tech/build/axion/release/ReleasePlugin.groovy

View check run for this annotation

Codecov / codecov/patch

src/main/groovy/pl/allegro/tech/build/axion/release/ReleasePlugin.groovy#L55-L57

Added lines #L55 - L57 were not covered by tests
}

project.tasks.register(PUSH_RELEASE_TASK, PushReleaseTask) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.Action
import org.gradle.api.Task
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.Releaser
import pl.allegro.tech.build.axion.release.domain.scm.ScmPushResult
Expand Down Expand Up @@ -32,6 +34,10 @@ abstract class ReleaseTask extends BaseAxionTask {
throw new ReleaseFailedException("Status: ${status}\nMessage: ${message}")
}

if (versionConfig.updateProjectVersionAfterRelease().get()) {
project.version = versionConfig.uncached.decoratedVersion

Check warning on line 38 in src/main/groovy/pl/allegro/tech/build/axion/release/ReleaseTask.groovy

View check run for this annotation

Codecov / codecov/patch

src/main/groovy/pl/allegro/tech/build/axion/release/ReleaseTask.groovy#L38

Added line #L38 was not covered by tests
}

if (result.outcome === ScmPushResultOutcome.SUCCESS) {
if (System.getenv().containsKey('GITHUB_ACTIONS')) {
Files.write(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ abstract class VersionConfig extends BaseExtension {
private static final String IGNORE_UNCOMMITTED_CHANGES_PROPERTY = 'release.ignoreUncommittedChanges'
private static final String FORCE_SNAPSHOT_PROPERTY = 'release.forceSnapshot'
private static final String USE_HIGHEST_VERSION_PROPERTY = 'release.useHighestVersion'
private static final String UPDATE_PROJECT_VERSION_AFTER_RELEASE_PROPERTY = 'release.updateProjectVersionAfterRelease'
private static final String LOCAL_ONLY = "release.localOnly"
private static final String FORCE_VERSION_PROPERTY = 'release.version'
private static final String DEPRECATED_FORCE_VERSION_PROPERTY = 'release.forceVersion'
Expand All @@ -43,6 +44,7 @@ abstract class VersionConfig extends BaseExtension {
getLocalOnly().convention(false)
getIgnoreUncommittedChanges().convention(true)
getUseHighestVersion().convention(false)
getUpdateProjectVersionAfterRelease().convention(false)
getUnshallowRepoOnCI().convention(false)
getIgnoreGlobalGitConfig().convention(false)
getReleaseBranchNames().convention(gradlePropertyAsSet(RELEASE_BRANCH_NAMES_PROPERTY).orElse(['master', 'main'] as Set))
Expand Down Expand Up @@ -127,6 +129,9 @@ abstract class VersionConfig extends BaseExtension {
@Internal
abstract Property<Boolean> getUseHighestVersion();

@Internal
abstract Property<Boolean> getUpdateProjectVersionAfterRelease();

Provider<Boolean> ignoreUncommittedChanges() {
gradlePropertyPresent(IGNORE_UNCOMMITTED_CHANGES_PROPERTY)
.orElse(ignoreUncommittedChanges)
Expand All @@ -140,6 +145,10 @@ abstract class VersionConfig extends BaseExtension {
gradlePropertyPresent(USE_HIGHEST_VERSION_PROPERTY).orElse(useHighestVersion)
}

Provider<Boolean> updateProjectVersionAfterRelease() {
gradlePropertyPresent(UPDATE_PROJECT_VERSION_AFTER_RELEASE_PROPERTY).orElse(updateProjectVersionAfterRelease)

Check warning on line 149 in src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy

View check run for this annotation

Codecov / codecov/patch

src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy#L149

Added line #L149 was not covered by tests
}

Provider<Boolean> localOnly() {
gradlePropertyPresent(LOCAL_ONLY).orElse(localOnly)
}
Expand Down

0 comments on commit 96eda73

Please # to comment.