Last active
August 13, 2024 07:17
-
-
Save XLTechie/e71edfe3ad8c31ebbd69edece515cb2e to your computer and use it in GitHub Desktop.
The "tagIt" bash script, used to generate tags for NVDA add-on repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # tagIt v2.0 | |
| # This script generates an appropriate git tag for an NVDA add-on's release. | |
| # Author: Luke Davis, @XLTechie on GitHub | |
| # By using this script, you agree that I have no responsibility for what you do with it, how you modify it, and | |
| # that I have provided no express or implied warranty. | |
| # I disclaim all responsibility for the outcome of your use, and hereby release it into the public domain. | |
| # | |
| # Usage: tagIt "the tag message" | |
| # When started from an add-on's git repository, it will determine the add-on | |
| # version number and channel from the buildVars.py file at the root of the repo. | |
| # It will then create a tag of the form: | |
| # v{version_number}{-channel} | |
| # E.g., for a stable (None) channel add-on, with version 24.1.3, the tag would be: | |
| # v24.1.3 | |
| # If that same add-on was in the dev channel: | |
| # v24.1.3-dev | |
| # Or in the beta channel: | |
| # v24.1.3-beta | |
| # Of course, you are responsible for making certain that the repo is on the correct commit and branch before running this. | |
| # You are also responsible for making sure that git actually pushes the tag, | |
| # so that any automation can perform an appropriate build based on the tagged version. | |
| # Use either: | |
| # git push --tags | |
| # or: | |
| # git push --follow-tags | |
| # or by setting the appropriate option in git config: | |
| # git config push.followTags true | |
| set -e | |
| dir=$(git rev-parse --show-toplevel ) ||{ | |
| echo 1>&2 "Not a git repository." | |
| exit 1 | |
| } | |
| python_bin=$(which python) || { | |
| echo 1>&2 "Can not find python on path $PATH" | |
| exit 2 | |
| } | |
| [ -r "$dir"/buildVars.py ] || { | |
| echo 1>&2 "Can not read \"$dir/buildVars.py\"" | |
| exit 3 | |
| } | |
| [ -z "$1" ] && { | |
| echo 1>&2 -e "Usage:\n$0 \"TAG MESSAGE\"\nWhere TAG MESSAGE is the message given to git for this tag, which is what makes it a full tag object." | |
| echo 2>&1 "You almost certainly want to quote it, to escape it from the shell." | |
| exit 4 | |
| } | |
| eval $({ | |
| cat "$dir"/buildVars.py | |
| cat <<EOD | |
| tag = f'v{addon_info["addon_version"]}' | |
| if addon_info["addon_updateChannel"] is not None: | |
| tag += f'-{addon_info["addon_updateChannel"]}' | |
| print(f"echo Tagging {tag};") | |
| print(f"git tag {tag} -m '$1'") | |
| EOD | |
| } | $python_bin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment