|
| 1 | +name: Release Client Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Release version without v prefix (e.g. 1.20.5)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + release_tag: |
| 11 | + description: 'GitHub release tag (e.g. v1.20.5)' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + target_repo: |
| 15 | + description: 'GitHub repo to attach binaries to' |
| 16 | + required: false |
| 17 | + default: terraphim-ai |
| 18 | + type: string |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + |
| 23 | +env: |
| 24 | + CARGO_TERM_COLOR: always |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-binaries: |
| 28 | + name: Build client binaries for ${{ matrix.target }} |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - os: [self-hosted, bigbox] |
| 34 | + target: x86_64-unknown-linux-gnu |
| 35 | + use_cross: false |
| 36 | + - os: [self-hosted, bigbox] |
| 37 | + target: x86_64-unknown-linux-musl |
| 38 | + use_cross: true |
| 39 | + - os: [self-hosted, bigbox] |
| 40 | + target: aarch64-unknown-linux-musl |
| 41 | + use_cross: true |
| 42 | + - os: [self-hosted, macOS] |
| 43 | + target: x86_64-apple-darwin |
| 44 | + use_cross: false |
| 45 | + - os: [self-hosted, macOS] |
| 46 | + target: aarch64-apple-darwin |
| 47 | + use_cross: false |
| 48 | + - os: windows-latest |
| 49 | + target: x86_64-pc-windows-msvc |
| 50 | + use_cross: false |
| 51 | + runs-on: ${{ matrix.os }} |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + - uses: dtolnay/rust-toolchain@stable |
| 55 | + with: |
| 56 | + targets: ${{ matrix.target }} |
| 57 | + - name: Install zig |
| 58 | + if: contains(matrix.target, 'apple-darwin') || contains(matrix.target, 'windows') |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + if command -v zig &>/dev/null; then exit 0; fi |
| 62 | + if command -v brew &>/dev/null; then brew install zig; fi |
| 63 | + if command -v choco &>/dev/null; then choco install zig -y; fi |
| 64 | + - name: Install cross |
| 65 | + if: matrix.use_cross |
| 66 | + run: cargo install cross |
| 67 | + - uses: Swatinem/rust-cache@v2 |
| 68 | + if: matrix.target != 'x86_64-unknown-linux-gnu' |
| 69 | + with: |
| 70 | + key: clients-${{ matrix.target }} |
| 71 | + - name: Build client binaries |
| 72 | + env: |
| 73 | + CARGO_REGISTRIES_TERRAPHIM_TOKEN: ${{ secrets.CARGO_REGISTRIES_TERRAPHIM_TOKEN }} |
| 74 | + run: | |
| 75 | + BUILD="${{ matrix.use_cross && 'cross' || 'cargo' }}" |
| 76 | + $BUILD build --release --target ${{ matrix.target }} -p terraphim_agent --bin terraphim-agent |
| 77 | + $BUILD build --release --target ${{ matrix.target }} -p terraphim_cli --bin terraphim-cli |
| 78 | + $BUILD build --release --target ${{ matrix.target }} -p terraphim_grep --bin terraphim-grep --features "code-search openrouter" |
| 79 | + - name: Package artifacts (Unix) |
| 80 | + if: matrix.os != 'windows-latest' |
| 81 | + env: |
| 82 | + VERSION: ${{ inputs.version }} |
| 83 | + run: | |
| 84 | + mkdir -p artifacts |
| 85 | + tar -czf "artifacts/terraphim-agent-${VERSION}-${{ matrix.target }}.tar.gz" -C "target/${{ matrix.target }}/release" terraphim-agent |
| 86 | + tar -czf "artifacts/terraphim-cli-${VERSION}-${{ matrix.target }}.tar.gz" -C "target/${{ matrix.target }}/release" terraphim-cli |
| 87 | + tar -czf "artifacts/terraphim-grep-${VERSION}-${{ matrix.target }}.tar.gz" -C "target/${{ matrix.target }}/release" terraphim-grep |
| 88 | + cp target/${{ matrix.target }}/release/terraphim-agent artifacts/terraphim-agent-${{ matrix.target }} |
| 89 | + cp target/${{ matrix.target }}/release/terraphim-cli artifacts/terraphim-cli-${{ matrix.target }} |
| 90 | + cp target/${{ matrix.target }}/release/terraphim-grep artifacts/terraphim-grep-${{ matrix.target }} |
| 91 | + chmod +x artifacts/* |
| 92 | + - name: Package artifacts (Windows) |
| 93 | + if: matrix.os == 'windows-latest' |
| 94 | + shell: bash |
| 95 | + env: |
| 96 | + VERSION: ${{ inputs.version }} |
| 97 | + run: | |
| 98 | + mkdir -p artifacts |
| 99 | + cd "target/${{ matrix.target }}/release" |
| 100 | + 7z a -tzip "../../../artifacts/terraphim-agent-${VERSION}-${{ matrix.target }}.zip" terraphim-agent.exe |
| 101 | + 7z a -tzip "../../../artifacts/terraphim-cli-${VERSION}-${{ matrix.target }}.zip" terraphim-cli.exe |
| 102 | + 7z a -tzip "../../../artifacts/terraphim-grep-${VERSION}-${{ matrix.target }}.zip" terraphim-grep.exe |
| 103 | + cd - |
| 104 | + cp target/${{ matrix.target }}/release/terraphim-agent.exe artifacts/terraphim-agent-${{ matrix.target }}.exe |
| 105 | + cp target/${{ matrix.target }}/release/terraphim-cli.exe artifacts/terraphim-cli-${{ matrix.target }}.exe |
| 106 | + cp target/${{ matrix.target }}/release/terraphim-grep.exe artifacts/terraphim-grep-${{ matrix.target }}.exe |
| 107 | + - uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: client-binaries-${{ matrix.target }} |
| 110 | + path: artifacts/* |
| 111 | + |
| 112 | + create-universal-macos: |
| 113 | + name: Create macOS universal client binaries |
| 114 | + needs: build-binaries |
| 115 | + if: always() && needs.build-binaries.result != 'cancelled' |
| 116 | + runs-on: [self-hosted, macOS] |
| 117 | + steps: |
| 118 | + - uses: actions/download-artifact@v4 |
| 119 | + with: |
| 120 | + name: client-binaries-x86_64-apple-darwin |
| 121 | + path: x86_64 |
| 122 | + - uses: actions/download-artifact@v4 |
| 123 | + with: |
| 124 | + name: client-binaries-aarch64-apple-darwin |
| 125 | + path: aarch64 |
| 126 | + - run: | |
| 127 | + mkdir -p universal |
| 128 | + lipo -create x86_64/terraphim-agent-x86_64-apple-darwin aarch64/terraphim-agent-aarch64-apple-darwin -output universal/terraphim-agent-universal-apple-darwin |
| 129 | + lipo -create x86_64/terraphim-grep-x86_64-apple-darwin aarch64/terraphim-grep-aarch64-apple-darwin -output universal/terraphim-grep-universal-apple-darwin |
| 130 | + chmod +x universal/* |
| 131 | + - uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: client-binaries-universal-apple-darwin |
| 134 | + path: universal/* |
| 135 | + |
| 136 | + sign-and-notarize-macos: |
| 137 | + name: Sign and notarize macOS client binaries |
| 138 | + needs: create-universal-macos |
| 139 | + if: always() && needs.create-universal-macos.result == 'success' |
| 140 | + runs-on: [self-hosted, macOS] |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v4 |
| 143 | + - uses: actions/download-artifact@v4 |
| 144 | + with: |
| 145 | + name: client-binaries-universal-apple-darwin |
| 146 | + path: universal |
| 147 | + - uses: 1password/install-cli-action@v2 |
| 148 | + - name: Load signing credentials |
| 149 | + env: |
| 150 | + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} |
| 151 | + run: | |
| 152 | + echo "APPLE_ID=$(op read 'op://TerraphimPlatform/apple.developer.credentials/username' --no-newline)" >> $GITHUB_ENV |
| 153 | + echo "APPLE_TEAM_ID=$(op read 'op://TerraphimPlatform/apple.developer.credentials/APPLE_TEAM_ID' --no-newline)" >> $GITHUB_ENV |
| 154 | + echo "APPLE_APP_PASSWORD=$(op read 'op://TerraphimPlatform/apple.developer.credentials/APPLE_APP_SPECIFIC_PASSWORD' --no-newline)" >> $GITHUB_ENV |
| 155 | + echo "CERT_BASE64=$(op read 'op://TerraphimPlatform/apple.developer.certificate/base64' --no-newline)" >> $GITHUB_ENV |
| 156 | + echo "CERT_PASSWORD=$(op read 'op://TerraphimPlatform/apple.developer.certificate/password' --no-newline)" >> $GITHUB_ENV |
| 157 | + - name: Sign and notarize agent and grep |
| 158 | + env: |
| 159 | + RUNNER_TEMP: ${{ runner.temp }} |
| 160 | + run: | |
| 161 | + chmod +x scripts/sign-macos-binary.sh |
| 162 | + ./scripts/sign-macos-binary.sh universal/terraphim-agent-universal-apple-darwin "$APPLE_ID" "$APPLE_TEAM_ID" "$APPLE_APP_PASSWORD" "$CERT_BASE64" "$CERT_PASSWORD" |
| 163 | + ./scripts/sign-macos-binary.sh universal/terraphim-grep-universal-apple-darwin "$APPLE_ID" "$APPLE_TEAM_ID" "$APPLE_APP_PASSWORD" "$CERT_BASE64" "$CERT_PASSWORD" |
| 164 | + - uses: actions/upload-artifact@v4 |
| 165 | + with: |
| 166 | + name: client-binaries-signed-universal-apple-darwin |
| 167 | + path: universal/* |
| 168 | + |
| 169 | + upload-to-target-release: |
| 170 | + name: Attach client binaries to terraphim-ai release |
| 171 | + needs: [build-binaries, sign-and-notarize-macos] |
| 172 | + if: always() && needs.build-binaries.result == 'success' |
| 173 | + runs-on: ubuntu-latest |
| 174 | + steps: |
| 175 | + - uses: actions/download-artifact@v4 |
| 176 | + with: |
| 177 | + pattern: client-binaries* |
| 178 | + path: release-assets |
| 179 | + merge-multiple: true |
| 180 | + - name: Upload to target GitHub release |
| 181 | + env: |
| 182 | + GH_TOKEN: ${{ secrets.TERRAPHIM_AI_RELEASE_TOKEN || secrets.GITHUB_TOKEN }} |
| 183 | + run: | |
| 184 | + TAG="${{ inputs.release_tag }}" |
| 185 | + REPO="terraphim/${{ inputs.target_repo }}" |
| 186 | + find release-assets -type f | sort |
| 187 | + gh release upload "$TAG" release-assets/* --repo "$REPO" --clobber |
0 commit comments