Skip to content

Commit

Permalink
add just file for updating python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
trappitsch committed Oct 22, 2024
1 parent e1afd3e commit a60f455
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 $1 --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 $1
just update_workflow $1 $2

# git add and commit
export BRANCH_NAME="update_python_$2"
git checkout -b $BRANCH_NAME

git add .
git commit -m "Update supported python to $2, minimum version $1"

git push origin $BRANCH_NAME

# create PR with gh
gh pr create --title "Update supported python to $2, minimum version $1" --body "This PR updates the supported python version to $2, with a minimum version of $1" --base main --head $BRANCH_NAME

0 comments on commit a60f455

Please sign in to comment.