@@ -7,7 +7,7 @@ There are two sbt plugins in this one plugin library:
77
88# Compatibility
99
10- Tested and supported for sbt version 0.13.x and above.
10+ Tested and supported for sbt versions: 0.13.17, 1.1.6, and 1.2.1
1111
1212# Install
1313
@@ -24,12 +24,17 @@ In either case, you should now be able to add the plugin dependency to `project/
2424``` scala
2525 addSbtPlugin(" com.rallyhealth.sbt" % " sbt-git-versioning" % " x.y.z" )
2626```
27- 3 . Enable the plugin.
27+ 3 . Enable the SemVer plugin to enforce SemVer with MiMa. (Important for shared libraries, not so much for personal apps)
2828
2929``` scala
3030val example = project
3131 .enablePlugins(SemVerPlugin )
3232```
33+ 4 . Add a ` gitVersioningSnapshotLowerBound ` placeholder in build.sbt.
34+ ``` sbt
35+ // Uncomment when you're ready to start building 1.0.0-...-SNAPSHOT versions.
36+ // gitVersioningSnapshotLowerBound in ThisBuild := "1.0.0"
37+ ```
3338
3439# GitVersioningPlugin
3540
@@ -40,9 +45,7 @@ previous tags) and the state of the working directly. Read on for the exact deta
4045## Usage
4146
4247This plugin will automatically determine and set the ` version ` setting on startup. There is nothing developers need to
43- explicitly do. You can use ` sbt publishLocal ` to create a local snapshot artifact or, if you have a snapshot repository,
44- you can ` sbt publish ` at the end of a continuous integration pipeline that is triggered on pull requests, so that you
45- can easily pull one snapshot into another for testing.
48+ explicitly do. You can ` publishLocal ` and PRs and use the created snapshot artifacts anywhere you would a release artifact.
4649
4750You will see additional log statements like:
4851```
@@ -149,6 +152,7 @@ ensure that any git plugins are configured to not use shallow clones.
149152## Creating a Release
150153
151154### Recommended: -Drelease
155+
152156Creating a release is done by passing a [ release arg] ( #release-arg-property ) .
153157```
154158sbt -Drelease=patch publish[Local]
@@ -166,13 +170,15 @@ git push origin "v${VERSION}"
166170` ` `
167171
168172# ## Possible: tag + sbt-git-versioning
173+
169174...or by tagging and then publishing a release...
170175 ` ` `
171176git tag v1.2.3
172177sbt publish[Local]
173178` ` `
174179
175180# ## Not recommended (unless have good reasons): version.override
181+
176182...or by overriding the version that will be applied to a specific build, using the
177183` version.override` setting. Typically this is done by at the command line to avoid changing ` build.sbt` .
178184` ` `
@@ -203,121 +209,19 @@ You can run the check manually using `semVerCheck`. The check and also be run au
203209* *Publish* - If `semVerCheckOnPublish` is set to true (the default) it will check **before** you publish
204210* *PublishLocal* - If `semVerCheckOnPublish` is set to true (the default) it will check **before** you publishLocal
205211
206- The output will look like this:
207- ```
208- [info] [SemVer] Checking ENABLED with LIMIT target semVerLimit=3.0.0
209- [info] [SemVer] Check starting (prev=2.0.0 vs curr=3.0.0) ...
210- [warn] [SemVer] Errors total=4, backward=0, forward=4, required diffType=minor
211- [warn] [SemVer] (1/4) Forward -> method calamity()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
212- [warn] [SemVer] (2/4) Forward -> method princessLuna()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
213- [warn] [SemVer] (3/4) Forward -> method starlightGlimmer()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
214- [warn] [SemVer] (4/4) Forward -> method velvetRemedy()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
215- [warn] [SemVer] version=3.0.0 PASSED: required diffType=Minor achieved
216- [success] Total time: 2 s, completed Nov 15, 2016 3:38:48 PM
217- ```
218-
219212When the SemVerPlugin halts the build it will look like:
220213```
221- [info] [SemVer] Checking ENABLED with LIMIT target semVerLimit=2.0.1
222- [info] [SemVer] Check starting (prev=2.0.0 vs curr=2.0.1) ...
223- [error] [SemVer] Errors total=4, backward=0, forward=4, required diffType=minor
224- [error] [SemVer] (1/4) Forward -> method calamity()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
225- [error] [SemVer] (2/4) Forward -> method princessLuna()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
226- [error] [SemVer] (3/4) Forward -> method starlightGlimmer()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
227- [error] [SemVer] (4/4) Forward -> method velvetRemedy()Double in class com.rallyhealth.sbt.semver.Equestria does not have a correspondent in previous version
228- [error] [SemVer] version=2.0.1 FAILED: required diffType=minor NOT achieved
229- java.lang.IllegalStateException: Proposed RELEASE version=2.0.1 FAILED SemVer rules, failing build
230- at com.rallyhealth.sbt.semver.SemVerHalter.haltBuild(SemVerHalter.scala:86)
231- ...
232- [error] (*:compile) java.lang.IllegalStateException: Proposed RELEASE version=2.0.1 FAILED SemVer rules, failing build
233- [error] Total time: 2 s, completed Nov 15, 2016 3:27:36 PM
214+ [error] (api/*:semVerCheck) com.rallyhealth.sbt.semver.SemVerVersionTooLowException: Your changes have new functionality and binary incompatibilites which violates the http://semver.org rules for a Minor release.
215+ [error]
216+ [error] Specifically, MiMa detected the following binary incompatibilities:
217+ [error] (1/1) Backward -> method url(java.lang.String)com.rallyhealth.rq.v1.RqRequest in object com.rallyhealth.rq.v1.Rq does not have a correspondent in current version
218+ [error]
219+ [error] These changes would require a Major release instead (1.9.0 => 2.0.0).
220+ [error] You can adjust the version by adding the following setting:
221+ [error] gitVersioningSnapshotLowerBound in ThisBuild := "2.0.0"
222+ [error] Total time: 0 s, completed Jul 13, 2018 3:49:57 PM
234223```
235224
236- ### semVerLimit
237-
238- `semVerLimit` is a version (e.g. "1.2.3") that tells SemVerPlugin when to halt the build. It prevents you from making any
239- compatibility changes that would *exceed* that version.
240-
241- Defaults:
242- - Release builds - same as version (version=1.2.3, semVerLimit=1.2.3).
243- - Snapshot builds - set to highest version before next major release (version=1.2.3-SNAPSHOT, semVerLimit=1.999.999).
244-
245- You may explicitly set `semVerLimit` to alter this behavior.
246-
247- #### Examples
248-
249- This is best explained with an example. Let' s assume the latest tag is ` 1.2.3` :
250-
251- * ` semVerLimit := 1.2.3` - you won' t be able to make *any* changes
252- * `semVerLimit := 1.2.**999**` - you will be allowed to make *patch* changes.
253- * `semVerLimit := 1.**999.999**` - you will be allowed to make *minor or patch* changes. (This is the default value.)
254- * `semVerLimit := ""` - you will be allowed to make *major, minor, or patch* changes (`semVerLimit` is disabled)
255-
256- Here are a few stories to illustrate how `semVerLimit` works.
257-
258- #### Patch Change
259-
260- 1. Version is `1.2.3` and `semVerLimit := 1.9.9`:
261- 2. Fluttershy needs to fix a bug (patch change).
262- 3. Fluttershy fixes, sees no backward or forward errors from SemVerPlugin.
263- 4. Fluttershy commits, PRs, and merges.
264- 5. Fluttershy successfully runs the release job for `1.2.4`.
265-
266- #### Minor Change (with a human error)
267-
268- 1. Version is `1.2.4` (from above) and `semVerLimit := 1.9.9` (the default value):
269- 2. Applejack wants to add a new method (minor change).
270- 3. Applejack adds the new method, commits, PRs, and merges.
271- 4. Applejack runs the release job for `1.2.4` but the release job fails.
272- 5. SemVerPlugin' s errors in the logs say that she needs to make a ` minor` release (e.g. ` 1.3.0` ).
273- 6. Applejack successfully runs the release job for ` 1.3.0` .
274-
275- # ### A 'Big' Patch Change
276-
277- 1. Version is ` 1.3.0` (from above) and ` semVerLimit := 1.9.9` (the default value):
278- 2. Twilight Sparkle found a potential bug for an edge case, e.g. some
279- ' undefined' behavior. She only needs to make a * patch* change, but
280- someone could be relying on that ' undefined' behavior, she wants to release
281- a * minor* change
282- 3. Twilight Sparkle fixes, sees no backward or forward errors from SemVerPlugin.
283- 4. Twilight Sparkle commits, PRs, and merges.
284- 5. Twilight Sparkle successfully runs the release job for ` 1.**4**.0` (* minor*
285- change even though only * patch* was required)
286-
287- # ### Hot Fix (patch change)
288-
289- 1. Version is ` 1.4.0` (from above) and ` semVerLimit := 1.9.9` (the default value):
290- 2. Rainbow Dash needs to make a hot fix.
291- 3. Rainbow Dash changes ` semVerLimit := 1.4.1` so she' s absolutely sure no minor changes sneak in.
292- 4. Rainbow Dash makes her fix, commits, PRs, and merges
293- 5. Rainbow Dash successfully runs the release job for `1.4.1`.
294- 6. *Unfortunately the next committer will need to reset `semVerLimit := 1.9.9`*
295- 7. Rainbow Dash helpfully merges a PR to revert `semVerLimit := 1.9.9`
296-
297- #### Hot Fix Redux (patch change)
298-
299- 1. Version is `1.4.1` (from above) and `semVerLimit := 1.9.9` (the default value):
300- 2. Pinkie Pie needs to make another hot fix.
301- 3. Pinkie Pie does not want to do a clean up commit like Rainbow Dash.
302- 4. Pinkie Pie runs SBT and executes ```> set semVerLimit := 1.4.2``` before any other command.
303- 5. Pinkie Pie makes her fix, commits, PRs
304- 6. Pinkie Pie successfully runs the release job for `1.4.2`.
305-
306- #### Major Change
307-
308- 1. Version is `1.4.2` (from above) and `semVerLimit := 1.9.9` (the default value):
309- 2. Rarity wants to make a major breaking API change.
310- 3. Rarity changes `gitVersioningSnapshotLowerBound := 2.0.0` which automatically raises default `semVerLimit := 2.9.9`.
311- 4. Rarity makes her API change, commits, PRs, and merges.
312- 5. Rarity successfully runs the release job for `2.0.0`.
313-
314- #### What should you choose for `semVerLimit`?
315-
316- * First, talk to the team working on the service, or the users of the library. What do they want?
317- * If you want to allow any backward compatible changes might choose the default limit (e.g. `semVerLimit := 1.999.999`).
318- * If you want to avoid changes you might choose a limit like `semVerLimit := 1.0.999`
319- * If you don' t care about * any* changes you can disable the limt using ` semVerLimit := " " ` .
320-
321225## Information
322226
323227SemverPlugin is built on top of [Typesafe' s migration-manager tool](https://github.com/typesafehub/migration-manager).
@@ -331,4 +235,4 @@ Then it uses that artifact as the baseline and compares against your changes.
331235* When adding a new sub-module within an existing module, be sure to add ` semVerEnforceAfterVersion` in the sbt settings
332236 and that version is a minor update.
333237
334- Example: Current tag is 1.3.4. Then the sbt sub-module settings should have `semvVerEnforceAfterVersion := 1.4.0`
238+ Example: Current tag is 1.3.4. Then the sbt sub-module settings should have ` semVerEnforceAfterVersion := Some( " 1.4.0" ) `
0 commit comments