Skip to content

Commit

Permalink
cd(bump-version): add get_version script (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsmrynk authored Aug 9, 2024
1 parent bb3f392 commit e47a3ca
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Bump version
run: |
python dev/scripts/bump_version.py --bump-type ${{ github.event.inputs.bump_type }}
echo "BUMPED_VERSION=$(python -c 'from aviary import __version__; print(__version__)')" >> $GITHUB_ENV
echo "BUMPED_VERSION=$(python dev/scripts/get_version.py)" >> $GITHUB_ENV
- name: Create pull request
uses: peter-evans/create-pull-request@v6
Expand Down
Empty file added dev/scripts/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions dev/scripts/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytz

from aviary import __version__
from .get_version import get_version


def bump_version(
Expand Down Expand Up @@ -99,7 +99,7 @@ def bump_citation_version(
)
args = parser.parse_args()

version = __version__
version = get_version()
bumped_version = bump_version(
version=version,
bump_type=args.bump_type,
Expand Down
27 changes: 27 additions & 0 deletions dev/scripts/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path


def get_version() -> str:
"""Returns the current version.
Returns:
current version
Raises:
ValueError: Invalid version
"""
package_path = Path(__file__).parents[2] / 'aviary' / '__init__.py'

with package_path.open() as file:
lines = file.readlines()

for line in lines:
if line.startswith('__version__ = '):
return line.split('=')[1].strip().strip("'")

message = 'Invalid version!'
raise ValueError(message)


if __name__ == '__main__':
print(get_version())
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ multiline-quotes = "single"
"T201",
]
"dev/scripts/*" = [
"INP001",
"T201",
]
"**/tests/*" = [
"D103",
Expand Down

0 comments on commit e47a3ca

Please sign in to comment.