latest pins #417
This file contains 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
name: "latest pins" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '25 4,16 * * *' | |
jobs: | |
update_pins: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: main | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install poetry from PyPI | |
uses: install-pinned/poetry@d95a199a06c2eb4e23169dd4f7139bb645b9dbe2 # 1.3.2 | |
- run: poetry init --name lockenv --python "^3.8" --directory ${{ runner.temp }} --no-interaction | |
- name: "Run poetry add tox-uv ..." | |
shell: python | |
run: | | |
import re | |
import subprocess | |
def add(pyver: str): | |
subprocess.run([ | |
"poetry", "add", | |
"--directory", "${{ runner.temp }}", | |
"--no-interaction", | |
"--lock", | |
"--python", pyver, | |
"tox-uv" | |
], check=True, capture_output=True, text=True) | |
try: | |
add("*") | |
except subprocess.CalledProcessError as e: | |
if (m := re.search(r'set the `python` property to "(.+?)"', e.stderr)) is None: | |
raise | |
print(f"Retrying with --python {m[1]}...") | |
try: | |
add(m[1]) | |
except subprocess.CalledProcessError as e: | |
if (m := re.search(r'set the `python` property to "(.+?)"', e.stderr)) is None: | |
raise | |
print(f"Retrying with --python {m[1]}...") | |
# We need to retry twice for some projects. | |
add(m[1]) | |
- run: poetry export -o requirements.txt --directory ${{ runner.temp }} --no-interaction | |
- run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git config --global user.name "install-pinned bot" | |
git config --global user.email "[email protected]" | |
git add --all | |
ver=$(curl -Ls https://pypi.org/pypi/tox-uv/json | jq -r .info.version) | |
git commit -m "update pins (tox-uv $ver)" | |
commit=$(git rev-parse HEAD) | |
sed -i -E "s/@[0-9a-f]{40}.*/@$commit # $ver/g" README.md | |
git commit -am "update README.md (tox-uv $ver)" | |
git push | |
fi |