Add edit_file + grep tools, upgrade read_file/bash/list_files #109
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release (Changesets 🦋) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| env: | |
| CI: true | |
| jobs: | |
| version: | |
| timeout-minutes: 30 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| actions: write | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
| should_release: ${{ steps.check_release.outputs.should_release }} | |
| steps: | |
| - name: Checkout code repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev libcap-ng-dev pkg-config | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache Rust build artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build web UI | |
| run: | | |
| cd crates/smooth-web/web | |
| pnpm install --no-frozen-lockfile | |
| pnpm build | |
| - name: Format check | |
| run: cargo fmt --check | |
| - name: Clippy | |
| run: cargo clippy -- -D warnings | |
| continue-on-error: true | |
| - name: Test | |
| run: cargo test | |
| - name: Build | |
| run: cargo build --release -p smooai-smooth-cli | |
| - name: Version Update 🦋 | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| commit: "🦋 New version release" | |
| title: "🦋 New version release" | |
| publish: pnpm ci:publish | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
| - name: Check if release needed | |
| id: check_release | |
| run: | | |
| # A release is needed when changesets says published OR when | |
| # the current commit is a changeset merge (version was just bumped). | |
| if [[ "${{ steps.changesets.outputs.published }}" == "true" ]]; then | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| elif git log -1 --pretty=%s | grep -q "🦋 New version release"; then | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Auto-Merge Changeset PR | |
| continue-on-error: true | |
| run: | | |
| PR_NUMBER=$(gh pr list --state open --head changeset-release/main --json number --jq '.[0].number') | |
| if [[ -n "$PR_NUMBER" && "$PR_NUMBER" != "null" ]]; then | |
| echo "Found Changeset PR #$PR_NUMBER, attempting to auto-merge..." | |
| gh pr merge "$PR_NUMBER" --auto --squash || echo "Auto-merge not enabled for this repo — merge the changeset PR manually." | |
| else | |
| echo "No open Changeset PR found, skipping merge." | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| build: | |
| name: Build ${{ matrix.target }} | |
| needs: version | |
| if: needs.version.outputs.should_release == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Build web UI | |
| run: | | |
| cd crates/smooth-web/web | |
| pnpm install --no-frozen-lockfile | |
| pnpm build | |
| - name: Build binary | |
| run: cargo build --release --target ${{ matrix.target }} -p smooai-smooth-cli | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| - name: Package | |
| run: | | |
| mkdir -p dist | |
| cp target/${{ matrix.target }}/release/th dist/th-${{ matrix.target }} | |
| tar czf dist/th-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release th | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: th-${{ matrix.target }} | |
| path: dist/ | |
| release: | |
| name: Create Release | |
| needs: [version, build] | |
| if: needs.version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Get version | |
| id: version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| files: dist/* | |
| generate_release_notes: true | |
| - name: Install Rust (for crates.io publish) | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish smooth-policy to crates.io | |
| run: cargo publish --allow-dirty -p smooai-smooth-policy | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.SMOOAI_CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true | |
| - name: Wait for crates.io index update | |
| run: sleep 30 | |
| - name: Publish smooth-operator to crates.io | |
| run: cargo publish --allow-dirty -p smooai-smooth-operator | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.SMOOAI_CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true | |
| - name: Wait for crates.io index update | |
| run: sleep 30 | |
| - name: Publish smooth-pearls to crates.io | |
| run: cargo publish --allow-dirty -p smooai-smooth-pearls | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.SMOOAI_CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true |