Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version.h to store the released version #87

Open
iamazeem opened this issue Dec 5, 2022 · 4 comments
Open

Add version.h to store the released version #87

iamazeem opened this issue Dec 5, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@iamazeem
Copy link
Collaborator

iamazeem commented Dec 5, 2022

Currently, there's no version file in the codebase.
The version is extracted using git command and used as a compile time macro VERSION wherever needed.
Also, the CI workflow is being updated with the historical released version. See:

TAG: "0.3.2"

Instead of hardcoding the released version as TAG in the CI, it is suggested to use a version.h header file as the default place to store version information e.g. version, branch, date, etc.

@iamazeem iamazeem added the enhancement New feature or request label Dec 5, 2022
@iamazeem
Copy link
Collaborator Author

iamazeem commented Dec 7, 2022

Template for version.h header file:

// THIS FILE IS AUTOMATICALLY GENERATED/UPDATED DURING BUILD.
// DO NOT EDIT THIS MANUALLY UNLESS YOU KNOW WHAT YOU'RE DOING!

#ifndef __VERSION_H__
#define __VERSION_H__

#define VERSION "x.y.z"

#endif // __VERSION_H__

// Could be more macros if required e.g. BRANCH, BUILD_TYPE, etc.

#pragma once may be used instead of header guards if all the targeted compilers support it i.e.:

// THIS FILE IS AUTOMATICALLY GENERATED/UPDATED DURING BUILD.
// DO NOT EDIT THIS MANUALLY UNLESS YOU KNOW WHAT YOU'RE DOING!

#pragma once

#define VERSION "x.y.z"

@liquidaty
Copy link
Owner

OK. Using this approach, how would the ci.yml script assign a value to TAG, if it isn't hardcoded?

@iamazeem
Copy link
Collaborator Author

Read the version from the version.h and set it as an env var in a separate step.
The subsequent steps will use this value.

The existing version itself would be used for a PR or direct commit.
For a new tag/release, the version.h will be updated, committed back to repo, and this version would be used.

@iamazeem
Copy link
Collaborator Author

iamazeem commented Dec 7, 2023

UPDATE

In addition, if the source code is downloaded via Code > Download ZIP button or from a release e.g. https://github.com/liquidaty/zsv/archive/refs/tags/v0.3.8-alpha.zip, after build/install, the zsv version command outputs zsv version 0.0.0-zsv (lib 0.0.0-zsv) and not the actual version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants