scalacenter / sbt-version-policy

Compatibility checks for your dependencies
Apache License 2.0
82 stars 14 forks source link

Simplify integration with sbt-release #187

Closed julienrf closed 11 months ago

julienrf commented 11 months ago

There are still a couple of issues to address, IMHO:

julienrf commented 11 months ago

One limitation is that the mode “compute the release version from the level of compatibility with the last release” does not work for the first release. This means you would have to publish a first release in a way, and then update the release workflow to publish the next releases. Ideally, it would be great to define the release workflow once and also handle the first release with it.

julienrf commented 11 months ago

I added a commit that

I am now happy with the content of the PR, could you please have a look @rtyley?

rtyley commented 11 months ago

Just because they're the maintainer of sbt-release, and this PR might be interesting to them, I'm just going to @-mention @xuwei-k here (apologies, @xuwei-k, if this is not of interest, feel free to ignore!).

This PR is adding support for a new custom versioning strategy that determines the new version number based on sbt-version-policy's assessment of the binary/source compatibility of the new release with the previous release, using the recommended Scala semver rules.

An example of how this might used with sbt-release in a project is in https://github.com/guardian/etag-caching/pull/21, here - it doesn't necessitate either sbt-release or sbt-version-policy having a dependency on each other (because the exposed interface is really just String => String for the version number), though we did copy & paste a small amount of code from sbt-release (Version.scala - both projects are Apache V2) to parse version-numbers and calculate a version string with the appropriate bump.

import sbtversionpolicy.withsbtrelease.ReleaseVersion

...

releaseVersion := {
   ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value
}

We haven't used this code in earnest yet, but should have something usable by sometime next week!