Skip to content

Automate version update after releaseΒ #485

Open
@strangelookingnerd

Description

@strangelookingnerd

Describe the need of your request

After a release is published, a PR with the patched changelog is created. In that PR it would make sense to also update the pluginVersion to the next patch number.

Proposed solution

Have a task similar to this:

    register("updateVersion") {
        description = "Updates the version in gradle.properties after a release build"

        val version = providers.gradleProperty("pluginVersion").get()
        val (major, minor, patch) = version.split(".").map { it.toInt() }
        val newVersion = "$major.$minor.${patch + 1}"

        // update
        val file = file("gradle.properties")
        val lines = file.readLines().toMutableList()

        val updatedLines = lines.map { line ->
            if (line.startsWith("pluginVersion = $version")) {
                "pluginVersion = $newVersion"
            } else {
                line
            }
        }

        file.writeText(updatedLines.joinToString(System.lineSeparator()) + System.lineSeparator())
    }

and call it before the changelog PR is created in release.yml action:

      # Update the artifact version
      - name: Update Version
        run: |
          ./gradlew updateVersion 

Alternatives you've considered

No response

Additional context

This could also be extended to handle major and minor releases alongside the patches - however for a first iteration updating the patch version would already be a great addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions