🔍 get-version.sh
This script is used to retrieve the current version of the application from a specified version file.
The script performs the following operations:
- VERSION_FILE_PATHis either loaded from the environment or, if it's not present in the environment, it defaults to- src/beans_logging/__version__.py.
- It first checks if the VERSION_FILE_PATHvariable is not empty and if the file exists. If these conditions are met, it retrieves the value of__version__from the file by usinggrep,awk, andtrcommands. Thegrepcommand filters the line containing__version__ =, theawkcommand splits the line into two parts at=, and thetrcommand removes the quotes around the version. If these operations fail, it exits the script with status code2.
- If the VERSION_FILE_PATHvariable is empty or the file does not exist, it sets the current version to0.0.0.
- Finally, it echoes the current version to the console.
Usage:
To execute the get version script, simply run the following command in the terminal:
This script can be used to conveniently fetch the version. It is used by the bump-version.sh script to retrieve the current version before incrementing it.