Skip to content

Commit

Permalink
script: rename script to project-version
Browse files Browse the repository at this point in the history
This commit also remove mentions to Zephyr project and instead provide
three outputs format:
- h for C header
- hpp for cpp header
- cmake for cmake file (zephyr porject for exemple)
  • Loading branch information
AlexFabre committed Nov 15, 2024
1 parent b620737 commit 5732fbb
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
- name: Codespell action
uses: codespell-project/actions-codespell@v2
with:
ignore_words_list: rever
ignore_words_list: project-version

6 changes: 3 additions & 3 deletions .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- name: Run rever on itself
run: ./rever.sh -l -o base_version.h -f base -t v
- name: Run project-version on itself
run: ./project-version.sh -l -o version.h -f h -t v

- name: Checking version
run: ci-script/check_rever_version.sh rever.sh base_version.h
run: ci-script/check_script_self_version.sh project-version.sh version.h
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Generated file (base format)
# Generated file
version.h

# Generated file (Zephyr format)
version.hpp
VERSION
63 changes: 29 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rever
# project-version

A little POSIX shell script that generates a C header containing the version information (Major Minor etc...) of a Git based repository.

Expand All @@ -11,15 +11,15 @@ The script simply parses the `git describe` command to extract the firmware info
The script will generate a C header file.

```sh
./rever.sh -o project/include/version.h
./project-version.sh -o project/include/version.h
```

### Zephyr project

The script will generate the cmake version file.

```sh
./rever.sh -f zephyr -o cmake-project/VERSION
./project-version.sh -f zephyr -o cmake-project/VERSION
```

## Requirements
Expand All @@ -29,23 +29,24 @@ The script will generate the cmake version file.

## Usage

Clone the repo or simply copy the `rever.sh` script into your repository and let the magic happen.
Clone the repo or simply copy the `project-version.sh` script into your repository and let the magic happen.

All available options can be listed with option `-h`

~~~sh
$ ./rever.sh -h
==> rever.sh 0.5.0
$ ./project-version.sh -h
==> project-version.sh 0.6.0
A little POSIX shell script to generate
version information for your C project.
ref: https://github.com/AlexFabre/rever
ref: https://github.com/AlexFabre/project-version
Usage:
rever.sh <options>
-f <project format>
-f zephyr: Generate a 'VERSION' file, specific to zephyr projects
-f base: (default) Generate the basic rever format file
-o <output file>
-t <git tag format> (default 'v')
project-version.sh <options>
-f <output format>
-f h : (default) Generate a C header file (.h).
-f hpp : Generate a C++ header file (.hpp).
-f cmake : Generate a cmake variable file.
-o <output file name>
-t <git tag format> (default 'v') (ex. 'v' will match tags 'v0.3.1' and 'v0.2.1-beta' but not tags '1.3.4' nor 'version3.2.3')
-h <help>
-v <script version>
-l <script logs> (default none)
Expand All @@ -56,15 +57,15 @@ rever.sh <options>
~~~c
/**
* @file version.h
* @brief version information of project build
* @brief This file declares the firmware revision information
*
* Generated with rever.sh 0.5.0
* Generated with project-version.sh 0.6.0
* A little POSIX shell script to generate
* version information for your C project.
* ref: https://github.com/AlexFabre/rever
* ref: https://github.com/AlexFabre/project-version
*
* Do not edit this file manually. Its content
* is generated with rever.sh script.
* is generated with project-version.sh script.
*/
#ifndef VERSION_H__
#define VERSION_H__
Expand All @@ -75,43 +76,37 @@ rever.sh <options>
#define VERSION_PATCH 0

/* Git repo info */
#define VERSION_BRANCH_NAME "feat/add-zephyr-compatibility"
#define VERSION_NB_COMMITS_SINCE_LAST_TAG 6
#define VERSION_COMMIT_SHORT_SHA "08df77b"
#define VERSION_BRANCH_NAME "main"
#define VERSION_NB_COMMITS_SINCE_LAST_TAG 3
#define VERSION_COMMIT_SHORT_SHA "b620737"

/* Build date time (UTC) */
#define VERSION_BUILD_DAY 29
#define VERSION_BUILD_MONTH 10
#define VERSION_BUILD_DAY 15
#define VERSION_BUILD_MONTH 11
#define VERSION_BUILD_YEAR 2024
#define VERSION_BUILD_HOUR 11
#define VERSION_BUILD_HOUR 9

#endif /* VERSION_H__ */

~~~

### Example of generated header for Zephyr project

~~~txt
# This file declares the firmware revision information
# both for cmake and for mcuboot
#
# ref: https://docs.zephyrproject.org/latest/build/version/index.html
#
# Generated with rever.sh 0.5.0
# Generated with project-version.sh 0.6.0
# A little POSIX shell script to generate
# version information for your C project.
# ref: https://github.com/AlexFabre/rever
# ref: https://github.com/AlexFabre/project-version
#
# Do not edit this file manually. Its content
# is generated with rever.sh script.
# is generated with project-version.sh script.
VERSION_MAJOR = 0
VERSION_MINOR = 5
PATCHLEVEL = 0
VERSION_TWEAK = 6
EXTRAVERSION = "feat/add-zephyr-compatibility08df77b"
VERSION_TWEAK = 3
EXTRAVERSION = main
~~~

## Code quality
Expand Down
Loading

0 comments on commit 5732fbb

Please sign in to comment.