|
41 | 41 | echo "changed=false" >> "$GITHUB_OUTPUT" |
42 | 42 | echo "### All embedded dependencies are up to date" >> "$GITHUB_STEP_SUMMARY" |
43 | 43 | fi |
44 | | - - name: Create Pull Request |
| 44 | + - name: Check PyPI release age |
45 | 45 | 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 |
46 | 73 | uses: peter-evans/create-pull-request@v8 |
47 | 74 | with: |
48 | 75 | commit-message: "Upgrade embedded dependencies" |
|
55 | 82 | This PR was created automatically by the [upgrade workflow](https://github.com/${{ github.repository }}/actions/workflows/upgrade.yaml). |
56 | 83 | labels: | |
57 | 84 | 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