-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython--daily-dependencies-update.yml
More file actions
94 lines (83 loc) · 3.61 KB
/
Copy pathpython--daily-dependencies-update.yml
File metadata and controls
94 lines (83 loc) · 3.61 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This workflow updates pip library dependencies every day and opens a pull
# request when any dependency changes are detected.
name: Python - Daily Dependencies Update
on:
schedule:
# 0:00 JST every day
- cron: "0 15 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update_pip_library_dependencies:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup-python
- name: Update pip Library Dependencies
working-directory: ./python
run: |
pip install --upgrade pip
sed -E 's/==.*//' requirements.txt | xargs pip install --upgrade
pip freeze > requirements.lock
pip --version | awk '{print "pip==" $2}' >> requirements.lock
- name: Mirror Updated Versions to requirements.txt
working-directory: ./python
run: |
python - <<'PY'
import re
from importlib.metadata import version
with open('requirements.txt') as f:
lines = f.read().splitlines()
with open('requirements.txt', 'w') as f:
for line in lines:
m = re.match(r'([A-Za-z0-9._-]+)==\S+$', line.strip())
f.write(f'{m.group(1)}=={version(m.group(1))}\n' if m else line + '\n')
PY
- name: Generate Pull Request Description
env:
BODY_PATH: ${{ runner.temp }}/pr_body.md
run: |
{
cat <<'OVERVIEW'
## 1. Overview
This pull request was created automatically by the Python - Daily Dependencies Update workflow.
It upgrades pip itself, upgrades every library listed in requirements.txt to the latest available versions, regenerates requirements.lock (which also records the pip version), and mirrors the updated versions to requirements.txt:
~~~console
pip install --upgrade pip
sed -E 's/==.*//' requirements.txt | xargs pip install --upgrade
pip freeze > requirements.lock
pip --version | awk '{print "pip==" $2}' >> requirements.lock
~~~
## 2. Key Changes & Differences
OVERVIEW
echo
bash .github/scripts/dependency_report.sh pip python/requirements.lock python/requirements.txt Libraries
cat <<SUMMARY
## 3. Summary
All pip library dependencies in python/requirements.txt and python/requirements.lock are now up to date.
Please make sure that all CI workflows pass before merging this pull request.
## 4. References
- [Python - Daily Dependencies Update workflow run](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)
- [pip install documentation](https://pip.pypa.io/en/stable/cli/pip_install/)
- [PyPI](https://pypi.org/)
SUMMARY
} > "$BODY_PATH"
- name: Compute Timestamp
run: echo "TIMESTAMP=$(TZ=Asia/Tokyo date '+%Y-%m-%d %H:%M:%S JST')" >> "$GITHUB_ENV"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
sign-commits: true
branch: hayat01sh1da/daily/python/update-pypi-library-dependencies
delete-branch: true
add-paths: |
python/requirements.txt
python/requirements.lock
commit-message: "[Daily][Python] Update PyPI library dependencies at ${{ env.TIMESTAMP }}"
title: "[Daily][Python] Update PyPI Library Dependencies"
body-path: ${{ runner.temp }}/pr_body.md
reviewers: hayat01sh1da
assignees: hayat01sh1da