Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include project version from git in /api/v2/service/info
Git tags are used to identify releases of the MapRoulette backend. This commit adds a few useful git and version settings in the response of route /api/v2/service/info. The algorithm to determine the version is described by [sbt-git in their manual](https://github.com/sbt/sbt-git#versioning-with-git), and we use git describe. Here is the snippet from the readme: The git plugin will now autogenerate your version using the following rules, in order: 1. Looks at version-property setting (default to `project.version`), and checks the `sys.props` to see if this has a value. If so, use it. 2. Otherwise, looks at the project tags. The first to match the `gitTagToVersionNumberSetting` is used to assign the version. The default is to look for tags that begin with `v` and a number, and use the number as the version. If there are multiple version tags, it will pick the highest. 3. If no tags are found either, look at the head commit. We attach this to the `git.baseVersion` setting: "<base-version>.<git commit sha>" 4. If no head commit is present either (which means this is a brand-new repository with no commits yet), we append the current timestamp to the base version: "<base-version>.<timestamp>". This way the version is derived by passing the result of `git describe` to the `gitTagToVersionNumber` function. The `describe` version is built from the last tag + number of commits since tag + short hash. We recommend adopting the git describe approach. Example response json: ```json { "compiletime": { "name": "MapRouletteAPI", "version": "4.4.4-test1", "scalaVersion": "2.13.10", "sbtVersion": "1.7.2", "buildDate": "2023-08-23", "javaVersion": "11.0.20", "javaVendor": "Eclipse Adoptium", "gitDescribe": "4.4.4-test1", "gitHasUncommitedChanges": false, "gitHeadCommit": "ed5fcead860265a6522da2e80d18ce9b102ab8ca", "gitHeadCommitUrl": "ed5fcea", "gitHeadCommitDate": "2023-08-23T00:40:42-0500" }, "runtime": { "javaVersion": "11.0.20", "javaVendor": "Eclipse Adoptium", "startDateTime": "2023-08-23T05:43:08.317823" } } ```
- Loading branch information