Created
December 16, 2021 14:53
-
-
Save bsnacks000/814e955f1cfec6a706a1188c79823362 to your computer and use it in GitHub Desktop.
version tag for github CI workflows with poetry
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
| """ | |
| Assuming you have pyproject.toml we will read in the current version tag into the environment tag: VERSION_TAG | |
| This will be available in your workflow now. | |
| Place this at the root of .github folder | |
| """ | |
| import toml | |
| import os | |
| import sys | |
| import logging | |
| l = logging.getLogger(__name__) | |
| if __name__ == '__main__': | |
| rootdir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | |
| try: | |
| proj = toml.load(os.path.join(rootdir, 'pyproject.toml')) | |
| except IOError as err: | |
| l.error(err) | |
| sys.exit(1) | |
| try: | |
| num = proj['tool']['poetry']['version'] | |
| print(f"VERSION_TAG={num}") | |
| except KeyError as err: | |
| l.error(err) | |
| sys.exit(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment