-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (59 loc) · 2.34 KB
/
update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 mitmproxy ..."
shell: python
run: |
import re
import subprocess
def add(pyver: str):
subprocess.run([
"poetry", "add",
"--directory", "${{ runner.temp }}",
"--no-interaction",
"--lock",
"--python", pyver,
"mitmproxy"
], 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/mitmproxy/json | jq -r .info.version)
git commit -m "update pins (mitmproxy $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 (mitmproxy $ver)"
git push
fi