fix: use crates.io deps in CI (a3s-cron 0.1.2), fix node publish #7
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # =========================================================================== | |
| # 1. Build server binary (cross-compiled) | |
| # =========================================================================== | |
| build-server: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| name: darwin-arm64 | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| name: darwin-x86_64 | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| name: linux-x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| name: linux-arm64 | |
| cross: true | |
| name: Server / ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup workspace | |
| run: bash .github/setup-workspace.sh | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install protobuf compiler | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then | |
| sudo apt-get update && sudo apt-get install -y protobuf-compiler | |
| else | |
| brew install protobuf | |
| fi | |
| - name: Install cross-compilation tools | |
| if: matrix.cross | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} -p a3s-code | |
| - name: Strip binary | |
| shell: bash | |
| run: | | |
| BINARY="target/${{ matrix.target }}/release/a3s-code" | |
| if [ "${{ matrix.cross }}" = "true" ]; then | |
| aarch64-linux-gnu-strip "$BINARY" || true | |
| else | |
| strip "$BINARY" || true | |
| fi | |
| - name: Package | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| ARCHIVE="a3s-code-${VERSION}-${{ matrix.name }}.tar.gz" | |
| tar -czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" a3s-code | |
| echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: server-${{ matrix.name }} | |
| path: ${{ env.ARCHIVE }} | |
| # =========================================================================== | |
| # 2. Build Python native wheels (PyO3 + maturin) | |
| # =========================================================================== | |
| build-python-native: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| name: Python Native / ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup workspace | |
| run: bash .github/setup-workspace.sh | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install protobuf compiler | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then | |
| sudo apt-get update && sudo apt-get install -y protobuf-compiler | |
| else | |
| brew install protobuf | |
| fi | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install maturin | |
| run: pip install maturin | |
| - name: Build wheel | |
| working-directory: sdk/python-native | |
| run: | | |
| if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
| pip install ziglang | |
| maturin build --release --target ${{ matrix.target }} --zig | |
| else | |
| maturin build --release --target ${{ matrix.target }} | |
| fi | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-wheel-${{ matrix.target }} | |
| path: target/wheels/*.whl | |
| # =========================================================================== | |
| # 3. Build Node.js native addon (napi-rs) | |
| # =========================================================================== | |
| build-node-native: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| name: darwin-arm64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| name: darwin-x64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| name: linux-x64-gnu | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| name: linux-arm64-gnu | |
| cross: true | |
| name: Node Native / ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup workspace | |
| run: bash .github/setup-workspace.sh | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install protobuf compiler | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then | |
| sudo apt-get update && sudo apt-get install -y protobuf-compiler | |
| else | |
| brew install protobuf | |
| fi | |
| - name: Install cross-compilation tools | |
| if: matrix.cross | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| working-directory: sdk/node-native | |
| run: npm install | |
| - name: Build native addon | |
| working-directory: sdk/node-native | |
| run: npx napi build --platform --release --target ${{ matrix.target }} --js index.js --dts index.d.ts | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: node-native-${{ matrix.name }} | |
| path: sdk/node-native/*.node | |
| # =========================================================================== | |
| # 4. Publish Python gRPC SDK to PyPI | |
| # =========================================================================== | |
| publish-python-sdk: | |
| name: Publish Python gRPC SDK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build package | |
| working-directory: sdk/python | |
| run: python -m build | |
| - name: Publish to PyPI | |
| working-directory: sdk/python | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: twine upload dist/* | |
| # =========================================================================== | |
| # 5. Publish TypeScript gRPC SDK to npm | |
| # =========================================================================== | |
| publish-typescript-sdk: | |
| name: Publish TypeScript gRPC SDK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install & build | |
| working-directory: sdk/typescript | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Publish to npm | |
| working-directory: sdk/typescript | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public | |
| # =========================================================================== | |
| # 6. Publish Python native wheels to PyPI | |
| # =========================================================================== | |
| publish-python-native: | |
| name: Publish Python Native Wheels | |
| runs-on: ubuntu-latest | |
| needs: build-python-native | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install twine | |
| run: pip install twine | |
| - name: Download all wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: python-wheel-* | |
| path: wheels | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_NATIVE_TOKEN }} | |
| run: twine upload wheels/*.whl | |
| # =========================================================================== | |
| # 7. Publish Node.js native addon to npm | |
| # =========================================================================== | |
| publish-node-native: | |
| name: Publish Node Native Addon | |
| runs-on: ubuntu-latest | |
| needs: build-node-native | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| working-directory: sdk/node-native | |
| run: npm install | |
| - name: Download all native addons | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: node-native-* | |
| path: sdk/node-native | |
| merge-multiple: true | |
| - name: List artifacts | |
| working-directory: sdk/node-native | |
| run: ls -la *.node | |
| - name: Publish to npm | |
| working-directory: sdk/node-native | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Remove prepublishOnly to avoid napi prepublish (binaries already built) | |
| node -e "const p=require('./package.json'); delete p.scripts.prepublishOnly; require('fs').writeFileSync('package.json', JSON.stringify(p, null, 2))" | |
| npm publish --access public | |
| # =========================================================================== | |
| # 8. Create GitHub Release with all artifacts | |
| # =========================================================================== | |
| release: | |
| name: GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [build-server, build-python-native, build-node-native] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download server artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: server-* | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Download Python wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: python-wheel-* | |
| path: artifacts/wheels | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| sha256sum *.tar.gz > checksums.txt | |
| sha256sum wheels/*.whl >> checksums.txt | |
| cat checksums.txt | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: | | |
| artifacts/*.tar.gz | |
| artifacts/wheels/*.whl | |
| artifacts/checksums.txt | |
| # =========================================================================== | |
| # 9. Update Homebrew formula | |
| # =========================================================================== | |
| update-homebrew: | |
| name: Update Homebrew Formula | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: Download server artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: server-* | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Compute SHA256 checksums | |
| id: sha | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "darwin_arm64=$(sha256sum artifacts/a3s-code-${VERSION}-darwin-arm64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT | |
| echo "darwin_x86_64=$(sha256sum artifacts/a3s-code-${VERSION}-darwin-x86_64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT | |
| echo "linux_arm64=$(sha256sum artifacts/a3s-code-${VERSION}-linux-arm64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT | |
| echo "linux_x86_64=$(sha256sum artifacts/a3s-code-${VERSION}-linux-x86_64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT | |
| - name: Checkout homebrew-tap | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: A3S-Lab/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Update formula | |
| run: | | |
| VERSION="${{ steps.sha.outputs.version }}" | |
| cat > homebrew-tap/Formula/a3s-code.rb << 'FORMULA' | |
| # typed: false | |
| # frozen_string_literal: true | |
| # A3S Code - AI agent with tool execution capabilities | |
| class A3sCode < Formula | |
| desc "AI agent with tool execution capabilities and gRPC service" | |
| homepage "https://github.com/A3S-Lab/Code" | |
| version "VERSION_PLACEHOLDER" | |
| license "MIT" | |
| on_macos do | |
| on_arm do | |
| url "https://github.com/A3S-Lab/Code/releases/download/vVERSION_PLACEHOLDER/a3s-code-VERSION_PLACEHOLDER-darwin-arm64.tar.gz" | |
| sha256 "SHA_DARWIN_ARM64" | |
| end | |
| on_intel do | |
| url "https://github.com/A3S-Lab/Code/releases/download/vVERSION_PLACEHOLDER/a3s-code-VERSION_PLACEHOLDER-darwin-x86_64.tar.gz" | |
| sha256 "SHA_DARWIN_X86_64" | |
| end | |
| end | |
| on_linux do | |
| on_arm do | |
| url "https://github.com/A3S-Lab/Code/releases/download/vVERSION_PLACEHOLDER/a3s-code-VERSION_PLACEHOLDER-linux-arm64.tar.gz" | |
| sha256 "SHA_LINUX_ARM64" | |
| end | |
| on_intel do | |
| url "https://github.com/A3S-Lab/Code/releases/download/vVERSION_PLACEHOLDER/a3s-code-VERSION_PLACEHOLDER-linux-x86_64.tar.gz" | |
| sha256 "SHA_LINUX_X86_64" | |
| end | |
| end | |
| def install | |
| bin.install "a3s-code" | |
| end | |
| service do | |
| run [opt_bin/"a3s-code", "serve"] | |
| keep_alive true | |
| log_path var/"log/a3s-code.log" | |
| error_log_path var/"log/a3s-code-error.log" | |
| end | |
| test do | |
| system "#{bin}/a3s-code", "--version" | |
| end | |
| end | |
| FORMULA | |
| # Replace placeholders | |
| sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" homebrew-tap/Formula/a3s-code.rb | |
| sed -i "s/SHA_DARWIN_ARM64/${{ steps.sha.outputs.darwin_arm64 }}/g" homebrew-tap/Formula/a3s-code.rb | |
| sed -i "s/SHA_DARWIN_X86_64/${{ steps.sha.outputs.darwin_x86_64 }}/g" homebrew-tap/Formula/a3s-code.rb | |
| sed -i "s/SHA_LINUX_ARM64/${{ steps.sha.outputs.linux_arm64 }}/g" homebrew-tap/Formula/a3s-code.rb | |
| sed -i "s/SHA_LINUX_X86_64/${{ steps.sha.outputs.linux_x86_64 }}/g" homebrew-tap/Formula/a3s-code.rb | |
| # Remove leading whitespace from heredoc | |
| sed -i 's/^ //' homebrew-tap/Formula/a3s-code.rb | |
| - name: Push formula update | |
| working-directory: homebrew-tap | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/a3s-code.rb | |
| git commit -m "a3s-code ${{ steps.sha.outputs.version }}" | |
| git push |