Skip to content

Commit 0735a7f

Browse files
committed
Enhance upgrade workflow: age check, dedup, issue tracking
1 parent 2aeb918 commit 0735a7f

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

.github/workflows/upgrade.yaml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,35 @@ jobs:
4141
echo "changed=false" >> "$GITHUB_OUTPUT"
4242
echo "### All embedded dependencies are up to date" >> "$GITHUB_STEP_SUMMARY"
4343
fi
44-
- name: Create Pull Request
44+
- name: Check PyPI release age
4545
if: steps.upgrade.outputs.changed == 'true'
46+
id: age-check
47+
run: |
48+
cutoff=$(( $(date +%s) - 7 * 24 * 3600 ))
49+
too_new=false
50+
for whl in $(git diff --name-only -- 'src/virtualenv/seed/wheels/embed/*.whl'); do
51+
pkg=$(basename "$whl" | cut -d- -f1)
52+
version=$(basename "$whl" | cut -d- -f2)
53+
upload_time=$(curl -sf "https://pypi.org/pypi/${pkg}/${version}/json" | jq -r '.urls[0].upload_time_iso_8601 // empty')
54+
if [ -z "$upload_time" ]; then
55+
echo "::warning::Could not fetch release date for ${pkg}==${version}"
56+
continue
57+
fi
58+
release_epoch=$(date -d "$upload_time" +%s)
59+
if [ "$release_epoch" -gt "$cutoff" ]; then
60+
echo "::notice::${pkg}==${version} released less than 7 days ago (${upload_time})"
61+
too_new=true
62+
fi
63+
done
64+
if [ "$too_new" = "true" ]; then
65+
echo "skip=true" >> "$GITHUB_OUTPUT"
66+
echo "### Skipped — some packages released less than 7 days ago" >> "$GITHUB_STEP_SUMMARY"
67+
else
68+
echo "skip=false" >> "$GITHUB_OUTPUT"
69+
fi
70+
- name: Create Pull Request
71+
if: steps.upgrade.outputs.changed == 'true' && steps.age-check.outputs.skip != 'true'
72+
id: cpr
4673
uses: peter-evans/create-pull-request@v8
4774
with:
4875
commit-message: "Upgrade embedded dependencies"
@@ -55,3 +82,22 @@ jobs:
5582
This PR was created automatically by the [upgrade workflow](https://github.com/${{ github.repository }}/actions/workflows/upgrade.yaml).
5683
labels: |
5784
dependencies
85+
- name: Rename changelog with PR number
86+
if: steps.cpr.outputs.pull-request-number
87+
env:
88+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
run: |
90+
pr_number="${{ steps.cpr.outputs.pull-request-number }}"
91+
target="docs/changelog/${pr_number}.bugfix.rst"
92+
# switch to the PR branch
93+
git fetch origin auto/upgrade-embedded-deps
94+
git checkout auto/upgrade-embedded-deps
95+
if [ -f "docs/changelog/u.bugfix.rst" ]; then
96+
mv "docs/changelog/u.bugfix.rst" "$target"
97+
elif [ ! -f "$target" ]; then
98+
echo "No changelog file found to rename"
99+
exit 0
100+
fi
101+
git add docs/changelog/
102+
git commit -m "Rename changelog to ${pr_number}.bugfix.rst"
103+
git push

0 commit comments

Comments
 (0)