latest pins #1616
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 pip-tools ..." | |
shell: python | |
run: | | |
import re | |
import subprocess | |
def add(pyver: str): | |
subprocess.run([ | |
"poetry", "add", | |
"--directory", "${{ runner.temp }}", | |
"--no-interaction", | |
"--lock", | |
"--python", pyver, | |
"pip-tools" | |
], 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/pip-tools/json | jq -r .info.version) | |
git commit -m "update pins (pip-tools $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 (pip-tools $ver)" | |
git push | |
fi |