diff --git a/.github/workflows/gdk-release.yml b/.github/workflows/gdk-release.yml new file mode 100644 index 000000000..ea4695981 --- /dev/null +++ b/.github/workflows/gdk-release.yml @@ -0,0 +1,93 @@ +name: Publish GDK + +on: + push: + tags: + - "gdk-v*" + workflow_dispatch: + inputs: + version: + description: GDK version to publish (for example, 0.1.0-alpha.6) + required: true + type: string + +permissions: + contents: read + +concurrency: + group: gdk-release-${{ github.event_name == 'workflow_dispatch' && format('gdk-v{0}', inputs.version) || github.ref_name }} + cancel-in-progress: false + +jobs: + validate-version: + name: Validate package versions + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.value }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Resolve release version + id: version + shell: bash + env: + INPUT_VERSION: ${{ inputs.version }} + run: echo "value=${INPUT_VERSION:-${GITHUB_REF_NAME#gdk-v}}" >> "$GITHUB_OUTPUT" + + - name: Install just + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + + - name: Validate package versions + env: + RELEASE_VERSION: ${{ steps.version.outputs.value }} + run: just --justfile crates/goose-sdk/justfile check-version "$RELEASE_VERSION" + + crates-io: + name: Publish Rust crates + needs: validate-version + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + environment: crates-io + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + with: + cache: false + + - name: Install just + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + + - name: Authenticate with crates.io + id: crates-io-auth + uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 + + - name: Publish to crates.io + env: + CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }} + run: just --justfile crates/goose-sdk/justfile crates-publish false + + maven-central: + name: Publish Maven package + needs: validate-version + permissions: + contents: read + uses: ./.github/workflows/maven-sdk.yml + with: + publish: true + secrets: inherit + + pypi: + name: Publish Python wheels + needs: validate-version + permissions: + contents: read + id-token: write + uses: ./.github/workflows/python-sdk-wheels.yml + with: + publish: true diff --git a/.github/workflows/maven-sdk.yml b/.github/workflows/maven-sdk.yml index 2c4395704..fb94f0c20 100644 --- a/.github/workflows/maven-sdk.yml +++ b/.github/workflows/maven-sdk.yml @@ -1,6 +1,13 @@ name: Maven GDK on: + workflow_call: + inputs: + publish: + description: "Publish gdk to Maven Central after building" + required: false + default: false + type: boolean workflow_dispatch: inputs: publish: @@ -73,6 +80,8 @@ jobs: name: Package Maven artifact needs: build-native runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.value }} steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -112,12 +121,20 @@ jobs: working-directory: crates/goose-sdk/maven run: gradle --no-daemon publishToMavenLocal - - name: Stage Maven local artifacts + - name: Resolve Maven version + id: version shell: bash run: | version=$(grep -m1 '^version =' crates/goose-sdk/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') + echo "value=$version" >> "$GITHUB_OUTPUT" + + - name: Stage Maven local artifacts + shell: bash + env: + VERSION: ${{ steps.version.outputs.value }} + run: | mkdir -p maven-artifacts - cp -R "$HOME/.m2/repository/io/github/aaif-goose/gdk/$version" maven-artifacts/ + cp -R "$HOME/.m2/repository/io/github/aaif-goose/gdk/$VERSION" maven-artifacts/ - name: Upload Maven artifact bundle uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 @@ -175,8 +192,11 @@ jobs: name: Publish to Maven Central needs: [package, smoke-test-linux-aarch64] runs-on: ubuntu-latest - if: github.event_name == 'workflow_dispatch' && inputs.publish + if: inputs.publish environment: maven-central + concurrency: + group: gdk-maven-release-${{ needs.package.outputs.version }} + cancel-in-progress: false steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 diff --git a/.github/workflows/python-sdk-wheels.yml b/.github/workflows/python-sdk-wheels.yml index c587e4fbe..460a48972 100644 --- a/.github/workflows/python-sdk-wheels.yml +++ b/.github/workflows/python-sdk-wheels.yml @@ -1,6 +1,13 @@ name: Python GDK Wheels on: + workflow_call: + inputs: + publish: + description: "Publish wheels to PyPI after building" + required: false + default: false + type: boolean workflow_dispatch: inputs: publish: @@ -25,7 +32,7 @@ jobs: - name: macos-arm64 os: macos-14 - name: macos-x86_64 - os: macos-13 + os: macos-15-intel - name: linux-x86_64 os: ubuntu-latest container: quay.io/pypa/manylinux_2_28_x86_64@sha256:441c35fdc6ee809ff9260894f8468ab4fea8c15dc880f8700a3f81b7922c1cda @@ -39,7 +46,12 @@ jobs: - name: Set up Rust uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + - name: Select Linux Python + if: runner.os == 'Linux' + run: echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH" + - name: Set up Python + if: runner.os != 'Linux' uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12" @@ -99,7 +111,7 @@ jobs: name: Publish wheels to PyPI needs: build-wheels runs-on: ubuntu-latest - if: github.event_name == 'workflow_dispatch' && inputs.publish + if: inputs.publish environment: pypi steps: - name: Download wheel artifacts @@ -113,3 +125,4 @@ jobs: uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 with: packages-dir: dist + skip-existing: true diff --git a/Cargo.lock b/Cargo.lock index 55f24b2ed..319239b83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5330,7 +5330,7 @@ dependencies = [ [[package]] name = "goose-agent" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "async-trait", @@ -5410,7 +5410,7 @@ dependencies = [ [[package]] name = "goose-context-management" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "async-trait", @@ -5426,7 +5426,7 @@ dependencies = [ [[package]] name = "goose-download-manager" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "once_cell", @@ -5438,7 +5438,7 @@ dependencies = [ [[package]] name = "goose-local-inference" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "async-stream", @@ -5503,7 +5503,7 @@ dependencies = [ [[package]] name = "goose-provider-types" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "async-stream", @@ -5532,7 +5532,7 @@ dependencies = [ [[package]] name = "goose-providers" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "anyhow", "async-stream", @@ -5584,7 +5584,7 @@ dependencies = [ [[package]] name = "goose-sdk" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "agent-client-protocol", "agent-client-protocol-schema", @@ -5604,7 +5604,7 @@ dependencies = [ [[package]] name = "goose-sdk-types" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" dependencies = [ "agent-client-protocol", "agent-client-protocol-schema", diff --git a/crates/goose-agent/Cargo.toml b/crates/goose-agent/Cargo.toml index fdc988ad3..9df8025f5 100644 --- a/crates/goose-agent/Cargo.toml +++ b/crates/goose-agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-agent" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true @@ -16,7 +16,7 @@ anyhow = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync", "time", "fs", "process", "net", "signal", "io-std", "io-util"] } tokio-util = { workspace = true, features = ["compat"] } async-trait = { workspace = true } -goose-provider-types = { version = "0.1.0-alpha.6", path = "../goose-provider-types", default-features = false } +goose-provider-types = { version = "0.1.0-alpha.7", path = "../goose-provider-types", default-features = false } rmcp = { workspace = true } uuid = { workspace = true } serde_json = { workspace = true } diff --git a/crates/goose-context-management/Cargo.toml b/crates/goose-context-management/Cargo.toml index 3281a19e9..5ae04f9ff 100644 --- a/crates/goose-context-management/Cargo.toml +++ b/crates/goose-context-management/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-context-management" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true @@ -12,7 +12,7 @@ description = "Conversation compaction for Goose" workspace = true [dependencies] -goose-providers = { version = "0.1.0-alpha.6", path = "../goose-providers", features = ["rustls-tls"] } +goose-providers = { version = "0.1.0-alpha.7", path = "../goose-providers", features = ["rustls-tls"] } anyhow = { workspace = true } async-trait = { workspace = true } include_dir = { workspace = true } diff --git a/crates/goose-download-manager/Cargo.toml b/crates/goose-download-manager/Cargo.toml index a31c81bf2..3713ab5d5 100644 --- a/crates/goose-download-manager/Cargo.toml +++ b/crates/goose-download-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-download-manager" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/goose-local-inference/Cargo.toml b/crates/goose-local-inference/Cargo.toml index 3da359e6e..4a0b1216e 100644 --- a/crates/goose-local-inference/Cargo.toml +++ b/crates/goose-local-inference/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-local-inference" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true @@ -27,9 +27,9 @@ etcetera = { workspace = true } encoding_rs = { version = "0.8.35", default-features = false } fs2 = { workspace = true } futures = { workspace = true } -goose-download-manager = { version = "0.1.0-alpha.6", path = "../goose-download-manager" } -goose-provider-types = { version = "0.1.0-alpha.6", path = "../goose-provider-types", default-features = false } -goose-sdk-types = { version = "0.1.0-alpha.6", path = "../goose-sdk-types", default-features = false } +goose-download-manager = { version = "0.1.0-alpha.7", path = "../goose-download-manager" } +goose-provider-types = { version = "0.1.0-alpha.7", path = "../goose-provider-types", default-features = false } +goose-sdk-types = { version = "0.1.0-alpha.7", path = "../goose-sdk-types", default-features = false } hf-hub = { version = "1.0.0-rc.1", default-features = false } include_dir = { workspace = true } llama-cpp-2 = { workspace = true } diff --git a/crates/goose-provider-types/Cargo.toml b/crates/goose-provider-types/Cargo.toml index 9ced28d34..c9558f56f 100644 --- a/crates/goose-provider-types/Cargo.toml +++ b/crates/goose-provider-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-provider-types" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/goose-providers/Cargo.toml b/crates/goose-providers/Cargo.toml index 9608264e5..3ba2aa59d 100644 --- a/crates/goose-providers/Cargo.toml +++ b/crates/goose-providers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-providers" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true @@ -34,8 +34,8 @@ anyhow = { workspace = true } async-stream = { workspace = true } chrono = { workspace = true } futures = { workspace = true } -goose-provider-types = { version = "0.1.0-alpha.6", path = "../goose-provider-types", default-features = false } -goose-local-inference = { version = "0.1.0-alpha.6", path = "../goose-local-inference", default-features = false, optional = true } +goose-provider-types = { version = "0.1.0-alpha.7", path = "../goose-provider-types", default-features = false } +goose-local-inference = { version = "0.1.0-alpha.7", path = "../goose-local-inference", default-features = false, optional = true } reqwest = { workspace = true } rmcp = { workspace = true, features = ["server", "macros"] } serde = { workspace = true } diff --git a/crates/goose-sdk-types/Cargo.toml b/crates/goose-sdk-types/Cargo.toml index 1003ac1bd..c9d6edf66 100644 --- a/crates/goose-sdk-types/Cargo.toml +++ b/crates/goose-sdk-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-sdk-types" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/goose-sdk/Cargo.toml b/crates/goose-sdk/Cargo.toml index b51ef8db8..212d2c059 100644 --- a/crates/goose-sdk/Cargo.toml +++ b/crates/goose-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "goose-sdk" -version = "0.1.0-alpha.6" +version = "0.1.0-alpha.7" edition.workspace = true rust-version.workspace = true authors.workspace = true @@ -33,14 +33,14 @@ uniffi = [ ] [dependencies] -goose-sdk-types = { version = "0.1.0-alpha.6", path = "../goose-sdk-types" } +goose-sdk-types = { version = "0.1.0-alpha.7", path = "../goose-sdk-types" } agent-client-protocol = { workspace = true } agent-client-protocol-schema = { workspace = true } uniffi = { version = "0.32", features = ["cli"], optional = true } thiserror = { version = "2", optional = true } -goose-providers = { version = "0.1.0-alpha.6", path = "../goose-providers", features = ["rustls-tls"], optional = true } -goose-context-management = { version = "0.1.0-alpha.6", path = "../goose-context-management", optional = true } +goose-providers = { version = "0.1.0-alpha.7", path = "../goose-providers", features = ["rustls-tls"], optional = true } +goose-context-management = { version = "0.1.0-alpha.7", path = "../goose-context-management", optional = true } futures = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } tokio = { workspace = true, features = ["rt-multi-thread", "sync"], optional = true } diff --git a/crates/goose-sdk/justfile b/crates/goose-sdk/justfile index 6e4078e37..0c8bb90da 100644 --- a/crates/goose-sdk/justfile +++ b/crates/goose-sdk/justfile @@ -98,6 +98,8 @@ crates-publish dry_run="true": echo 'dry_run must be true or false' >&2; \ exit 1; \ fi; \ + version=$(cargo metadata --no-deps --format-version 1 | python3 -c \ + 'import json, sys; print(next(package["version"] for package in json.load(sys.stdin)["packages"] if package["name"] == "goose-sdk"))'); \ for crate in \ goose-provider-types \ goose-sdk-types \ @@ -107,9 +109,102 @@ crates-publish dry_run="true": goose-agent \ goose-context-management \ goose-sdk; do \ - cargo publish -p "$crate" $dry_run_flag --allow-dirty; \ + if [ "{{dry_run}}" = "false" ]; then \ + status=$(curl --silent --output /dev/null --write-out '%{http_code}' \ + --user-agent 'goose-gdk-release (https://github.com/aaif-goose/goose)' \ + "https://crates.io/api/v1/crates/$crate/$version"); \ + case "$status" in \ + 200) echo "$crate $version is already published; skipping upload" ;; \ + 404) cargo publish -p "$crate" --allow-dirty ;; \ + *) echo "crates.io returned HTTP $status while checking $crate $version" >&2; exit 1 ;; \ + esac; \ + else \ + cargo publish -p "$crate" $dry_run_flag --allow-dirty; \ + fi; \ + if [ "{{dry_run}}" = "false" ]; then \ + for attempt in $(seq 1 60); do \ + if cargo info "$crate@$version" --registry crates-io >/dev/null 2>&1; then \ + echo "$crate $version is available on crates.io"; \ + break; \ + fi; \ + if [ "$attempt" -eq 60 ]; then \ + echo "timed out waiting for $crate $version to become available on crates.io" >&2; \ + exit 1; \ + fi; \ + sleep 10; \ + done; \ + fi; \ done +check-version rust_version: + #!/usr/bin/env bash + set -euo pipefail + python3 - "{{rust_version}}" <<'PY' + import re + import sys + from pathlib import Path + + rust_version = sys.argv[1] + match = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?", rust_version) + if not match: + raise SystemExit("version must look like 0.1.0 or 0.1.0-alpha.0") + + major, minor, patch, alpha = match.groups() + python_version = f"{major}.{minor}.{patch}" if alpha is None else f"{major}.{minor}.{patch}a{alpha}" + crate_names = [ + "goose-provider-types", + "goose-sdk-types", + "goose-download-manager", + "goose-local-inference", + "goose-providers", + "goose-agent", + "goose-context-management", + "goose-sdk", + ] + + def package_version(path: Path, section: str) -> str: + text = path.read_text() + section_match = re.search(rf"(?ms)^\[{re.escape(section)}\]\s*$(.*?)(?=^\[|\Z)", text) + if not section_match: + raise SystemExit(f"missing [{section}] in {path}") + version_match = re.search(r'^version\s*=\s*"([^"]+)"', section_match.group(1), re.MULTILINE) + if not version_match: + raise SystemExit(f"missing version in [{section}] in {path}") + return version_match.group(1) + + errors = [] + dependency_names = set(crate_names) - {"goose-sdk"} + for crate in crate_names: + path = Path("crates") / crate / "Cargo.toml" + text = path.read_text() + actual = package_version(path, "package") + if actual != rust_version: + errors.append(f"{path}: expected {rust_version}, found {actual}") + + for dependency in dependency_names: + for dependency_match in re.finditer( + rf'(?m)^{re.escape(dependency)}\s*=\s*' + re.escape("{") + r'([^}]*)' + re.escape("}"), text + ): + version_match = re.search(r'version\s*=\s*"([^"]+)"', dependency_match.group(1)) + if not version_match: + errors.append(f"{path}: {dependency} is missing a version requirement") + elif version_match.group(1) != rust_version: + errors.append( + f"{path}: {dependency} expected {rust_version}, " + f"found {version_match.group(1)}" + ) + + pyproject = Path("crates/goose-sdk/python/pyproject.toml") + actual_python = package_version(pyproject, "project") + if actual_python != python_version: + errors.append(f"{pyproject}: expected {python_version}, found {actual_python}") + + if errors: + raise SystemExit("\n".join(errors)) + + print(f"Validated Rust/Maven version {rust_version} and Python version {python_version}") + PY + bump-version rust_version: #!/usr/bin/env bash set -euo pipefail @@ -174,4 +269,5 @@ bump-version rust_version: print(f"Python package: {python_version}") print(f"Maven artifact: {rust_version}") PY + cargo update --workspace cargo fmt --all diff --git a/crates/goose-sdk/python/pyproject.toml b/crates/goose-sdk/python/pyproject.toml index 2d3037b53..cba35ff33 100644 --- a/crates/goose-sdk/python/pyproject.toml +++ b/crates/goose-sdk/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "goose-sdk" -version = "0.1.0a6" +version = "0.1.0a7" description = "Python bindings for the goose Development Kit (GDK)" readme = "README.md" requires-python = ">=3.9" diff --git a/crates/goose-sdk/python/setup.py b/crates/goose-sdk/python/setup.py index 5166d0ee9..7c774de31 100644 --- a/crates/goose-sdk/python/setup.py +++ b/crates/goose-sdk/python/setup.py @@ -1,7 +1,12 @@ -from setuptools import setup +from setuptools import Distribution, setup from wheel.bdist_wheel import bdist_wheel +class BinaryDistribution(Distribution): + def has_ext_modules(self): + return True + + class BinaryWheel(bdist_wheel): def finalize_options(self): super().finalize_options() @@ -12,4 +17,4 @@ class BinaryWheel(bdist_wheel): return "py3", "none", platform_tag -setup(cmdclass={"bdist_wheel": BinaryWheel}) +setup(cmdclass={"bdist_wheel": BinaryWheel}, distclass=BinaryDistribution) diff --git a/documentation/src/data/gdk-api.json b/documentation/src/data/gdk-api.json index 29eef54e1..7d2ad8c2a 100644 --- a/documentation/src/data/gdk-api.json +++ b/documentation/src/data/gdk-api.json @@ -1,7 +1,7 @@ { "versions": [ { - "version": "0.1.0-alpha.6", + "version": "0.1.0-alpha.7", "docVersion": "0.1", "source": "crates/goose-sdk/src/bindings.rs", "functions": [