Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/publish-crates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Publish Crates & SDKs
on:
release:
types: [published]
push:
branches:
- "release/v*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
rust_version: 1.85.0

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install essentials
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
npm install --global yarn

- name: Install Rust
shell: "bash"
run: rustup toolchain install ${{ env.rust_version }} --profile minimal

- name: Cache rust
uses: Swatinem/rust-cache@v2

lint:
needs: install
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./

steps:
- uses: actions/checkout@v4
- name: Run fmt
run: cargo fmt -- --check

- name: Run clippy
run: cargo clippy -- --deny=warnings

publish:
needs: [install, lint]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: run build
working-directory: ./
run: |
cargo build
cargo test

- name: Set DRY_RUN based on trigger
run: echo "DRY_RUN=true" >> $GITHUB_ENV
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: cargo publish
working-directory: ./
run: |
DRY_RUN_FLAG=""
if [ "${DRY_RUN}" = "true" ]; then
DRY_RUN_FLAG="--dry-run"
fi

if [ "${DRY_RUN}" = "true" ]; then
NO_VERIFY_FLAG="--no-verify"
fi

if [ "${DRY_RUN}" != "true" ]; then
cargo publish $DRY_RUN_FLAG --manifest-path=./Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
fi
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
DRY_RUN: ${{ env.DRY_RUN }}
Comment on lines +70 to +84
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix uninitialized NO_VERIFY_FLAG variable.

The NO_VERIFY_FLAG variable is only initialized when DRY_RUN is true (lines 75–77), but it's used in all cargo publish commands regardless (lines 79–88). While bash tolerates this as an empty expansion, it violates best practices and creates maintenance risk. Initialize the variable unconditionally before the conditional block.

Apply this diff to fix the variable initialization:

  DRY_RUN_FLAG=""
- if [ "${DRY_RUN}" = "true" ]; then
-   DRY_RUN_FLAG="--dry-run"
- fi
-
- if [ "${DRY_RUN}" = "true" ]; then
-   NO_VERIFY_FLAG="--no-verify"
- fi      
+ NO_VERIFY_FLAG=""
+ if [ "${DRY_RUN}" = "true" ]; then
+   DRY_RUN_FLAG="--dry-run"
+   NO_VERIFY_FLAG="--no-verify"
+ fi

This consolidates the initialization and makes the logic explicit.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DRY_RUN_FLAG=""
if [ "${DRY_RUN}" = "true" ]; then
DRY_RUN_FLAG="--dry-run"
fi
if [ "${DRY_RUN}" = "true" ]; then
NO_VERIFY_FLAG="--no-verify"
fi
cargo publish $DRY_RUN_FLAG --manifest-path=ephemeral/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=delegate/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=commit-attribute/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=action-attribute/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
if [ "${DRY_RUN}" != "true" ]; then
cargo publish $DRY_RUN_FLAG --manifest-path=sdk/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=resolver/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=pinocchio/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
fi
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
DRY_RUN: ${{ env.DRY_RUN }}
DRY_RUN_FLAG=""
NO_VERIFY_FLAG=""
if [ "${DRY_RUN}" = "true" ]; then
DRY_RUN_FLAG="--dry-run"
NO_VERIFY_FLAG="--no-verify"
fi
cargo publish $DRY_RUN_FLAG --manifest-path=ephemeral/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=delegate/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=commit-attribute/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=action-attribute/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
if [ "${DRY_RUN}" != "true" ]; then
cargo publish $DRY_RUN_FLAG --manifest-path=sdk/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=resolver/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
cargo publish $DRY_RUN_FLAG --manifest-path=pinocchio/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
fi
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
DRY_RUN: ${{ env.DRY_RUN }}
🤖 Prompt for AI Agents
.github/workflows/publish-crates.yml around lines 70 to 91: NO_VERIFY_FLAG is
only set inside the DRY_RUN=true branch but is later referenced by every cargo
publish call; initialize NO_VERIFY_FLAG to an empty string before the
conditional and then only set it to "--no-verify" when DRY_RUN is true so the
variable is always defined (i.e., add NO_VERIFY_FLAG="" above the if block and
keep the existing conditional assignment to NO_VERIFY_FLAG="--no-verify" when
DRY_RUN=true).



Loading