Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(fleets): package native provider releases (#6730)

r33drichardsf046d75658a3
diff --git a/libs/fleet/terraform-provider-fleets/.github/workflows/release.yml b/libs/fleet/terraform-provider-fleets/.github/workflows/release.yml
index 3c28b03af5..5a41e25013 100644
--- a/libs/fleet/terraform-provider-fleets/.github/workflows/release.yml
+++ b/libs/fleet/terraform-provider-fleets/.github/workflows/release.yml
@@ -4,32 +4,130 @@ on:
push:
tags:
- "v*"
+ workflow_dispatch:
+ inputs:
+ version:
+ description: Version to build without the v prefix
+ required: true
+ default: "0.2.0"
permissions:
contents: write
jobs:
- release:
+ prepare:
runs-on: ubuntu-latest
+ outputs:
+ version: ${{ steps.version.outputs.version }}
+ steps:
+ - id: version
+ name: Determine release version
+ env:
+ DISPATCH_VERSION: ${{ inputs.version }}
+ run: |
+ set -euo pipefail
+ if [ "$GITHUB_EVENT_NAME" = "push" ]; then
+ version="${GITHUB_REF_NAME#v}"
+ else
+ version="$DISPATCH_VERSION"
+ fi
+ [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
+ echo "version=$version" >> "$GITHUB_OUTPUT"
+
+ build:
+ needs: prepare
+ name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
+ runs-on: ${{ matrix.runner }}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - goos: linux
+ goarch: amd64
+ runner: ubuntu-22.04
+ cc: gcc
+ - goos: linux
+ goarch: arm64
+ runner: ubuntu-24.04-arm
+ cc: gcc
+ - goos: darwin
+ goarch: amd64
+ runner: macos-15-intel
+ cc: clang
+ - goos: darwin
+ goarch: arm64
+ runner: macos-14
+ cc: clang
+ - goos: windows
+ goarch: amd64
+ runner: windows-2022
+ cc: clang
+ - goos: windows
+ goarch: arm64
+ runner: windows-11-arm
+ cc: clang
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- with:
- fetch-depth: 0
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: go.mod
+ - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 1.97.0
+ with:
+ toolchain: "1.97.0"
+ - name: Build provider archive
+ shell: bash
+ env:
+ CC: ${{ matrix.cc }}
+ VERSION: ${{ needs.prepare.outputs.version }}
+ run: ./scripts/build-release-archive.sh "$VERSION" dist
+ - name: Upload provider archive
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
+ with:
+ name: terraform-provider-fleets-${{ matrix.goos }}-${{ matrix.goarch }}
+ path: dist/*.zip
+ if-no-files-found: error
+
+ release:
+ needs: [prepare, build]
+ if: github.event_name == 'push'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ - name: Download provider archives
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
+ with:
+ pattern: terraform-provider-fleets-*
+ path: dist
+ merge-multiple: true
- name: Import release signing key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
+ set -euo pipefail
test -n "$GPG_PRIVATE_KEY"
printf '%s' "$GPG_PRIVATE_KEY" | gpg --batch --import
- - name: Release signed provider archives
- uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
- with:
- distribution: goreleaser
- version: "~> v2"
- args: release --clean
+ - name: Create signed checksums
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
+ VERSION: ${{ needs.prepare.outputs.version }}
+ run: |
+ set -euo pipefail
+ test -n "$GPG_FINGERPRINT"
+ cd dist
+ test "$(find . -maxdepth 1 -name '*.zip' | wc -l)" -eq 6
+ sha256sum ./*.zip | sed 's# \./# #' > "terraform-provider-fleets_${VERSION}_SHA256SUMS"
+ gpg --batch --armor --detach-sign \
+ --local-user "$GPG_FINGERPRINT" \
+ --output "terraform-provider-fleets_${VERSION}_SHA256SUMS.sig" \
+ "terraform-provider-fleets_${VERSION}_SHA256SUMS"
+ cp ../terraform-registry-manifest.json .
+ - name: Publish GitHub release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ VERSION: ${{ needs.prepare.outputs.version }}
+ run: |
+ set -euo pipefail
+ gh release create "v$VERSION" dist/* \
+ --title "v$VERSION" \
+ --generate-notes \
+ --verify-tag
diff --git a/libs/fleet/terraform-provider-fleets/.goreleaser.yml b/libs/fleet/terraform-provider-fleets/.goreleaser.yml
deleted file mode 100644
index 2cd119d551..0000000000
--- a/libs/fleet/terraform-provider-fleets/.goreleaser.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-version: 2
-
-project_name: terraform-provider-fleets
-
-before:
- hooks:
- - go mod tidy
- - go generate ./...
-
-builds:
- - id: fleets
- binary: terraform-provider-fleets
- env:
- - CGO_ENABLED=0
- ldflags:
- - -s -w -X main.version={{ .Version }}
- goos:
- - darwin
- - linux
- - windows
- goarch:
- - amd64
- - arm64
-
-archives:
- - id: provider
- ids:
- - fleets
- formats:
- - zip
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
-
-checksum:
- name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
-
-signs:
- - artifacts: checksum
- args:
- - --batch
- - --local-user
- - "{{ .Env.GPG_FINGERPRINT }}"
- - --armor
- - --detach-sign
- - "${artifact}"
-
-release:
- github:
- owner: trycua
- name: terraform-provider-fleets
diff --git a/libs/fleet/terraform-provider-fleets/README.md b/libs/fleet/terraform-provider-fleets/README.md
index 9dd2fc43ec..1f95550511 100644
--- a/libs/fleet/terraform-provider-fleets/README.md
+++ b/libs/fleet/terraform-provider-fleets/README.md
@@ -2,112 +2,27 @@
This provider manages `OSGymSandboxWarmPool` and `OSGymSandboxTemplate` resources through the Fleet API. It uses the same user-key OAuth credentials and tenant-scoped authorization as the Fleet Python SDK and dashboard.
-## Temporary local installation (until Registry publication)
+## Installation
-Terraform and OpenTofu provider source addresses are registry addresses, not
-GitHub URLs. Until `trycua/fleets` is published to the Terraform Registry,
-build the public repository locally and install it through a filesystem mirror.
-This installs a locally built binary; it does **not** install the provider from
-the public Registry. Replace or remove this section after Registry publication.
-
-The intended first provider version is `1.0.0`. Clone the public repository and
-build the provider for your current operating system and architecture:
-
-```bash
-git clone https://github.com/trycua/terraform-provider-fleets.git
-cd terraform-provider-fleets
-
-VERSION=1.0.0
-OS="$(go env GOOS)"
-ARCH="$(go env GOARCH)"
-MIRROR="$HOME/.terraform.d/plugins"
-TARGET="$MIRROR/registry.terraform.io/trycua/fleets/$VERSION/${OS}_${ARCH}"
-
-mkdir -p "$TARGET"
-go build -o "$TARGET/terraform-provider-fleets_v${VERSION}" .
-```
-
-Create a Terraform CLI configuration file that uses that mirror and explicitly
-prevents a Registry lookup for this provider:
-
-```bash
-CLI_CONFIG="$HOME/.terraformrc-fleets-local"
-cat > "$CLI_CONFIG" <<EOF
-provider_installation {
- filesystem_mirror {
- path = "$MIRROR"
- include = ["registry.terraform.io/trycua/fleets"]
- }
-
- direct {
- exclude = ["registry.terraform.io/trycua/fleets"]
- }
-}
-EOF
-
-export TF_CLI_CONFIG_FILE="$CLI_CONFIG"
-```
-
-On Windows PowerShell, build the matching Windows binary and write the same
-CLI configuration with an absolute mirror path:
-
-```powershell
-git clone https://github.com/trycua/terraform-provider-fleets.git
-Set-Location terraform-provider-fleets
-
-$Version = "1.0.0"
-$Os = go env GOOS
-$Arch = go env GOARCH
-$Mirror = Join-Path $HOME ".terraform.d\plugins"
-$Target = Join-Path $Mirror "registry.terraform.io\trycua\fleets\$Version\${Os}_${Arch}"
-New-Item -ItemType Directory -Force -Path $Target | Out-Null
-go build -o (Join-Path $Target "terraform-provider-fleets_v$Version.exe") .
-
-$CliConfig = Join-Path $HOME "terraformrc-fleets-local.tfrc"
-@"
-provider_installation {
- filesystem_mirror {
- path = "$($Mirror -replace '\\', '/')"
- include = ["registry.terraform.io/trycua/fleets"]
- }
-
- direct {
- exclude = ["registry.terraform.io/trycua/fleets"]
- }
-}
-"@ | Set-Content -NoNewline $CliConfig
-
-$env:TF_CLI_CONFIG_FILE = $CliConfig
-```
-
-Use the normal provider address and version in configuration. Do not replace
-`source` with a GitHub URL:
+Declare the provider in your Terraform configuration:
```hcl
terraform {
required_providers {
fleets = {
source = "trycua/fleets"
- version = "1.0.0"
+ version = "0.2.0"
}
}
}
```
-With `TF_CLI_CONFIG_FILE` set, remove any prior initialization state and run
-Terraform (or substitute `tofu` for OpenTofu):
+Then install it from the Terraform Registry:
```bash
-rm -rf .terraform .terraform.lock.hcl
terraform init
-terraform providers
-terraform providers schema -json >/dev/null
```
-`terraform init` should succeed without resolving `trycua/fleets` from the
-public Registry, and `terraform providers` should list
-`provider[registry.terraform.io/trycua/fleets]` at version `1.0.0`.
-
## Development
```bash
diff --git a/libs/fleet/terraform-provider-fleets/RELEASING.md b/libs/fleet/terraform-provider-fleets/RELEASING.md
index b21f035367..7eaec05cbb 100644
--- a/libs/fleet/terraform-provider-fleets/RELEASING.md
+++ b/libs/fleet/terraform-provider-fleets/RELEASING.md
@@ -1,8 +1,8 @@
# Release procedure
-The first public release is `v1.0.0`. Create that tag only after the Cloud PR
-is merged to authoritative `main` and Copybara has exported that merge commit to
-`trycua/terraform-provider-fleets`.
+The first public release is `v0.2.0`. Create that tag only after the Cloud PR
+is merged to authoritative `main`, Copybara has exported that merge commit to
+`trycua/terraform-provider-fleets`, and a manual release workflow run has built every supported platform successfully.
Before tagging, an organization owner must configure `GPG_PRIVATE_KEY` and
`GPG_FINGERPRINT` in the generated repository and configure the matching public
diff --git a/libs/fleet/terraform-provider-fleets/scripts/build-release-archive.sh b/libs/fleet/terraform-provider-fleets/scripts/build-release-archive.sh
new file mode 100755
index 0000000000..3a00967ec6
--- /dev/null
+++ b/libs/fleet/terraform-provider-fleets/scripts/build-release-archive.sh
@@ -0,0 +1,114 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+if [ "$#" -ne 2 ]; then
+ echo "usage: $0 <version> <dist-dir>" >&2
+ exit 2
+fi
+
+version=$1
+dist_dir=$2
+provider_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+
+if [ -f "$provider_root/native/Cargo.toml" ]; then
+ native_root="$provider_root/native"
+elif [ -f "$provider_root/../Cargo.toml" ]; then
+ native_root="$(cd "$provider_root/.." && pwd)"
+else
+ echo "Cyclops SDK Rust workspace not found" >&2
+ exit 1
+fi
+
+bindings_root="$native_root/sdk-bindings/go-uniffi"
+target_dir="${CYCLOPS_SDK_TARGET_DIR:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}/terraform-provider-fleets/cyclops-sdk}"
+goos="$(go env GOOS)"
+goarch="$(go env GOARCH)"
+
+if [ "$goos" = windows ] && command -v cygpath >/dev/null 2>&1; then
+ native_root_for_tools="$(cygpath -m "$native_root")"
+ bindings_root_for_tools="$(cygpath -m "$bindings_root")"
+ target_dir_for_tools="$(cygpath -m "$target_dir")"
+else
+ native_root_for_tools="$native_root"
+ bindings_root_for_tools="$bindings_root"
+ target_dir_for_tools="$target_dir"
+fi
+
+case "$goos" in
+ linux|darwin)
+ static_library="$target_dir_for_tools/release/deps/libcyclops_sdk.a"
+ executable="terraform-provider-fleets_v${version}"
+ ;;
+ windows)
+ static_library="$target_dir_for_tools/release/deps/cyclops_sdk.lib"
+ executable="terraform-provider-fleets_v${version}.exe"
+ ;;
+ *)
+ echo "unsupported release platform: $goos/$goarch" >&2
+ exit 1
+ ;;
+esac
+
+mkdir -p "$dist_dir"
+build_log="$(mktemp)"
+trap 'rm -f "$build_log"' EXIT
+
+cargo rustc \
+ --locked \
+ --manifest-path "$native_root_for_tools/Cargo.toml" \
+ --package cyclops-sdk \
+ --release \
+ --target-dir "$target_dir_for_tools" \
+ -- \
+ --crate-type staticlib \
+ --print native-static-libs 2>&1 | tee "$build_log"
+
+[ -f "$static_library" ] || {
+ echo "native SDK static library was not built: $static_library" >&2
+ exit 1
+}
+
+native_static_libs="$(sed -n 's/^note: native-static-libs: //p' "$build_log" | tail -1)"
+[ -n "$native_static_libs" ] || {
+ echo "Rust did not report native static libraries" >&2
+ exit 1
+}
+
+build_dir="$(mktemp -d)"
+trap 'rm -f "$build_log"; rm -rf "$build_dir"' EXIT
+
+(
+ cd "$provider_root"
+ CGO_ENABLED=1 \
+ CGO_CFLAGS="-I$bindings_root_for_tools/fleet_sdk -I$bindings_root_for_tools/cyclops_sdk_schema" \
+ CGO_LDFLAGS="$static_library $native_static_libs" \
+ go build \
+ -trimpath \
+ -ldflags "-s -w -X main.version=$version" \
+ -o "$build_dir/$executable" \
+ .
+)
+
+case "$goos" in
+ linux)
+ if ldd "$build_dir/$executable" | grep -q cyclops_sdk; then
+ echo "provider has a runtime dependency on libcyclops_sdk" >&2
+ exit 1
+ fi
+ ;;
+ darwin)
+ if otool -L "$build_dir/$executable" | grep -q cyclops_sdk; then
+ echo "provider has a runtime dependency on libcyclops_sdk" >&2
+ exit 1
+ fi
+ ;;
+esac
+
+archive="$(cd "$dist_dir" && pwd)/terraform-provider-fleets_${version}_${goos}_${goarch}.zip"
+if command -v python3 >/dev/null 2>&1; then
+ python_bin=python3
+else
+ python_bin=python
+fi
+"$python_bin" -m zipfile -c "$archive" "$build_dir/$executable"
+printf '%s\n' "$archive"
diff --git a/libs/fleet/terraform-provider-fleets/scripts/test-release-contract.sh b/libs/fleet/terraform-provider-fleets/scripts/test-release-contract.sh
new file mode 100755
index 0000000000..3f1a6d979e
--- /dev/null
+++ b/libs/fleet/terraform-provider-fleets/scripts/test-release-contract.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+workflow="$repo_root/.github/workflows/release.yml"
+builder="$repo_root/scripts/build-release-archive.sh"
+
+require() {
+ local needle=$1
+ local file=$2
+ grep -Fq -- "$needle" "$file" || {
+ printf 'missing release contract in %s: %s\n' "$file" "$needle" >&2
+ exit 1
+ }
+}
+
+[ -x "$builder" ] || {
+ printf 'release builder is missing or not executable: %s\n' "$builder" >&2
+ exit 1
+}
+
+require 'workflow_dispatch:' "$workflow"
+require 'runner: ubuntu-22.04' "$workflow"
+require 'runner: ubuntu-24.04-arm' "$workflow"
+require 'runner: macos-15-intel' "$workflow"
+require 'runner: macos-14' "$workflow"
+require 'runner: windows-2022' "$workflow"
+require 'runner: windows-11-arm' "$workflow"
+require "./scripts/build-release-archive.sh \"\$VERSION\" dist" "$workflow"
+require "terraform-provider-fleets_\${VERSION}_SHA256SUMS" "$workflow"
+require 'gpg --batch --armor --detach-sign' "$workflow"
+require "terraform-provider-fleets_\${VERSION}_SHA256SUMS.sig" "$workflow"
+require "gh release create \"v\$VERSION\"" "$workflow"
+
+require 'cargo rustc' "$builder"
+require '--crate-type staticlib' "$builder"
+require '--print native-static-libs' "$builder"
+require 'CGO_ENABLED=1' "$builder"
+require "terraform-provider-fleets_\${version}_\${goos}_\${goarch}.zip" "$builder"