Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate version update after release #485

Open
strangelookingnerd opened this issue Nov 4, 2024 · 0 comments
Open

Automate version update after release #485

strangelookingnerd opened this issue Nov 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@strangelookingnerd
Copy link
Contributor

strangelookingnerd commented Nov 4, 2024

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.

@strangelookingnerd strangelookingnerd added the enhancement New feature or request label Nov 4, 2024
@strangelookingnerd strangelookingnerd changed the title Automate Update version after release Automate version update after release Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant