Skip to content

Commit 41a51d1

Browse files
committed
pip-tools will survive us all
1 parent 68eadd7 commit 41a51d1

File tree

8 files changed

+93
-605
lines changed

8 files changed

+93
-605
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update dependencies
2+
3+
# Stolen from https://www.oddbird.net/2022/06/01/dependabot-single-pull-request/
4+
5+
on:
6+
workflow_dispatch: # Allow running on-demand
7+
schedule:
8+
# Runs every 1st of Month at 3:25 UTC
9+
- cron: "25 3 1 * *"
10+
11+
jobs:
12+
upgrade:
13+
name: Upgrade & Open Pull Request
14+
runs-on: ubuntu-latest
15+
env:
16+
# This branch will receive updates each time the workflow runs
17+
# It doesn't matter if it's deleted when merged, it'll be re-created
18+
BRANCH_NAME: auto-dependency-upgrades
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
# START PYTHON DEPENDENCIES
23+
- uses: actions/setup-python@v3
24+
with:
25+
python-version: "3.10"
26+
cache: pip
27+
cache-dependency-path: "**/pip-tools.txt"
28+
29+
- name: Upgrade Python dependencies
30+
# ADD YOUR CUSTOM DEPENDENCY UPGRADE COMMANDS BELOW
31+
run: |
32+
pip install -U pip pip-tools
33+
pip-compile --upgrade -o requirements/tools.txt requirements/tools.in
34+
# END PYTHON DEPENDENCIES
35+
- name: Detect changes
36+
id: changes
37+
run:
38+
# This output boolean tells us if the dependencies have actually changed
39+
echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >>$GITHUB_OUTPUT
40+
- name: Commit & push changes
41+
# Only push if changes exist
42+
if: steps.changes.outputs.count > 0
43+
run: |
44+
git config user.name github-actions
45+
git config user.email [email protected]
46+
git add .
47+
git commit -m "Automated dependency upgrades"
48+
git push -f origin ${{ github.ref_name }}:${{ env.BRANCH_NAME }}
49+
- name: Open pull request if needed
50+
if: steps.changes.outputs.count > 0
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
# Only open a PR if the branch is not attached to an existing one
54+
run: |
55+
PR=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number -q '.[0].number')
56+
if [ -z $PR ]; then
57+
gh pr create \
58+
--head ${{ env.BRANCH_NAME }} \
59+
--title "Automated dependency upgrades" \
60+
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
61+
else
62+
echo "Pull request already exists, won't create a new one."
63+
fi

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
__pypackages__
2-
build_and_inspect_python_package.egg-info
3-
.pdm-python

Justfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

pdm.lock

Lines changed: 0 additions & 586 deletions
This file was deleted.

pyproject.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

requirements/pip-tools.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pip-tools
2+
wheel

requirements/pip-tools.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.12
3+
# by the following command:
4+
#
5+
# pip-compile --no-emit-index-url --output-file=requirements/pip-tools.txt requirements/pip-tools.in
6+
#
7+
build==1.0.3
8+
# via pip-tools
9+
click==8.1.7
10+
# via pip-tools
11+
packaging==23.2
12+
# via build
13+
pip-tools==7.3.0
14+
# via -r requirements/pip-tools.in
15+
pyproject-hooks==1.0.0
16+
# via build
17+
wheel==0.41.2
18+
# via
19+
# -r requirements/pip-tools.in
20+
# pip-tools
21+
22+
# The following packages are considered to be unsafe in a requirements file:
23+
# pip
24+
# setuptools

requirements/tools.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
check-wheel-contents
3+
twine
4+
wheel

0 commit comments

Comments
 (0)