|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build (${{ matrix.target }}) |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-gnu |
| 22 | + artifact_name: agentic-contract-mcp |
| 23 | + - os: ubuntu-latest |
| 24 | + target: aarch64-unknown-linux-gnu |
| 25 | + artifact_name: agentic-contract-mcp |
| 26 | + - os: macos-latest |
| 27 | + target: x86_64-apple-darwin |
| 28 | + artifact_name: agentic-contract-mcp |
| 29 | + - os: macos-latest |
| 30 | + target: aarch64-apple-darwin |
| 31 | + artifact_name: agentic-contract-mcp |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - name: Clone agentic-sdk (sibling dependency) |
| 35 | + run: git clone --depth 1 https://github.com/agentralabs/agentic-sdk.git ../agentic-sdk |
| 36 | + - uses: dtolnay/rust-toolchain@stable |
| 37 | + with: |
| 38 | + targets: ${{ matrix.target }} |
| 39 | + |
| 40 | + - name: Install cross-compilation tools |
| 41 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 45 | +
|
| 46 | + - name: Build |
| 47 | + run: cargo build --release --target ${{ matrix.target }} |
| 48 | + env: |
| 49 | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc |
| 50 | + |
| 51 | + - name: Package |
| 52 | + run: | |
| 53 | + cd target/${{ matrix.target }}/release |
| 54 | + tar czf ../../../${{ matrix.artifact_name }}-${{ matrix.target }}.tar.gz ${{ matrix.artifact_name }} acon |
| 55 | + continue-on-error: false |
| 56 | + |
| 57 | + - name: Upload artifacts |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: ${{ matrix.artifact_name }}-${{ matrix.target }} |
| 61 | + path: "*.tar.gz" |
| 62 | + |
| 63 | + release: |
| 64 | + name: Publish Release |
| 65 | + needs: build |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + merge-multiple: true |
| 72 | + - name: Create Release |
| 73 | + uses: softprops/action-gh-release@v2 |
| 74 | + with: |
| 75 | + files: "*.tar.gz" |
| 76 | + generate_release_notes: true |
| 77 | + |
| 78 | + publish-crate: |
| 79 | + name: Publish to crates.io (core + ffi + mcp + cli) |
| 80 | + needs: release |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v4 |
| 84 | + - name: Clone agentic-sdk (sibling dependency) |
| 85 | + run: git clone --depth 1 https://github.com/agentralabs/agentic-sdk.git ../agentic-sdk |
| 86 | + - uses: dtolnay/rust-toolchain@stable |
| 87 | + - name: Publish crates in canonical order |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + set -euo pipefail |
| 91 | +
|
| 92 | + publish_crate() { |
| 93 | + local pkg="$1" |
| 94 | + local retries="${2:-12}" |
| 95 | + local attempt |
| 96 | + local output |
| 97 | +
|
| 98 | + for attempt in $(seq 1 "$retries"); do |
| 99 | + echo "Publish attempt ${attempt}/${retries} for ${pkg}..." |
| 100 | + if output="$(cargo publish -p "${pkg}" --token "${{ secrets.CARGO_REGISTRY_TOKEN }}" 2>&1)"; then |
| 101 | + echo "$output" |
| 102 | + return 0 |
| 103 | + fi |
| 104 | +
|
| 105 | + echo "$output" |
| 106 | + if echo "$output" | grep -Eqi "already uploaded|already exists on crates\\.io index"; then |
| 107 | + echo "${pkg} already published for this version; continuing." |
| 108 | + return 0 |
| 109 | + fi |
| 110 | + if echo "$output" | grep -Eqi "failed to select a version for the requirement|no matching package named|could not find .* in registry"; then |
| 111 | + echo "Dependency index propagation not ready yet; waiting before retry..." |
| 112 | + sleep 20 |
| 113 | + continue |
| 114 | + fi |
| 115 | + return 1 |
| 116 | + done |
| 117 | +
|
| 118 | + echo "Timed out waiting for crates.io index propagation for ${pkg}." |
| 119 | + return 1 |
| 120 | + } |
| 121 | +
|
| 122 | + publish_crate "agentic-contract" |
| 123 | + publish_crate "agentic-contract-ffi" |
| 124 | + publish_crate "agentic-contract-mcp" |
| 125 | + publish_crate "agentic-contract-cli" |
0 commit comments