|
24 | 24 | jobs: |
25 | 25 | check_versions: |
26 | 26 | runs-on: ubuntu-latest |
| 27 | + concurrency: |
| 28 | + group: publish-wheel |
| 29 | + cancel-in-progress: false |
| 30 | + queue: max |
27 | 31 | steps: |
28 | 32 | # A branch pushed or a PR opened with GITHUB_TOKEN raises no events, so |
29 | 33 | # the per-package PRs would sit there with no checks at all. Push and open |
@@ -71,45 +75,52 @@ jobs: |
71 | 75 | base=$(git rev-parse HEAD) |
72 | 76 | ci_scripts/git-identity.sh |
73 | 77 |
|
74 | | - # Branch off main and re-declare this package alone, so the PR only |
75 | | - # ever touches its own docs/packages/<pkg>.yaml (plus packages.txt and |
76 | | - # deprecated.txt for a deprecation). |
| 78 | + # Re-declare each package on the same package-specific branch used by |
| 79 | + # wheel publication. This preserves publication metadata already |
| 80 | + # waiting for review while keeping unrelated packages isolated. |
77 | 81 | open_pr() { |
78 | 82 | local package="$1" slug="$2" title="$3" |
79 | | - local branch="github-actions/nightly-upgrade/$slug" pr |
80 | | -
|
81 | | - git switch --force-create "$branch" "$base" || return 1 |
82 | | - git reset --hard --quiet "$base" || return 1 |
| 83 | + local branch="package/$slug" pr pr_title="$slug: update packages" remote_sha="" |
| 84 | +
|
| 85 | + if git fetch --quiet origin "$branch" 2>/dev/null; then |
| 86 | + remote_sha=$(git rev-parse FETCH_HEAD) || return 1 |
| 87 | + git switch --force-create "$branch" "$remote_sha" || return 1 |
| 88 | + if ! git rebase "$base"; then |
| 89 | + git rebase --abort || true |
| 90 | + return 1 |
| 91 | + fi |
| 92 | + else |
| 93 | + git switch --force-create "$branch" "$base" || return 1 |
| 94 | + fi |
83 | 95 |
|
84 | 96 | uv run --with-requirements ci_scripts/requirements.txt python3 \ |
85 | 97 | ci_scripts/check_versions.py --declare "$package" || return 1 |
86 | 98 |
|
87 | 99 | if git diff --quiet -- docs/packages ci_scripts/packages.txt ci_scripts/deprecated.txt; then |
| 100 | + if [ -n "$remote_sha" ] && [ "$(git rev-parse HEAD)" != "$remote_sha" ]; then |
| 101 | + git push --force-with-lease="$branch:$remote_sha" origin "$branch" || return 1 |
| 102 | + fi |
88 | 103 | echo "$package: nothing to declare" |
89 | 104 | return 0 |
90 | 105 | fi |
91 | 106 |
|
92 | 107 | git add docs/packages ci_scripts/packages.txt ci_scripts/deprecated.txt || return 1 |
93 | 108 | git commit -s -m "$title" || return 1 |
94 | 109 |
|
95 | | - # Leave an open PR alone when it already declares the same thing: |
96 | | - # a nightly force-push would restart its build for nothing. |
97 | | - if git fetch --quiet origin "$branch" 2>/dev/null && |
98 | | - git diff --quiet FETCH_HEAD HEAD -- "docs/packages/$slug.yaml"; then |
99 | | - echo "$package: $branch is already up to date" |
100 | | - return 0 |
| 110 | + if [ -n "$remote_sha" ]; then |
| 111 | + git push --force-with-lease="$branch:$remote_sha" origin "$branch" || return 1 |
| 112 | + else |
| 113 | + git push origin "$branch" || return 1 |
101 | 114 | fi |
102 | 115 |
|
103 | | - git push --force origin "$branch" || return 1 |
104 | | -
|
105 | 116 | pr=$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$branch" --state open --json url --jq '.[0].url') || return 1 |
106 | 117 | if [ -n "$pr" ]; then |
107 | | - gh pr edit "$pr" --title "$title" --body-file "$REPORTS/$slug.md" || return 1 |
| 118 | + gh pr edit "$pr" --title "$pr_title" --body-file "$REPORTS/$slug.md" || return 1 |
108 | 119 | echo "Updated $pr" |
109 | 120 | else |
110 | 121 | gh pr create --draft --repo "$GITHUB_REPOSITORY" --base main --head "$branch" \ |
111 | 122 | --reviewer luhenry \ |
112 | | - --title "$title" --body-file "$REPORTS/$slug.md" || return 1 |
| 123 | + --title "$pr_title" --body-file "$REPORTS/$slug.md" || return 1 |
113 | 124 | fi |
114 | 125 | } |
115 | 126 |
|
|
0 commit comments