Skip to content

Commit

Permalink
add just file for updating python versions
Browse files Browse the repository at this point in the history
update justfile

update justfile

update justfile

update justfile

correct justfile
  • Loading branch information
trappitsch committed Oct 22, 2024
1 parent e1afd3e commit 3b5a4c1
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[positional-arguments]
pin python_version:
rye pin {{python_version}} --relaxed
rye sync
rye test

[positional-arguments]
update_workflow minimum_version maximum_version:
#! /usr/bin/env python3
from pathlib import Path
import sys

workflow = Path('.github/workflows/package_testing.yml')

vmin = sys.argv[1]
vmax = sys.argv[2]

minor_min = int(vmin.split(".")[1])
minor_max = int(vmax.split(".")[1])

with open(workflow) as f:
content = f.readlines()

for it, line in enumerate(content):
if "MAIN_PYTHON_VERSION: " in line:
print(it)
content[it] = f' MAIN_PYTHON_VERSION: "{vmax}"\n'
elif "python-version:" in line:
new_line = f' python-version: ['
for jt in range(minor_min, minor_max):
new_line += f'"3.{jt}", '
new_line += f'"3.{minor_max}"]\n'
content[it] = new_line

with open(workflow, 'w') as f:
f.writelines(content)

[positional-arguments]
python_update minimum_version maximum_version:
# ensure git is clean
git status | grep "nothing to commit" || exit 1

just pin {{maximum_version}}
just update_workflow {{minimum_version}} {{maximum_version}}

# git add and commit

git checkout -b 'update-python-{{maximum_version}}'

git add .
git commit -m "Update supported python to {{maximum_version}}, minimum version {{minimum_version}}"

git push origin 'update-python-{{maximum_version}}'

# create PR with gh
gh pr create --title "Update supported python to {{maximum_version}}, minimum version {{minimum_version}}" --body "This PR updates the supported python version to {{maximum_version}}, with a minimum version of {{minimum_version}}"

0 comments on commit 3b5a4c1

Please sign in to comment.