fix: make release workflow idempotent for already-published crates#160
fix: make release workflow idempotent for already-published crates#160ElFantasma merged 1 commit intomainfrom
Conversation
🤖 Kimi Code ReviewReview:
|
🤖 Claude Code ReviewPR #160 Review:
|
| Correctness | Minor: success output is silenced; substring match could be fragile |
| Safety | Low risk — worst case is masking a real error with a misleading message |
| Idempotency goal | Achieved for the stated use case |
The PR solves the immediate problem. I'd recommend the two small fixes: print $OUTPUT unconditionally and tighten the grep pattern to "is already uploaded".
Automated review by Claude (Anthropic) · custom prompt
🤖 Codex Code ReviewFindings:
No actor-runtime/concurrency lifecycle concerns from this PR because it only changes CI release workflow logic. Automated review by OpenAI Codex · custom prompt |
Greptile SummaryThis PR updates The motivation is sound —
Confidence Score: 2/5
|
| Filename | Overview |
|---|---|
| .github/workflows/release.yaml | Adds "already exists" error-skipping logic to all three cargo publish steps; the grep pattern may not match the actual crates.io error message ("already uploaded"), which would cause the idempotency fix to silently not work. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([Release Triggered]) --> B[cargo publish --package spawned-macros]
B -->|exit 0| C[Output captured, success silent]
B -->|exit non-zero| D{OUTPUT contains\n'already exists'?}
D -->|yes| E[Skip – already published\ncontinue]
D -->|no| F[Print OUTPUT\nexit 1 – fail]
C --> G[sleep 30s]
E --> G
G --> H[cargo publish --package spawned-rt]
H -->|exit 0| I[Output captured, success silent]
H -->|exit non-zero| J{OUTPUT contains\n'already exists'?}
J -->|yes| K[Skip – already published\ncontinue]
J -->|no| L[Print OUTPUT\nexit 1 – fail]
I --> M[sleep 30s]
K --> M
M --> N[cargo publish --package spawned-concurrency]
N -->|exit 0| O[Output captured, success silent]
N -->|exit non-zero| P{OUTPUT contains\n'already exists'?}
P -->|yes| Q[Skip – already published\ncontinue]
P -->|no| R[Print OUTPUT\nexit 1 – fail]
O --> S([Done])
Q --> S
style D fill:#ffe0b2
style J fill:#ffe0b2
style P fill:#ffe0b2
style F fill:#ffcdd2
style L fill:#ffcdd2
style R fill:#ffcdd2
Prompt To Fix All With AI
This 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.
---
This 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.
---
This 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.
---
This is a comment left during a code review.
Path: .github/workflows/release.yaml
Line: 22
Comment:
**Grep pattern may not match actual crates.io error message**
The error string `"already exists"` likely does not match what `cargo publish` actually outputs when a crate version is already published. The crates.io API returns:
```
crate version `spawned-macros@0.5.0` is already uploaded to crates.io
```
This contains **"already uploaded"**, not **"already exists"**. If the grep pattern never matches, the `else` branch will always execute on re-runs — printing the output and calling `exit 1` — which defeats the entire purpose of this PR.
The same pattern is repeated for `spawned-rt` (line 36) and `spawned-concurrency` (line 50). Please verify the exact error message against the real failure and consider broadening the match to cover both possible phrasings:
```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.Last reviewed commit: 1b2a4c9
| 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 |
There was a problem hiding this 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.
| if echo "$OUTPUT" | grep -q "already exists"; then | |
| if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then |
Prompt To Fix With AI
This 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.| 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 |
There was a problem hiding this 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.
| if echo "$OUTPUT" | grep -q "already exists"; then | |
| if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then |
Prompt To Fix With AI
This 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.| 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 | ||
| } |
There was a problem hiding this 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:
| 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 | |
| } | |
| 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 | |
| } |
Prompt To Fix With AI
This 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!
| 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 |
There was a problem hiding this comment.
Grep pattern may not match actual crates.io error message
The error string "already exists" likely does not match what cargo publish actually outputs when a crate version is already published. The crates.io API returns:
crate version `spawned-macros@0.5.0` is already uploaded to crates.io
This contains "already uploaded", not "already exists". If the grep pattern never matches, the else branch will always execute on re-runs — printing the output and calling exit 1 — which defeats the entire purpose of this PR.
The same pattern is repeated for spawned-rt (line 36) and spawned-concurrency (line 50). Please verify the exact error message against the real failure and consider broadening the match to cover both possible phrasings:
| if echo "$OUTPUT" | grep -q "already exists"; then | |
| if echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then |
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/release.yaml
Line: 22
Comment:
**Grep pattern may not match actual crates.io error message**
The error string `"already exists"` likely does not match what `cargo publish` actually outputs when a crate version is already published. The crates.io API returns:
```
crate version `spawned-macros@0.5.0` is already uploaded to crates.io
```
This contains **"already uploaded"**, not **"already exists"**. If the grep pattern never matches, the `else` branch will always execute on re-runs — printing the output and calling `exit 1` — which defeats the entire purpose of this PR.
The same pattern is repeated for `spawned-rt` (line 36) and `spawned-concurrency` (line 50). Please verify the exact error message against the real failure and consider broadening the match to cover both possible phrasings:
```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.
Summary
cargo publishso re-runs succeedNeeded because
spawned-macros0.5.0 was published manually, so the release workflow fails when trying to publish it again.