https://github.com/degree9/boot-semver
Semantic Versioning for boot projects.
https://github.com/degree9/boot-semver
boot-clj
Last synced: 9 days ago
JSON representation
Semantic Versioning for boot projects.
- Host: GitHub
- URL: https://github.com/degree9/boot-semver
- Owner: degree9
- License: mit
- Created: 2015-12-09T04:29:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-16T20:37:16.000Z (over 4 years ago)
- Last Synced: 2024-04-23T23:55:45.621Z (about 1 year ago)
- Topics: boot-clj
- Language: Clojure
- Size: 161 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://clojars.org/degree9/boot-semver)
[](https://clojars.org/degree9/boot-semver)
[](https://versions.deps.co/degree9/enterprise)
[![Slack][slack]][d9-slack]Semantic Versioning task for [boot-clj][1].
---
![]()
boot-semver is developed and maintained by Degree9---
* Provides `version` task
* Parses a `version.properties` file to read the current project version. Example content:
`VERSION=0.1.1-SNAPSHOT`
* Writes a new (if changed) [Maven compatible][2] version string to `version.properties`.
* Optionally includes the `version.properties` file in target output.
* Optionally generates a namespace containing version information.> The following outlines basic usage of the task, extensive testing has not been done.
> Please submit issues and pull requests!## Usage ##
Add `boot-semver` to your `build.boot` dependencies and `require` the namespace:
```clj
(set-env! :dependencies '[[degree9/boot-semver "X.Y.Z" :scope "test"]])
(require '[degree9.boot-semver :refer :all])
```Get the current project version:
```bash
boot version
```Use the `version` task when pushing to clojars:
```bash
boot version -y inc build-jar push-release
```Or use the `version` task in a deployment process:
```clojure
(deftask deploy
"Build boot-semver and deploy to clojars."
[]
(comp
(version :minor 'inc)
(build-jar)
(push-release)))
```## Task Options ##
The `version` task exposes a bunch of options for modifying the project version during a build pipeline.
Each option takes a quoted symbol (ex. `'inc`) which should resolve to an available function. This function will be applied to the current value of the project version component.```clojure
x major MAJ sym "Symbol of fn to apply to Major version."
y minor MIN sym "Symbol of fn to apply to Minor version."
z patch PAT sym "Symbol of fn to apply to Patch version."
r pre-release PRE sym "Symbol of fn to apply to Pre-Release version."
b build BLD sym "Symbol of fn to apply to Build version."
d develop bool "Prevents writing to version.properties file."
i include bool "Includes version.properties file in out-files."
g generate GEN sym "Generate a namespace with version information."
```The `:develop` option is provided for development tasks. These tasks will modify the project version number however, this version number will not be written back to the filesystem.
```clojure
(deftask dev
"Build boot-semver for development."
[]
(comp
(version :develop true
:minor 'inc
:pre-release 'snapshot)
(watch)
(build-jar)))
```The `:include` option is provided for adding the `version.properties` file to the output directory.
```clojure
(deftask dev
"Build boot-semver for development."
[]
(comp
(version :develop true
:minor 'inc
:pre-release 'snapshot
:include true)
(watch)
(build-jar)))
```The `:generate` option is provided for building a namespace containing a single variable `version` which will contain the the current version, it takes the namespace to be generated as input.
```clojure
(deftask dev
"Build boot-semver for development."
[]
(comp
(version :develop true
:minor 'inc
:pre-release 'snapshot
:generate 'degree9.boot-semver.version)
(watch)
(build-jar)))
```
```clojure
(ns degree9.boot-semver.version)(def version "1.4.3")
```## Continuous Deployment ##
The latest version of `boot-semver` now supports continuous versioning and deployment. This allows you to place the `version` task after the `watch` task to support updating the project version each time the files are changed. Additionally `build-jar`, `push-snapshot` and `push-release` are provided which support the new `version` task.
```clj
(deftask dev
"Continuously build and deploy snapshot."
[]
(comp
(watch)
(version :develop true
:pre-release 'snapshot
:generate 'degree9.boot-semver.version)
(build-jar)
(push-snapshot)))
```## Helpers ##
A few helper functions are provided to be used with the version task.
```clojure
;; Generic
'zero 'one 'two ... 'nine;; Pre-Release version helpers
'alpha ;; "alpha"
'beta ;; "beta"
'snapshot ;; "SNAPSHOT";; Build version helpers
'semver-date ;; "yyyyMMdd"
'semver-time ;; "hhmmss"
'semver-date-time ;; "yyyyMMdd-hhmmss"
'semver-date-dot-time ;; "yyyyMMdd.hhmmss"
'git-sha1-full ;; full git commit string
'git-sha1 ;; short git commit string (7 chars)
```---
![]()
Support this and other open-source projects on Patreon!---
[1]: https://github.com/boot-clj/boot
[2]: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm
[slack]: https://img.shields.io/badge/clojurians-degree9-%23e01563.svg?logo=slack
[d9-slack]: https://clojurians.slack.com/channels/degree9/