-
-
Notifications
You must be signed in to change notification settings - Fork 31
fix: make release workflow resilient to re-runs [skip changelog] #577
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 1 commit
482b09d
0e3e5f1
2a6e9bd
a7d05ef
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -247,34 +247,85 @@ jobs: | |||||||
| chmod +x /tmp/wait-for-crate.sh | ||||||||
|
|
||||||||
| # Publish order: agnix-rules (leaf) -> agnix-core -> agnix-cli/agnix-lsp/agnix-mcp | ||||||||
| # Each step tolerates "already exists" errors so re-runs work correctly | ||||||||
| - name: Publish agnix-rules | ||||||||
| run: cargo publish -p agnix-rules | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||
| cargo publish -p agnix-rules 2>&1 || { | ||||||||
| if cargo search agnix-rules --limit 1 | grep -qF "agnix-rules = \"$VERSION\""; then | ||||||||
| echo "agnix-rules $VERSION already published, skipping" | ||||||||
| else | ||||||||
| echo "Publish failed and crate not found on crates.io" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| } | ||||||||
|
||||||||
| env: | ||||||||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||||||||
|
|
||||||||
| - name: Wait for agnix-rules indexing | ||||||||
| run: /tmp/wait-for-crate.sh agnix-rules ${{ steps.version.outputs.version }} | ||||||||
|
|
||||||||
| - name: Publish agnix-core | ||||||||
| run: cargo publish -p agnix-core | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||
| cargo publish -p agnix-core 2>&1 || { | ||||||||
| if cargo search agnix-core --limit 1 | grep -qF "agnix-core = \"$VERSION\""; then | ||||||||
| echo "agnix-core $VERSION already published, skipping" | ||||||||
| else | ||||||||
| echo "Publish failed and crate not found on crates.io" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| } | ||||||||
| env: | ||||||||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||||||||
|
|
||||||||
| - name: Wait for agnix-core indexing | ||||||||
| run: /tmp/wait-for-crate.sh agnix-core ${{ steps.version.outputs.version }} | ||||||||
|
|
||||||||
| - name: Publish agnix-cli | ||||||||
| run: cargo publish -p agnix-cli | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||
| cargo publish -p agnix-cli 2>&1 || { | ||||||||
| if cargo search agnix-cli --limit 1 | grep -qF "agnix-cli = \"$VERSION\""; then | ||||||||
| echo "agnix-cli $VERSION already published, skipping" | ||||||||
| else | ||||||||
| echo "Publish failed and crate not found on crates.io" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| } | ||||||||
| env: | ||||||||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||||||||
|
|
||||||||
| - name: Publish agnix-lsp | ||||||||
| run: cargo publish -p agnix-lsp | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||
| cargo publish -p agnix-lsp 2>&1 || { | ||||||||
| if cargo search agnix-lsp --limit 1 | grep -qF "agnix-lsp = \"$VERSION\""; then | ||||||||
| echo "agnix-lsp $VERSION already published, skipping" | ||||||||
| else | ||||||||
| echo "Publish failed and crate not found on crates.io" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| } | ||||||||
| env: | ||||||||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||||||||
|
|
||||||||
| - name: Publish agnix-mcp | ||||||||
| run: cargo publish -p agnix-mcp | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||
| cargo publish -p agnix-mcp 2>&1 || { | ||||||||
| if cargo search agnix-mcp --limit 1 | grep -qF "agnix-mcp = \"$VERSION\""; then | ||||||||
| echo "agnix-mcp $VERSION already published, skipping" | ||||||||
| else | ||||||||
| echo "Publish failed and crate not found on crates.io" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| } | ||||||||
| env: | ||||||||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||||||||
|
|
||||||||
|
|
@@ -444,6 +495,8 @@ jobs: | |||||||
| run: npm --prefix website run version:cut -- "${{ steps.version.outputs.version }}" | ||||||||
|
|
||||||||
| - name: Commit and push versioned docs | ||||||||
| env: | ||||||||
| GH_TOKEN: ${{ secrets.COMMITTER_TOKEN }} | ||||||||
| run: | | ||||||||
| set -euo pipefail | ||||||||
| git config user.name "github-actions[bot]" | ||||||||
|
|
@@ -452,6 +505,14 @@ jobs: | |||||||
| if git diff --cached --quiet; then | ||||||||
| echo "No changes to commit" | ||||||||
| else | ||||||||
| BRANCH="docs/version-${{ steps.version.outputs.version }}" | ||||||||
| git checkout -b "$BRANCH" | ||||||||
| git commit -m "docs: version ${{ steps.version.outputs.version }} docs and update site data" | ||||||||
|
||||||||
| git commit -m "docs: version ${{ steps.version.outputs.version }} docs and update site data" | |
| git commit -m "docs: version ${{ steps.version.outputs.version }} docs and update site data" | |
| # Intentionally force-push to update the auto-generated docs branch on workflow re-runs. |
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.
Added a comment explaining force-push is intentional for re-runs of the auto-generated docs branch.
Copilot
AI
Feb 27, 2026
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.
This docs step still isn’t resilient to re-runs: git checkout -b "$BRANCH" will fail if the branch already exists locally/remotely, and gh pr create will fail if a PR for that head branch already exists. To make re-runs safe, consider using git checkout -B (or git switch -C) and either updating the existing PR (detect via gh pr view --head "$BRANCH") or treating “PR already exists” as a non-fatal outcome.
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.
Fixed. Now uses git checkout -B (force-create), git push --force-with-lease, and checks for existing PRs via gh pr view --head before creating.
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.
The “already published” detection relies on
cargo search <crate> --limit 1containing the exact version string.cargo searchonly returns the latest version, so this can false-negative when re-running older tags after a newer release exists (the older version is published but won’t appear in search output), and it can also false-negative during crates.io indexing lag. Consider instead keying off thecargo publisherror output (match the known “already uploaded/exists” message), or querying the crates.io HTTP API for the specific version (/api/v1/crates/<crate>/<version>) with retries before deciding to fail.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.
Fixed. Extracted into /tmp/publish-crate.sh helper that uses the crates.io HTTP API for reliable version detection instead of cargo search.