-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (115 loc) · 4.35 KB
/
dep-version-bump.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Update Dependency Versions
#######
# Updates versions for dependencies that are otherwise unmanaged by other processes.
#######
on:
schedule:
- cron: "0 20 * * SUN" # Sunday @ 2000 UTC
workflow_dispatch:
workflow_call:
inputs:
subdirectory:
description: "Whitespace-delimited list of directories containing pyproject.toml and tox.ini files; defaults to repo's base directory."
default: ""
type: string
create-changenote:
description: "Defaults 'true' to create a misc changenote in the './changes' directory."
default: true
type: boolean
workflow-repo:
# Only needed for PRs in other repos wanting to test new workflow changes before they are merged.
# These inputs should not be specified by another repo on their main branch.
description: "The repo to use to run additional workflows and actions."
default: "beeware/.github"
type: string
workflow-repo-ref:
description: "The repo ref to use to run additional workflows and actions."
default: ""
type: string
secrets:
BRUTUS_PAT_TOKEN:
required: true
permissions:
pull-requests: write
env:
BRANCH_PREFIX: "autoupdates"
CHANGENOTE_DIR: "./changes"
FORCE_COLOR: "1"
defaults:
run:
shell: bash
jobs:
dep-version-bump:
name: Bump Config File Dependencies
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout ${{ github.repository }}
uses: actions/[email protected]
with:
token: ${{ secrets.BRUTUS_PAT_TOKEN }}
path: "repo"
- name: Checkout ${{ inputs.workflow-repo }}${{ inputs.workflow-repo-ref && format('@{0}', inputs.workflow-repo-ref) || '' }}
uses: actions/[email protected]
with:
repository: ${{ inputs.workflow-repo }}
ref: ${{ inputs.workflow-repo-ref }}
path: "beeware-.github"
- name: Configure git
working-directory: "repo"
run: |
git config user.email "[email protected]"
git config user.name "Brutus (robot)"
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.X
- name: Install Dependencies
run: |
python -m pip install pip --upgrade
python -m pip install configupdater packaging requests tomlkit --upgrade --upgrade-strategy eager
- name: Update Versions
working-directory: "repo"
run: |
if [ "${{ inputs.subdirectory }}" == "" ]; then
python ../beeware-.github/scripts/bump_versions.py
else
for SUBDIR in ${{ inputs.subdirectory }}; do
python ../beeware-.github/scripts/bump_versions.py ${SUBDIR}
done
fi
- name: PR Needed?
id: pr
working-directory: "repo"
run: |
if [[ $(git status --porcelain) ]]; then
echo "needed=true" >> ${GITHUB_OUTPUT}
else
echo "needed=false" >> ${GITHUB_OUTPUT}
fi
- name: Create Pull Request
id: created-pr
if: steps.pr.outputs.needed == 'true'
uses: peter-evans/[email protected]
with:
token: ${{ secrets.BRUTUS_PAT_TOKEN }}
path: "repo"
title: "Bump dependencies in pyproject.toml and tox.ini"
branch: "${{ env.BRANCH_PREFIX }}/config-files"
commit-message: "Bump dependencies in pyproject.toml and tox.ini"
committer: "Brutus (robot) <[email protected]>"
author: "Brutus (robot) <[email protected]>"
body: "Bumps versions for dependencies in pyproject.toml and tox.ini."
labels: "dependencies"
- name: Add changenote
if: (inputs.create-changenote == true) && (steps.created-pr.outputs.pull-request-number != '')
working-directory: "repo"
run: |
BRANCH_NAME="${{ env.BRANCH_PREFIX }}/config-files"
git fetch origin
git checkout "${BRANCH_NAME}"
FILENAME="${{ env.CHANGENOTE_DIR }}/${{ steps.created-pr.outputs.pull-request-number }}.misc.rst"
printf 'The pinned dependencies in pyproject.toml and tox.ini were updated to their latest versions.\n' > "${FILENAME}"
git add "${FILENAME}"
git commit -m "Add changenote."
git push --set-upstream origin "${BRANCH_NAME}"