Skip to content

Commit

Permalink
meta.json semantic versioning (#33)
Browse files Browse the repository at this point in the history
* Use last v* git-tag for meta.json version

* docs: semver for meta.json

Co-authored-by: Willard <[email protected]>
  • Loading branch information
DerZade and TheWillard authored Mar 12, 2022
1 parent c6c95e7 commit 38a5924
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ else()
OUTPUT_VARIABLE GIT_BRANCH)

execute_process(
COMMAND git describe --tags --abbrev=0
OUTPUT_VARIABLE GIT_LAST_TAG
COMMAND git describe --tags --abbrev=0 --match v*
OUTPUT_VARIABLE GIT_LAST_VERSION
)

string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
string(STRIP "${GIT_LAST_TAG}" GIT_LAST_TAG)
string(STRIP "${GIT_LAST_VERSION}" GIT_LAST_VERSION)
string(REGEX REPLACE "^v" "" GIT_LAST_VERSION "${GIT_LAST_VERSION}")
endif()

set(VERSION "#include \"version.h\"
const std::string GRAD_MEH_GIT_REV = \"${GIT_REV}${GIT_DIFF}\";
const std::string GRAD_MEH_GIT_TAG = \"${GIT_TAG}\";
const std::string GRAD_MEH_GIT_BRANCH = \"${GIT_BRANCH}\";
const std::string GRAD_MEH_GIT_LAST_TAG = \"${GIT_LAST_TAG}\";
const std::string GRAD_MEH_GIT_LAST_VERSION = \"${GIT_LAST_VERSION}\";
")

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
Expand Down
7 changes: 4 additions & 3 deletions docs/meta_json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@
]
},
"version": {
"type": "number",
"description": "Version of meta.json specification.",
"type": "string",
"description": "Version of grad_meh",
"examples": [
0.1
"0.1.0",
"2.0.0-rc.1"
]
},
"worldName": {
Expand Down
2 changes: 1 addition & 1 deletion docs/metajson_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Inside this document the term "`MAP_CONFIG`" refers to the [CfgWorlds](https://
| `grids[i].zoomMax` | `number` | `0.949999988079071` | Max zoom at which grid is shown (same as [ctrlMapScale](https://community.bistudio.com/wiki/ctrlMapScale))<br>(corresponds to `MAP_CONFIG >> "Grid" >> <ZOOM> >> "zoomMax"`) |
| `latitude` | `number` | `-35.09700012207031` | Latitude of map<br>(corresponds to [`MAP_CONFIG >> "latitude"`](https://community.bistudio.com/wiki/Arma_3_CfgWorlds_Config_Reference#latitude)) |
| `longitude` | `number` | `16.8200035095215` | Longitude of map<br>(corresponds to [`MAP_CONFIG >> "longitude"`](https://community.bistudio.com/wiki/Arma_3_CfgWorlds_Config_Reference#longitude)) |
| `version` | `string` | `2.0.0-rc.1` | Version of `grad_meh` (This follows [semantic versioning](https://semver.org/)) |
| `colorOutside` | `array` | `[0.227451, 0.27451, 0.384314, 1]` | Outside color of map. _This property is optional and may be omitted, if the related config attribute does not exist._<br>(corresponds to [`MAP_CONFIG >> "OutsideTerrain" >> "colorOutside"`](https://community.bistudio.com/wiki/Arma_3_CfgWorlds_Config_Reference#class_OutsideTerrain)) |
| `version` | `number` | `0.1` | Version of `grad_meh` | |
| `worldName` | `string` | `"stratis"` | ID of map<br>(corresponds to LOWERCASE [`configName`](https://community.bistudio.com/wiki/configName) `MAP_CONFIG`) |
| `worldSize` | `number` | `8192` | Size of map in meters<br>(corresponds to [`MAP_CONFIG >> "mapSize"`](https://community.bistudio.com/wiki/Arma_3_CfgWorlds_Config_Reference#mapSize)) |

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void writeMeta(const std::string& worldName, const int32_t& worldSize, fs::path&
client::invoker_lock threadLock;
auto mapConfig = sqf::config_entry(sqf::config_file()) >> "CfgWorlds" >> worldName;
nl::json meta;
meta["version"] = GRAD_MEH_GIT_LAST_TAG;
meta["version"] = GRAD_MEH_GIT_LAST_VERSION;
meta["worldName"] = ba::to_lower_copy(worldName);
meta["worldSize"] = worldSize;
meta["author"] = sqf::get_text(mapConfig >> "author");
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
extern const std::string GRAD_MEH_GIT_REV;
extern const std::string GRAD_MEH_GIT_TAG;
extern const std::string GRAD_MEH_GIT_BRANCH;
extern const std::string GRAD_MEH_GIT_LAST_TAG;
extern const std::string GRAD_MEH_GIT_LAST_VERSION;

0 comments on commit 38a5924

Please sign in to comment.