-
Notifications
You must be signed in to change notification settings - Fork 204
74 lines (64 loc) · 2.48 KB
/
Copy pathupdate-python-versions.yml
File metadata and controls
74 lines (64 loc) · 2.48 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
name: Update Python versions
on:
schedule:
- cron: '0 0 1 * *' # first of each month
workflow_dispatch:
# Prevent races between overlapping scheduled and manual runs
# on the shared bot/update-python-versions branch.
concurrency:
group: update-python-versions
permissions:
contents: write
pull-requests: write
jobs:
update-python-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Run version update script
run: python .github/scripts/update_python_versions.py
- name: Check for changes
id: check_changes
run: |
if git diff --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push to bot branch
if: steps.check_changes.outputs.changed == 'true'
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git checkout -B bot/update-python-versions
git add \
setup.py \
tox.ini \
.github/workflows/ci.yml \
.github/workflows/release.yml \
README.md \
.pre-commit-config.yaml
git commit -m "Update tested and supported Python versions"
git push --force origin bot/update-python-versions
- name: Create pull request
if: steps.check_changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING_PR=$(gh pr list --head bot/update-python-versions --json number --jq '.[0].number // empty' 2>/dev/null || echo "")
if [ -z "$EXISTING_PR" ]; then
gh pr create \
--title "Update tested and supported Python versions" \
--body "$(cat <<'EOF'
Automated update of supported Python versions based on the [Python release cycle](https://devguide.python.org/versions/).
> This PR was automatically created by the [Update Python versions](${{ github.server_url }}/${{ github.repository }}/actions/workflows/update-python-versions.yml) workflow.
EOF
)" \
--base master \
--head bot/update-python-versions
else
echo "PR #$EXISTING_PR already exists for bot/update-python-versions — branch updated in place."
fi