|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: Version number (with or without a v prefix) |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + skip_github_release: |
| 14 | + description: Skip creating the GitHub release |
| 15 | + required: false |
| 16 | + default: false |
| 17 | + type: boolean |
| 18 | + |
| 19 | +env: |
| 20 | + CARGO_TERM_COLOR: always |
| 21 | + CI: true |
| 22 | + CONTROLLER_IMAGE: ghcr.io/${{ github.repository_owner }}/agentdesktop-controller |
| 23 | + CHART_REGISTRY: ghcr.io/${{ github.repository_owner }}/charts |
| 24 | + |
| 25 | +jobs: |
| 26 | + setup: |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + outputs: |
| 29 | + version: ${{ steps.version.outputs.version }} |
| 30 | + steps: |
| 31 | + - name: Set canonical version |
| 32 | + id: version |
| 33 | + shell: bash |
| 34 | + env: |
| 35 | + VERSION_INPUT: ${{ inputs.version || github.ref_name }} |
| 36 | + run: | |
| 37 | + VERSION="${VERSION_INPUT}" |
| 38 | + VERSION="${VERSION#v}" |
| 39 | + if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then |
| 40 | + echo "Version must be SemVer (for example, 1.2.3 or v1.2.3)" >&2 |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" |
| 44 | +
|
| 45 | + build-controller-image: |
| 46 | + needs: setup |
| 47 | + runs-on: ${{ matrix.runner }} |
| 48 | + permissions: |
| 49 | + contents: read |
| 50 | + packages: write |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + include: |
| 55 | + - platform: linux/amd64 |
| 56 | + runner: ubuntu-24.04 |
| 57 | + - platform: linux/arm64 |
| 58 | + runner: blacksmith-4vcpu-ubuntu-2404-arm |
| 59 | + steps: |
| 60 | + - name: Prepare platform name |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + platform="${{ matrix.platform }}" |
| 64 | + echo "PLATFORM_PAIR=${platform//\//-}" >> "${GITHUB_ENV}" |
| 65 | +
|
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 68 | + with: |
| 69 | + persist-credentials: false |
| 70 | + |
| 71 | + - name: Log in to GitHub Container Registry |
| 72 | + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 |
| 73 | + with: |
| 74 | + registry: ghcr.io |
| 75 | + username: ${{ github.actor }} |
| 76 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + - name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 |
| 80 | + |
| 81 | + - name: Build and push by digest |
| 82 | + id: build |
| 83 | + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 |
| 84 | + with: |
| 85 | + context: . |
| 86 | + platforms: ${{ matrix.platform }} |
| 87 | + tags: ${{ env.CONTROLLER_IMAGE }} |
| 88 | + outputs: type=image,push-by-digest=true,name-canonical=true,push=true |
| 89 | + cache-from: type=gha,scope=controller-${{ env.PLATFORM_PAIR }} |
| 90 | + cache-to: type=gha,scope=controller-${{ env.PLATFORM_PAIR }},mode=max |
| 91 | + |
| 92 | + - name: Export digest |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + mkdir -p "${{ runner.temp }}/digests" |
| 96 | + digest="${{ steps.build.outputs.digest }}" |
| 97 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 98 | +
|
| 99 | + - name: Upload digest |
| 100 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 101 | + with: |
| 102 | + name: controller-digest-${{ env.PLATFORM_PAIR }} |
| 103 | + path: ${{ runner.temp }}/digests/* |
| 104 | + if-no-files-found: error |
| 105 | + retention-days: 1 |
| 106 | + |
| 107 | + push-controller-image: |
| 108 | + needs: |
| 109 | + - setup |
| 110 | + - build-controller-image |
| 111 | + runs-on: ubuntu-24.04 |
| 112 | + permissions: |
| 113 | + contents: read |
| 114 | + packages: write |
| 115 | + id-token: write |
| 116 | + steps: |
| 117 | + - name: Download digests |
| 118 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 119 | + with: |
| 120 | + path: ${{ runner.temp }}/digests |
| 121 | + pattern: controller-digest-* |
| 122 | + merge-multiple: true |
| 123 | + |
| 124 | + - name: Log in to GitHub Container Registry |
| 125 | + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 |
| 126 | + with: |
| 127 | + registry: ghcr.io |
| 128 | + username: ${{ github.actor }} |
| 129 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + |
| 131 | + - name: Set up Docker Buildx |
| 132 | + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 |
| 133 | + |
| 134 | + - name: Create and push manifest |
| 135 | + working-directory: ${{ runner.temp }}/digests |
| 136 | + shell: bash |
| 137 | + env: |
| 138 | + VERSION: ${{ needs.setup.outputs.version }} |
| 139 | + run: | |
| 140 | + tags=(-t "${CONTROLLER_IMAGE}:v${VERSION}") |
| 141 | + if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then |
| 142 | + tags+=(-t "${CONTROLLER_IMAGE}:latest") |
| 143 | + fi |
| 144 | + images=() |
| 145 | + for digest in *; do |
| 146 | + images+=("${CONTROLLER_IMAGE}@sha256:${digest}") |
| 147 | + done |
| 148 | + docker buildx imagetools create "${tags[@]}" "${images[@]}" |
| 149 | +
|
| 150 | + - name: Install cosign |
| 151 | + uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3.9.1 |
| 152 | + |
| 153 | + - name: Sign versioned image |
| 154 | + env: |
| 155 | + VERSION: ${{ needs.setup.outputs.version }} |
| 156 | + run: cosign sign --yes "${CONTROLLER_IMAGE}:v${VERSION}" |
| 157 | + |
| 158 | + - name: Sign latest image |
| 159 | + if: github.event_name == 'push' |
| 160 | + run: cosign sign --yes "${CONTROLLER_IMAGE}:latest" |
| 161 | + |
| 162 | + push-helm-chart: |
| 163 | + needs: |
| 164 | + - setup |
| 165 | + - push-controller-image |
| 166 | + runs-on: ubuntu-24.04 |
| 167 | + permissions: |
| 168 | + contents: read |
| 169 | + packages: write |
| 170 | + steps: |
| 171 | + - name: Checkout |
| 172 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 173 | + with: |
| 174 | + persist-credentials: false |
| 175 | + |
| 176 | + - name: Log in to GitHub Container Registry |
| 177 | + shell: bash |
| 178 | + run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username "${{ github.actor }}" --password-stdin |
| 179 | + |
| 180 | + - name: Package and push chart |
| 181 | + shell: bash |
| 182 | + env: |
| 183 | + VERSION: ${{ needs.setup.outputs.version }} |
| 184 | + run: | |
| 185 | + mkdir -p "${{ runner.temp }}/charts" |
| 186 | + helm package deploy/helm/agentdesktop-controller \ |
| 187 | + --version "${VERSION}" \ |
| 188 | + --app-version "v${VERSION}" \ |
| 189 | + --destination "${{ runner.temp }}/charts" |
| 190 | + helm push \ |
| 191 | + "${{ runner.temp }}/charts/agentdesktop-controller-${VERSION}.tgz" \ |
| 192 | + "oci://${CHART_REGISTRY}" |
| 193 | +
|
| 194 | + build-binaries: |
| 195 | + needs: setup |
| 196 | + runs-on: ${{ matrix.runner }} |
| 197 | + permissions: |
| 198 | + contents: read |
| 199 | + strategy: |
| 200 | + fail-fast: false |
| 201 | + matrix: |
| 202 | + include: |
| 203 | + - os_name: linux |
| 204 | + arch: amd64 |
| 205 | + target: x86_64-unknown-linux-gnu |
| 206 | + runner: ubuntu-24.04 |
| 207 | + extension: "" |
| 208 | + - os_name: linux |
| 209 | + arch: arm64 |
| 210 | + target: aarch64-unknown-linux-gnu |
| 211 | + runner: blacksmith-4vcpu-ubuntu-2404-arm |
| 212 | + extension: "" |
| 213 | + - os_name: darwin |
| 214 | + arch: amd64 |
| 215 | + target: x86_64-apple-darwin |
| 216 | + runner: macos-15-intel |
| 217 | + extension: "" |
| 218 | + - os_name: darwin |
| 219 | + arch: arm64 |
| 220 | + target: aarch64-apple-darwin |
| 221 | + runner: macos-26 |
| 222 | + extension: "" |
| 223 | + - os_name: windows |
| 224 | + arch: amd64 |
| 225 | + target: x86_64-pc-windows-msvc |
| 226 | + runner: windows-2025 |
| 227 | + extension: .exe |
| 228 | + - os_name: windows |
| 229 | + arch: arm64 |
| 230 | + target: aarch64-pc-windows-msvc |
| 231 | + runner: windows-11-arm |
| 232 | + extension: .exe |
| 233 | + steps: |
| 234 | + - name: Checkout |
| 235 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 236 | + with: |
| 237 | + persist-credentials: false |
| 238 | + |
| 239 | + - name: Install Node |
| 240 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
| 241 | + with: |
| 242 | + node-version-file: frontend/.nvmrc |
| 243 | + |
| 244 | + - name: Install Linux desktop dependencies |
| 245 | + if: matrix.os_name == 'linux' |
| 246 | + shell: bash |
| 247 | + run: | |
| 248 | + sudo apt-get update |
| 249 | + sudo apt-get install --yes --no-install-recommends \ |
| 250 | + libwebkit2gtk-4.1-dev \ |
| 251 | + libxdo-dev \ |
| 252 | + libssl-dev \ |
| 253 | + libayatana-appindicator3-dev \ |
| 254 | + librsvg2-dev |
| 255 | +
|
| 256 | + - name: Install Rust target |
| 257 | + uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master |
| 258 | + with: |
| 259 | + toolchain: "1.97" |
| 260 | + targets: ${{ matrix.target }} |
| 261 | + |
| 262 | + - name: Build frontend |
| 263 | + shell: bash |
| 264 | + run: | |
| 265 | + corepack enable |
| 266 | + pnpm --dir frontend install --frozen-lockfile |
| 267 | + pnpm --dir frontend --filter @agentdesktop/desktop-web build |
| 268 | +
|
| 269 | + - name: Build binary |
| 270 | + shell: bash |
| 271 | + run: cargo build --locked --release --package agentdesktop --target "${{ matrix.target }}" |
| 272 | + |
| 273 | + - name: Stage binary and checksum |
| 274 | + shell: bash |
| 275 | + env: |
| 276 | + OUTPUT_NAME: agentdesktop-${{ matrix.os_name }}-${{ matrix.arch }}${{ matrix.extension }} |
| 277 | + run: | |
| 278 | + mkdir -p release |
| 279 | + cp "target/${{ matrix.target }}/release/agentdesktop${{ matrix.extension }}" "release/${OUTPUT_NAME}" |
| 280 | + if command -v sha256sum >/dev/null 2>&1; then |
| 281 | + (cd release && sha256sum "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256") |
| 282 | + else |
| 283 | + (cd release && shasum -a 256 "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256") |
| 284 | + fi |
| 285 | +
|
| 286 | + - name: Upload binary |
| 287 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 288 | + with: |
| 289 | + name: release-binary-${{ matrix.os_name }}-${{ matrix.arch }} |
| 290 | + path: release/agentdesktop-* |
| 291 | + if-no-files-found: error |
| 292 | + |
| 293 | + release: |
| 294 | + if: github.event_name == 'push' || !inputs.skip_github_release |
| 295 | + needs: |
| 296 | + - setup |
| 297 | + - push-controller-image |
| 298 | + - push-helm-chart |
| 299 | + - build-binaries |
| 300 | + runs-on: ubuntu-24.04 |
| 301 | + permissions: |
| 302 | + contents: write |
| 303 | + steps: |
| 304 | + - name: Download binaries |
| 305 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 306 | + with: |
| 307 | + path: release |
| 308 | + pattern: release-binary-* |
| 309 | + merge-multiple: true |
| 310 | + |
| 311 | + - name: Create GitHub release |
| 312 | + uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1 |
| 313 | + with: |
| 314 | + files: release/agentdesktop-* |
| 315 | + tag_name: v${{ needs.setup.outputs.version }} |
| 316 | + target_commitish: ${{ github.sha }} |
| 317 | + generate_release_notes: true |
| 318 | + body: | |
| 319 | + ## Artifacts |
| 320 | +
|
| 321 | + - Controller image: `${{ env.CONTROLLER_IMAGE }}:v${{ needs.setup.outputs.version }}` |
| 322 | + - Helm chart: `oci://${{ env.CHART_REGISTRY }}/agentdesktop-controller:${{ needs.setup.outputs.version }}` |
| 323 | + - Agentdesktop binaries for amd64 and arm64 on Linux, macOS, and Windows are attached below. |
| 324 | + env: |
| 325 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments