-
Notifications
You must be signed in to change notification settings - Fork 5
fix: make release workflow idempotent for already-published crates #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,16 +17,40 @@ jobs: | |||||||||||||||||||||||||||||||||
| override: true | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Publish spawned-macros | ||||||||||||||||||||||||||||||||||
| run: cargo publish --package spawned-macros --token ${{ secrets.CRATES_IO_TOKEN }} | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| OUTPUT=$(cargo publish --package spawned-macros --token ${{ secrets.CRATES_IO_TOKEN }} 2>&1) || { | ||||||||||||||||||||||||||||||||||
| if echo "$OUTPUT" | grep -q "already exists"; then | ||||||||||||||||||||||||||||||||||
| echo "spawned-macros already published, continuing" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "$OUTPUT" | ||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Successful publish output is silently discarded When
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/release.yaml
Line: 21-28
Comment:
**Successful publish output is silently discarded**
When `cargo publish` exits 0, the content captured in `OUTPUT` is never printed, so workflow logs give no visibility into what was published. Consider echoing the output on success for observability:
```suggestion
OUTPUT=$(cargo publish --package spawned-macros --token ${{ secrets.CRATES_IO_TOKEN }} 2>&1) && echo "$OUTPUT" || {
if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then
echo "spawned-macros already published, continuing"
else
echo "$OUTPUT"
exit 1
fi
}
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Wait for crates.io indexing | ||||||||||||||||||||||||||||||||||
| run: sleep 30 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Publish spawned-rt | ||||||||||||||||||||||||||||||||||
| run: cargo publish --package spawned-rt --token ${{ secrets.CRATES_IO_TOKEN }} | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| OUTPUT=$(cargo publish --package spawned-rt --token ${{ secrets.CRATES_IO_TOKEN }} 2>&1) || { | ||||||||||||||||||||||||||||||||||
| if echo "$OUTPUT" | grep -q "already exists"; then | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same grep pattern concern as The
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/release.yaml
Line: 36
Comment:
**Same grep pattern concern as `spawned-macros` step**
The `"already exists"` pattern here has the same potential mismatch issue as described at line 22. If the crates.io error says "already uploaded", this check will silently fail and the step will always exit with error 1 on re-runs.
```suggestion
if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||||||||||||||
| echo "spawned-rt already published, continuing" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "$OUTPUT" | ||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Wait for crates.io indexing | ||||||||||||||||||||||||||||||||||
| run: sleep 30 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Publish spawned-concurrency | ||||||||||||||||||||||||||||||||||
| run: cargo publish --package spawned-concurrency --token ${{ secrets.CRATES_IO_TOKEN }} | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| OUTPUT=$(cargo publish --package spawned-concurrency --token ${{ secrets.CRATES_IO_TOKEN }} 2>&1) || { | ||||||||||||||||||||||||||||||||||
| if echo "$OUTPUT" | grep -q "already exists"; then | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same grep pattern concern as Same potential mismatch:
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/release.yaml
Line: 50
Comment:
**Same grep pattern concern as `spawned-macros` step**
Same potential mismatch: `"already exists"` vs `"already uploaded"`. If this doesn't match, `spawned-concurrency` re-runs will always fail.
```suggestion
if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||||||||||||||
| echo "spawned-concurrency already published, continuing" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "$OUTPUT" | ||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grep pattern may not match actual crates.io error message
The error string
"already exists"likely does not match whatcargo publishactually outputs when a crate version is already published. The crates.io API returns:This contains "already uploaded", not "already exists". If the grep pattern never matches, the
elsebranch will always execute on re-runs — printing the output and callingexit 1— which defeats the entire purpose of this PR.The same pattern is repeated for
spawned-rt(line 36) andspawned-concurrency(line 50). Please verify the exact error message against the real failure and consider broadening the match to cover both possible phrasings:Prompt To Fix With AI