diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8389897..888c2fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,45 @@ jobs: - name: Test run: cargo test --workspace + + # Packaging breakage should show up on the pull request, not on the tag. + npm-launcher: + name: npm launcher typecheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Build the launcher + working-directory: packaging/npm/si + run: | + npm ci + npm run build + + pypi-wheel: + name: PyPI wheel build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Read Rust toolchain + shell: bash + run: | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" + echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" + + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + + - uses: Swatinem/rust-cache@v2 + + - name: Build wheel + uses: PyO3/maturin-action@v1 + with: + manylinux: "off" + working-directory: packaging/pypi/si + args: --release --locked --out dist diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml index 4c1f101..5dc27ae 100644 --- a/.github/workflows/release-crates.yml +++ b/.github/workflows/release-crates.yml @@ -1,4 +1,4 @@ -name: Publish to crates.io +name: CLI Release Crates.io on: push: @@ -94,6 +94,19 @@ jobs: exit 1 fi + # The Claude plugin directory publishes an update only when plugin.json's + # version rises, so it moves with the crates. + - name: Check the Claude plugin version matches the tag + shell: bash + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + plugin=$(jq -r .version packaging/claude-plugin/.claude-plugin/plugin.json) + if [ "$plugin" != "$VERSION" ]; then + echo "::error::packaging/claude-plugin is at ${plugin}, but the tag is v${VERSION}" + exit 1 + fi + - name: Test run: cargo test --workspace --locked diff --git a/.github/workflows/release-github.yml b/.github/workflows/release-github.yml new file mode 100644 index 0000000..a432ee5 --- /dev/null +++ b/.github/workflows/release-github.yml @@ -0,0 +1,169 @@ +name: CLI Release GitHub + +# Attaches the prebuilt `si` binaries, each with a .sha256 sidecar, to the GitHub release for the +# tag, so Homebrew, Scoop or winget can be added later without rebuilding. Re-running overwrites +# the assets on the same release, so a re-pushed or re-dispatched tag is harmless. + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. v1.3.0)" + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.event.inputs.tag || github.ref_name }} + cancel-in-progress: false + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + verify-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + - name: Tag matches the workspace version + shell: bash + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + run: | + workspace=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + if [ "$TAG" != "v$workspace" ]; then + echo "::error::tag $TAG does not match the workspace version $workspace" + exit 1 + fi + + build: + name: Build binary (${{ matrix.build.NAME }}) + needs: verify-version + runs-on: ${{ matrix.build.OS }} + strategy: + fail-fast: false + matrix: + build: + - { + NAME: linux-x64, + OS: ubuntu-22.04, + TARGET: x86_64-unknown-linux-gnu, + } + - { + NAME: linux-arm64, + OS: ubuntu-22.04-arm, + TARGET: aarch64-unknown-linux-gnu, + } + - { + NAME: windows-x64, + OS: windows-2022, + TARGET: x86_64-pc-windows-msvc, + } + - { + NAME: windows-arm64, + OS: windows-2022, + TARGET: aarch64-pc-windows-msvc, + } + - { NAME: darwin-x64, OS: macos-26, TARGET: x86_64-apple-darwin } + - { NAME: darwin-arm64, OS: macos-26, TARGET: aarch64-apple-darwin } + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Read Rust toolchain + shell: bash + run: | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" + if [ -z "$rust_toolchain" ]; then + echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 + exit 1 + fi + echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + + - name: Install Rust target + shell: bash + run: | + rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }} + rustup target list --installed + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + with: + key: github-${{ matrix.build.TARGET }} + + # Linux builds on the oldest runner image for its glibc floor (2.35). The repo uses rustls, + # so there is no OpenSSL to link or vendor. + - name: Build binary + shell: bash + run: cargo build --locked --release -p sigit-si-cli --bin si --target ${{ matrix.build.TARGET }} + + # The exe must not import the VC++ runtime DLLs (see .cargo/config.toml), or it fails to + # load on a machine without the redistributable. + - name: Check static CRT + if: contains(matrix.build.TARGET, 'windows') + shell: pwsh + run: ./packaging/windows/check-static-crt.ps1 -Path target/${{ matrix.build.TARGET }}/release/si.exe + + # Windows runners use bash from Git for Windows, which has sha256sum; macOS only has shasum. + - name: Package binary and checksum + shell: bash + env: + BUILD_NAME: ${{ matrix.build.NAME }} + TARGET: ${{ matrix.build.TARGET }} + run: | + suffix="" + if [[ "${BUILD_NAME}" == windows-* ]]; then + suffix=".exe" + fi + + mkdir -p release + asset="si-${BUILD_NAME}${suffix}" + cp "target/${TARGET}/release/si${suffix}" "release/${asset}" + + cd release + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "${asset}" | awk '{print $1}' > "${asset}.sha256" + else + shasum -a 256 "${asset}" | awk '{print $1}' > "${asset}.sha256" + fi + echo "${asset}: $(cat "${asset}.sha256")" + + - name: Upload binary artifact + uses: actions/upload-artifact@v4 + with: + name: github-binary-${{ matrix.build.NAME }} + path: release/* + + release: + name: Create GitHub release + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download binary artifacts + uses: actions/download-artifact@v4 + with: + pattern: github-binary-* + path: release + merge-multiple: true + + - name: Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.inputs.tag || github.ref_name }} + files: release/* + generate_release_notes: true diff --git a/.github/workflows/release-mcp-registry.yml b/.github/workflows/release-mcp-registry.yml index 18b03a9..e76e09a 100644 --- a/.github/workflows/release-mcp-registry.yml +++ b/.github/workflows/release-mcp-registry.yml @@ -1,4 +1,4 @@ -name: MCP Registry Release +name: CLI Release MCP Registry on: workflow_dispatch: diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml new file mode 100644 index 0000000..f16b1df --- /dev/null +++ b/.github/workflows/release-npm.yml @@ -0,0 +1,280 @@ +name: CLI Release NPM + +# Publishes @getsigit/si, a launcher that resolves the native `si` binary from one of six +# platform packages (@getsigit/si--), on the same tag that release-crates.yml +# publishes from. +# +# Auth is npm Trusted Publishing (OIDC), so no token is stored. Each of the seven packages needs +# a trusted publisher for this repository and workflow (release-npm.yml). `npm trust` only works +# on a package that already exists, so the first version of each is published by hand. + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. v1.3.0)" + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.event.inputs.tag || github.ref_name }} + cancel-in-progress: false + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + # The binary reports CARGO_PKG_VERSION, and the launcher package.json carries its own copy of + # the version, so both must agree with the tag. + verify-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + - name: Tag matches the workspace and npm package versions + shell: bash + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + run: | + workspace=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + if [ "$TAG" != "v$workspace" ]; then + echo "::error::tag $TAG does not match the workspace version $workspace" + exit 1 + fi + + npm_version=$(node -p "require('./packaging/npm/si/package.json').version") + if [ "$TAG" != "v$npm_version" ]; then + echo "::error::tag $TAG does not match packaging/npm/si/package.json version $npm_version. Bump it (and its lockfile) with the workspace version." + exit 1 + fi + + publish-npm-binaries: + name: Publish @getsigit/si-${{ matrix.build.NAME }} + needs: verify-version + runs-on: ${{ matrix.build.OS }} + permissions: + contents: read + id-token: write + strategy: + fail-fast: false + matrix: + build: + - { + NAME: linux-x64, + OS: ubuntu-22.04, + TARGET: x86_64-unknown-linux-gnu, + NODE_OS: linux, + NODE_ARCH: x64, + } + - { + NAME: linux-arm64, + OS: ubuntu-22.04-arm, + TARGET: aarch64-unknown-linux-gnu, + NODE_OS: linux, + NODE_ARCH: arm64, + } + - { + NAME: windows-x64, + OS: windows-2022, + TARGET: x86_64-pc-windows-msvc, + NODE_OS: win32, + NODE_ARCH: x64, + } + - { + NAME: windows-arm64, + OS: windows-2022, + TARGET: aarch64-pc-windows-msvc, + NODE_OS: win32, + NODE_ARCH: arm64, + } + - { + NAME: darwin-x64, + OS: macos-26, + TARGET: x86_64-apple-darwin, + NODE_OS: darwin, + NODE_ARCH: x64, + } + - { + NAME: darwin-arm64, + OS: macos-26, + TARGET: aarch64-apple-darwin, + NODE_OS: darwin, + NODE_ARCH: arm64, + } + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Set the release version + shell: bash + run: | + release_version="${{ github.event.inputs.tag || github.ref_name }}" + echo "RELEASE_VERSION=${release_version#v}" >> "$GITHUB_ENV" + + - name: Read Rust toolchain + shell: bash + run: | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" + if [ -z "$rust_toolchain" ]; then + echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 + exit 1 + fi + echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + + - name: Install Rust target + shell: bash + run: | + rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }} + rustup target list --installed + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + with: + key: npm-${{ matrix.build.TARGET }} + + # Linux builds on the oldest runner image for its glibc floor (2.35). The repo uses rustls, + # so there is no OpenSSL to link or vendor. + - name: Build binary + shell: bash + run: cargo build --locked --release -p sigit-si-cli --bin si --target ${{ matrix.build.TARGET }} + + # The exe must not import the VC++ runtime DLLs (see .cargo/config.toml), or it fails to + # load on a machine without the redistributable. + - name: Check static CRT + if: contains(matrix.build.TARGET, 'windows') + shell: pwsh + run: ./packaging/windows/check-static-crt.ps1 -Path target/${{ matrix.build.TARGET }}/release/si.exe + + - name: Install Node + uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + registry-url: "https://registry.npmjs.org" + + - name: Render the platform package + shell: bash + env: + BUILD_NAME: ${{ matrix.build.NAME }} + TARGET: ${{ matrix.build.TARGET }} + NODE_OS: ${{ matrix.build.NODE_OS }} + NODE_ARCH: ${{ matrix.build.NODE_ARCH }} + run: | + package_directory="si-${BUILD_NAME}" + executable_name="si" + if [[ "${BUILD_NAME}" == windows-* ]]; then + executable_name="si.exe" + fi + + mkdir -p "packaging/npm/${package_directory}/bin" + node packaging/npm/scripts/render-platform-package.cjs \ + "${package_directory}" "${RELEASE_VERSION}" "${NODE_OS}" "${NODE_ARCH}" + cp "target/${TARGET}/release/${executable_name}" "packaging/npm/${package_directory}/bin/" + + - name: Check whether the package version already exists on npm + id: npm-check + shell: bash + env: + BUILD_NAME: ${{ matrix.build.NAME }} + run: | + # A 404 means this version is not on npm yet. Anything other than 200 or 404 is an + # outage or a block, which must not read as "not published yet". + status=$(curl -sS -o /dev/null -w '%{http_code}' \ + --retry 3 --retry-delay 2 --retry-all-errors \ + "https://registry.npmjs.org/@getsigit%2Fsi-${BUILD_NAME}/${RELEASE_VERSION}") + + case "$status" in + 200) + echo "@getsigit/si-${BUILD_NAME}@${RELEASE_VERSION} already exists on npm, skipping publish" + echo "exists=true" >> "$GITHUB_OUTPUT" + ;; + 404) + echo "exists=false" >> "$GITHUB_OUTPUT" + ;; + *) + echo "Unexpected ${status} from npm while checking @getsigit/si-${BUILD_NAME}@${RELEASE_VERSION}" >&2 + exit 1 + ;; + esac + + - name: Publish to npm + if: steps.npm-check.outputs.exists != 'true' + shell: bash + env: + BUILD_NAME: ${{ matrix.build.NAME }} + run: | + cd "packaging/npm/si-${BUILD_NAME}" + npm publish --access public --provenance + + publish-npm-base: + name: Publish @getsigit/si + needs: publish-npm-binaries + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Set the release version + shell: bash + run: | + release_version="${{ github.event.inputs.tag || github.ref_name }}" + echo "RELEASE_VERSION=${release_version#v}" >> "$GITHUB_ENV" + + - name: Install Node + uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + registry-url: "https://registry.npmjs.org" + + - name: Render and build the launcher + shell: bash + working-directory: packaging/npm/si + run: | + node ../scripts/render-main-package.cjs ./package.json "${RELEASE_VERSION}" + npm ci + npm run build + + - name: Check whether the package version already exists on npm + id: npm-check + shell: bash + run: | + status=$(curl -sS -o /dev/null -w '%{http_code}' \ + --retry 3 --retry-delay 2 --retry-all-errors \ + "https://registry.npmjs.org/@getsigit%2Fsi/${RELEASE_VERSION}") + + case "$status" in + 200) + echo "@getsigit/si@${RELEASE_VERSION} already exists on npm, skipping publish" + echo "exists=true" >> "$GITHUB_OUTPUT" + ;; + 404) + echo "exists=false" >> "$GITHUB_OUTPUT" + ;; + *) + echo "Unexpected ${status} from npm while checking @getsigit/si@${RELEASE_VERSION}" >&2 + exit 1 + ;; + esac + + - name: Publish to npm + if: steps.npm-check.outputs.exists != 'true' + shell: bash + working-directory: packaging/npm/si + run: npm publish --access public --provenance diff --git a/.github/workflows/release-nuget.yml b/.github/workflows/release-nuget.yml index 4baeaa1..24f7a17 100644 --- a/.github/workflows/release-nuget.yml +++ b/.github/workflows/release-nuget.yml @@ -1,4 +1,4 @@ -name: Release NuGet +name: CLI Release NuGet # Publishes SiGit.Cli, a .NET tool that bundles the native `si` binaries, on the same tag that # release-crates.yml publishes from. diff --git a/.github/workflows/release-pypi.yml b/.github/workflows/release-pypi.yml new file mode 100644 index 0000000..6040320 --- /dev/null +++ b/.github/workflows/release-pypi.yml @@ -0,0 +1,247 @@ +name: CLI Release PyPI + +# Publishes sigit-si-cli, the native `si` binary packaged as maturin wheels, on the same tag that +# release-crates.yml publishes from. +# +# Windows arm64 wheels are intentionally not built here. GitHub's hosted Windows runners provide +# x64 Python, and maturin refuses to build an arm64 wheel when the interpreter reports win-amd64. +# +# Auth is PyPI Trusted Publishing (OIDC), so no API token is stored. pypi.org needs a publisher +# for this repository and workflow (release-pypi.yml), with no environment. For the first release +# that is a pending publisher, which creates the project on first upload. + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. v1.3.0)" + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.event.inputs.tag || github.ref_name }} + cancel-in-progress: false + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + PYPI_PACKAGE: sigit-si-cli + +jobs: + verify-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + - name: Tag matches the workspace version + shell: bash + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + run: | + workspace=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + if [ "$TAG" != "v$workspace" ]; then + echo "::error::tag $TAG does not match the workspace version $workspace" + exit 1 + fi + + build-wheels: + name: Build wheel (${{ matrix.build.NAME }}) + needs: verify-version + runs-on: ${{ matrix.build.OS }} + strategy: + fail-fast: false + matrix: + build: + - { + NAME: linux-x64, + OS: ubuntu-22.04, + TARGET: x86_64-unknown-linux-gnu, + MANYLINUX: "2_28", + } + - { + NAME: linux-arm64, + OS: ubuntu-22.04-arm, + TARGET: aarch64-unknown-linux-gnu, + MANYLINUX: "2_28", + } + - { + NAME: windows-x64, + OS: windows-2022, + TARGET: x86_64-pc-windows-msvc, + } + - { NAME: darwin-x64, OS: macos-26, TARGET: x86_64-apple-darwin } + - { NAME: darwin-arm64, OS: macos-26, TARGET: aarch64-apple-darwin } + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Read Rust toolchain + shell: bash + run: | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" + if [ -z "$rust_toolchain" ]; then + echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 + exit 1 + fi + echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + targets: ${{ matrix.build.TARGET }} + + # The repo uses rustls and a vendored libgit2, so the manylinux container needs no extra + # system packages. + - name: Build wheel + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.build.TARGET }} + manylinux: ${{ matrix.build.MANYLINUX || 'off' }} + working-directory: packaging/pypi/si + args: --release --locked --compatibility pypi --out dist + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: pypi-wheels-${{ matrix.build.NAME }} + path: packaging/pypi/si/dist/* + + build-sdist: + name: Build source distribution + needs: verify-version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + working-directory: packaging/pypi/si + args: --out dist + + - name: Upload sdist artifact + uses: actions/upload-artifact@v4 + with: + name: pypi-sdist + path: packaging/pypi/si/dist/* + + # Installing from the built wheels proves the binary loads, not just that it was packed: a + # missing runtime DLL or a glibc mismatch shows up here instead of on PyPI. + smoke-test: + name: Smoke test (${{ matrix.os }}) + needs: + - build-wheels + - build-sdist + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + # The oldest image, so the Linux wheel runs against the glibc floor. + - ubuntu-22.04 + - windows-2022 + - macos-26 + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - name: Set the release version + shell: bash + run: | + release_version="${{ github.event.inputs.tag || github.ref_name }}" + echo "RELEASE_VERSION=${release_version#v}" >> "$GITHUB_ENV" + + - name: Download distribution artifacts + uses: actions/download-artifact@v4 + with: + pattern: pypi-* + path: dist + merge-multiple: true + + # --only-binary keeps pip from falling back to the sdist, which would compile instead of + # testing the wheel. + - name: Install from the built wheels + shell: bash + run: | + python -m venv .venv + if [ -d .venv/Scripts ]; then bin_dir=.venv/Scripts; else bin_dir=.venv/bin; fi + "${bin_dir}/python" -m pip install --no-index --only-binary :all: --find-links dist "${PYPI_PACKAGE}==${RELEASE_VERSION}" + echo "SI_BIN_DIR=${bin_dir}" >> "$GITHUB_ENV" + + - name: Run the installed binary + shell: bash + run: | + output="$("${SI_BIN_DIR}/si" --version)" + echo "${output}" + case "${output}" in + *"${RELEASE_VERSION}"*) ;; + *) + echo "::error::si --version did not report ${RELEASE_VERSION}" >&2 + exit 1 + ;; + esac + + publish-pypi: + name: Publish to PyPI + needs: smoke-test + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Set the release version + shell: bash + run: | + release_version="${{ github.event.inputs.tag || github.ref_name }}" + echo "RELEASE_VERSION=${release_version#v}" >> "$GITHUB_ENV" + + - name: Download distribution artifacts + uses: actions/download-artifact@v4 + with: + pattern: pypi-* + path: dist + merge-multiple: true + + - name: Check whether release already exists on PyPI + id: pypi-check + shell: bash + run: | + # A 404 means the project or the version is not on PyPI, so publish. Anything other than + # 200 or 404 is an outage or a block, which must not read as "not published yet". + status=$(curl -sS -o /dev/null -w '%{http_code}' \ + --retry 3 --retry-delay 2 --retry-all-errors \ + "https://pypi.org/pypi/${PYPI_PACKAGE}/${RELEASE_VERSION}/json") + + case "$status" in + 200) + echo "${PYPI_PACKAGE} ${RELEASE_VERSION} already exists on PyPI, skipping publish" + echo "exists=true" >> "$GITHUB_OUTPUT" + ;; + 404) + echo "exists=false" >> "$GITHUB_OUTPUT" + ;; + *) + echo "Unexpected ${status} from PyPI while checking whether ${PYPI_PACKAGE} ${RELEASE_VERSION} is published" >&2 + exit 1 + ;; + esac + + - name: Publish distribution + if: steps.pypi-check.outputs.exists != 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true diff --git a/.gitignore b/.gitignore index 0facf51..6777f6f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,9 @@ packaging/nuget/**/obj/ packaging/nuget/**/native/ packaging/nuget/dist/ packaging/nuget/NuGet.Config + +# npm and PyPI packaging +/packaging/npm/si-*/ +/packaging/npm/si/lib/ +/packaging/npm/si/node_modules/ +/packaging/pypi/*/dist/ diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/Cargo.lock b/Cargo.lock index a698850..7b89e06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1581,7 +1581,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "sigit-si-api" -version = "1.3.1" +version = "1.4.0" dependencies = [ "chrono", "reqwest", @@ -1593,7 +1593,7 @@ dependencies = [ [[package]] name = "sigit-si-cli" -version = "1.3.1" +version = "1.4.0" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index e211249..398c7f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = ["crates/cli", "crates/sigit-si-api"] # without pulling in clap, dialoguer, and the rest of the terminal surface. # `cli` is the thin `si` binary on top of it. [workspace.package] -version = "1.3.1" +version = "1.4.0" edition = "2021" authors = ["Seto Elkahfi "] license = "Apache-2.0" @@ -33,7 +33,7 @@ rmcp = { version = "3.2", features = [ schemars = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" -sigit-si-api = { version = "1.3.1", path = "crates/sigit-si-api" } +sigit-si-api = { version = "1.4.0", path = "crates/sigit-si-api" } tabled = { version = "0.20", default-features = false, features = ["std"] } thiserror = "2.0" # `io-std` is what the MCP stdio transport binds to. diff --git a/README.md b/README.md index d042e5a..a77e3a1 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,18 @@ drive Cloud Sessions, all from the terminal. cargo install --path crates/cli ``` -This installs a binary named `si`. On a machine with the .NET SDK there is also -a prebuilt tool: +This installs a binary named `si`. Prebuilt binaries are also available: ```sh -dotnet tool install --global SiGit.Cli +npm install -g @getsigit/si # npm +pipx install sigit-si-cli # PyPI (or: uvx --from sigit-si-cli si) +dotnet tool install --global SiGit.Cli # .NET ``` +Or download a binary for your platform from +[GitHub Releases](https://github.com/getsigit/si/releases); each asset has a +`.sha256` file next to it. + ## Usage ```sh @@ -116,6 +121,17 @@ they're served over the same MCP (Model Context Protocol) JSON-RPC endpoint the AI agent uses. `sigit-si-api` speaks that transport internally; it's not visible at the call site. +## Claude plugin + +`packaging/claude-plugin` is the siGit plugin for the Claude plugin directory. It bundles the +hosted server at `https://sigit.si/api/v1/mcp`, not `si mcp`, so it works in claude.ai and +Cowork as well as Claude Code, and users sign in through the browser with sigit.si's OAuth +server. The directory tracks `main` and reads that folder, and it publishes an update only +when `version` in `.claude-plugin/plugin.json` rises, so that version moves with the crates +(`release-crates.yml` fails if it doesn't match the tag). Its README is the listing text and +goes through the directory's policy review, so it must not tell people to install or add any +other MCP server. + ## MCP Registry listings This repo publishes two entries to the @@ -142,11 +158,18 @@ marker can never be listed, and fixing it costs a new version. The internal setup and release runbook live with the server (private `sigit-si` repo). To cut a release, bump `[workspace.package].version` and the `sigit-si-api` -dependency in the root `Cargo.toml`, merge `development` into `main`, and push a +dependency in the root `Cargo.toml`, and the `version` in +`packaging/npm/si/package.json` and its lockfile (`release-npm.yml` fails when +it differs from the tag; PyPI and NuGet read the version from the crate), and +`version` in `packaging/claude-plugin/.claude-plugin/plugin.json`, merge `development` into `main`, and push a `vX.Y.Z` tag. `release-crates.yml` checks the crate versions against the tag, publishes whichever of `sigit-si-api` and `sigit-si-cli` isn't on crates.io yet (through Trusted Publishing, so no token is stored), then dispatches -`release-mcp-registry.yml`. +`release-mcp-registry.yml`. The same tag also starts `release-github.yml` +(release assets with checksums), `release-npm.yml`, `release-pypi.yml` and +`release-nuget.yml`. They run independently, publish through Trusted Publishing +where the registry supports it, and skip a version that is already published, +so any of them can be re-run on its own. ## Development diff --git a/packaging/claude-plugin/.claude-plugin/icon.png b/packaging/claude-plugin/.claude-plugin/icon.png new file mode 100644 index 0000000..2db84b6 Binary files /dev/null and b/packaging/claude-plugin/.claude-plugin/icon.png differ diff --git a/packaging/claude-plugin/.claude-plugin/plugin.json b/packaging/claude-plugin/.claude-plugin/plugin.json new file mode 100644 index 0000000..df29fbb --- /dev/null +++ b/packaging/claude-plugin/.claude-plugin/plugin.json @@ -0,0 +1,16 @@ +{ + "name": "sigit", + "version": "1.4.0", + "description": "Work with your siGit (sigit.si) repositories from Claude: browse and search code, read and open issues and pull requests, comment, and search the web.", + "author": { + "name": "siGit", + "email": "privacy@sigit.si", + "url": "https://sigit.si" + }, + "homepage": "https://sigit.si", + "repository": "https://github.com/getsigit/si", + "license": "Apache-2.0", + "keywords": ["git", "git hosting", "code search", "pull requests", "issues", "sigit"], + "privacyPolicyUrl": "https://sigit.si/privacy", + "icon": ".claude-plugin/icon.png" +} diff --git a/packaging/claude-plugin/.mcp.json b/packaging/claude-plugin/.mcp.json new file mode 100644 index 0000000..2b8e519 --- /dev/null +++ b/packaging/claude-plugin/.mcp.json @@ -0,0 +1,8 @@ +{ + "mcpServers": { + "sigit": { + "type": "http", + "url": "https://sigit.si/api/v1/mcp" + } + } +} diff --git a/packaging/claude-plugin/README.md b/packaging/claude-plugin/README.md new file mode 100644 index 0000000..043b3d2 --- /dev/null +++ b/packaging/claude-plugin/README.md @@ -0,0 +1,44 @@ +# siGit for Claude + +This plugin connects Claude to your account on [siGit](https://sigit.si), the Git hosting +service for code and open-weights models. Once it is connected, you can ask Claude about the +repositories you can see on sigit.si, have it read and search their code, and have it open +issues and pull requests for you. + +## Signing in + +The first time Claude uses a siGit tool, it asks you to sign in. A browser window opens on +sigit.si, where you sign in to your siGit account and approve Claude's access. Claude gets +read access to your profile and to the repositories you can see, and permission to act for +you on the tools below. Nothing is shared until you approve. To disconnect Claude, revoke it +under Settings, Authorized applications on sigit.si. Its token stops working immediately. + +## Tools + +| Tool | What it does | +| --- | --- | +| `list_repositories` | Lists the repositories you can see, optionally filtered by name | +| `get_file_contents` | Reads a file at a branch, tag or commit | +| `search_code` | Searches one repository's code for a string | +| `list_issues`, `get_issue` | Lists issues and reads one with its comments | +| `create_issue` | Opens an issue | +| `list_pull_requests`, `get_pull_request` | Lists pull requests and reads one with its comments and diff | +| `create_pull_request` | Opens a pull request between two branches | +| `add_issue_comment` | Comments on an issue or pull request | +| `web_search` | Searches the web | + +`create_issue`, `create_pull_request` and `add_issue_comment` change things on sigit.si. The +other tools only read. + +## Your data + +The tools read and write data in your siGit account on sigit.si. What they return is sent to +Claude and handled under Anthropic's terms. `web_search` sends your search query to Brave +Search, which returns the results; Brave does not receive your account details. siGit keeps +your repositories, issues and pull requests until you delete them or your account. The +[siGit privacy policy](https://sigit.si/privacy) covers all of this in full, and questions +about your data go to privacy@sigit.si. + +## License + +Apache-2.0 diff --git a/packaging/npm/scripts/render-main-package.cjs b/packaging/npm/scripts/render-main-package.cjs new file mode 100644 index 0000000..5aa2c18 --- /dev/null +++ b/packaging/npm/scripts/render-main-package.cjs @@ -0,0 +1,57 @@ +#!/usr/bin/env node + +const fs = require("fs"); +const path = require("path"); + +const [outputPath, version] = process.argv.slice(2); + +if (!outputPath || !version) { + throw new Error("Usage: render-main-package.cjs "); +} + +// The platform binary packages the launcher resolves at runtime. Kept in lockstep with the +// release-npm.yml build matrix. +const platformSuffixes = [ + "darwin-arm64", + "darwin-x64", + "linux-arm64", + "linux-x64", + "windows-arm64", + "windows-x64", +]; + +const optionalDependencies = {}; +for (const suffix of platformSuffixes) { + optionalDependencies[`@getsigit/si-${suffix}`] = version; +} + +const packageJson = { + name: "@getsigit/si", + version, + // Ownership proof for the MCP Registry: must match `name` in the repo's server.json. + mcpName: "si.sigit/cli", + keywords: ["sigit", "si", "cli", "git", "code-review", "mcp"], + bin: { + si: "lib/index.js", + }, + files: ["lib", "README.md"], + description: "si, the sigit.si command line interface.", + license: "Apache-2.0", + homepage: "https://sigit.si", + repository: { + type: "git", + url: "git+https://github.com/getsigit/si.git", + }, + scripts: { + typecheck: "tsc --noEmit", + build: "tsc", + dev: "npm run build && node lib/index.js", + }, + devDependencies: { + "@types/node": "^18.15.11", + typescript: "^5.0.0", + }, + optionalDependencies, +}; + +fs.writeFileSync(path.resolve(outputPath), `${JSON.stringify(packageJson, null, 2)}\n`); diff --git a/packaging/npm/scripts/render-platform-package.cjs b/packaging/npm/scripts/render-platform-package.cjs new file mode 100644 index 0000000..1eabfd7 --- /dev/null +++ b/packaging/npm/scripts/render-platform-package.cjs @@ -0,0 +1,37 @@ +#!/usr/bin/env node + +const fs = require("fs"); +const path = require("path"); + +const [packageName, version, operatingSystem, architecture] = process.argv.slice(2); + +if (!packageName || !version || !operatingSystem || !architecture) { + throw new Error("Usage: render-platform-package.cjs "); +} + +const packageDirectory = path.resolve(__dirname, "..", packageName); + +fs.mkdirSync(packageDirectory, { recursive: true }); + +const packageJson = { + name: `@getsigit/${packageName}`, + version, + description: "Platform binary for the si CLI.", + license: "Apache-2.0", + repository: { + type: "git", + url: "git+https://github.com/getsigit/si.git", + }, + keywords: [packageName, "si", "sigit", "cli", "binary"], + os: [operatingSystem], + cpu: [architecture], + files: ["bin"], +}; + +const readme = `# ${packageName} + +Not meant to be used directly. Please see [@getsigit/si](https://www.npmjs.com/package/@getsigit/si). +`; + +fs.writeFileSync(path.join(packageDirectory, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`); +fs.writeFileSync(path.join(packageDirectory, "README.md"), readme); diff --git a/packaging/npm/si/.gitignore b/packaging/npm/si/.gitignore new file mode 100644 index 0000000..3b4e8dc --- /dev/null +++ b/packaging/npm/si/.gitignore @@ -0,0 +1,2 @@ +lib/ +node_modules/ diff --git a/packaging/npm/si/README.md b/packaging/npm/si/README.md new file mode 100644 index 0000000..9438814 --- /dev/null +++ b/packaging/npm/si/README.md @@ -0,0 +1,54 @@ + + +# si for npm + +`si` is the command line interface for [sigit.si](https://sigit.si): sign in, manage repositories, +review pull requests, triage issues, search code, and drive Cloud Sessions from the terminal. + +This package installs the native `si` binary for your platform. It has no JavaScript API. + +## Install + +```sh +npm install -g @getsigit/si +``` + +Or run it without installing: + +```sh +npx @getsigit/si --help +``` + +## Run + +```sh +si auth login +si repo list +``` + +## Platform support + +The binary comes from an optional dependency that npm selects for your machine: + +- macOS `arm64`, `x64` +- Linux `arm64`, `x64` (glibc) +- Windows `arm64`, `x64` + +Installing with `--omit=optional` leaves the binary out, and `si` then fails with a message saying so. + +## Other installation methods + +- Cargo: `cargo install sigit-si-cli` +- PyPI: `pipx install sigit-si-cli` +- .NET: `dotnet tool install --global SiGit.Cli` +- Prebuilt binaries: [GitHub Releases](https://github.com/getsigit/si/releases) + +## Source + +- Repository: +- Website: +- Issues: + +## License + +[Apache 2.0](https://github.com/getsigit/si/blob/main/LICENSE) diff --git a/packaging/npm/si/package-lock.json b/packaging/npm/si/package-lock.json new file mode 100644 index 0000000..9ee41e3 --- /dev/null +++ b/packaging/npm/si/package-lock.json @@ -0,0 +1,77 @@ +{ + "name": "@getsigit/si", + "version": "1.4.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@getsigit/si", + "version": "1.4.0", + "license": "Apache-2.0", + "bin": { + "si": "lib/index.js" + }, + "devDependencies": { + "@types/node": "^18.15.11", + "typescript": "^5.0.0" + }, + "optionalDependencies": { + "@getsigit/si-darwin-arm64": "1.4.0", + "@getsigit/si-darwin-x64": "1.4.0", + "@getsigit/si-linux-arm64": "1.4.0", + "@getsigit/si-linux-x64": "1.4.0", + "@getsigit/si-windows-arm64": "1.4.0", + "@getsigit/si-windows-x64": "1.4.0" + } + }, + "node_modules/@getsigit/si-darwin-arm64": { + "optional": true + }, + "node_modules/@getsigit/si-darwin-x64": { + "optional": true + }, + "node_modules/@getsigit/si-linux-arm64": { + "optional": true + }, + "node_modules/@getsigit/si-linux-x64": { + "optional": true + }, + "node_modules/@getsigit/si-windows-arm64": { + "optional": true + }, + "node_modules/@getsigit/si-windows-x64": { + "optional": true + }, + "node_modules/@types/node": { + "version": "18.19.130", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/packaging/npm/si/package.json b/packaging/npm/si/package.json new file mode 100644 index 0000000..d232499 --- /dev/null +++ b/packaging/npm/si/package.json @@ -0,0 +1,44 @@ +{ + "name": "@getsigit/si", + "version": "1.4.0", + "mcpName": "si.sigit/cli", + "keywords": [ + "sigit", + "si", + "cli", + "git", + "code-review", + "mcp" + ], + "bin": { + "si": "lib/index.js" + }, + "files": [ + "lib", + "README.md" + ], + "description": "si, the sigit.si command line interface.", + "license": "Apache-2.0", + "homepage": "https://sigit.si", + "repository": { + "type": "git", + "url": "git+https://github.com/getsigit/si.git" + }, + "scripts": { + "typecheck": "tsc --noEmit", + "build": "tsc", + "dev": "npm run build && node lib/index.js" + }, + "devDependencies": { + "@types/node": "^18.15.11", + "typescript": "^5.0.0" + }, + "optionalDependencies": { + "@getsigit/si-darwin-arm64": "1.4.0", + "@getsigit/si-darwin-x64": "1.4.0", + "@getsigit/si-linux-arm64": "1.4.0", + "@getsigit/si-linux-x64": "1.4.0", + "@getsigit/si-windows-arm64": "1.4.0", + "@getsigit/si-windows-x64": "1.4.0" + } +} diff --git a/packaging/npm/si/src/index.ts b/packaging/npm/si/src/index.ts new file mode 100644 index 0000000..706f905 --- /dev/null +++ b/packaging/npm/si/src/index.ts @@ -0,0 +1,44 @@ +#!/usr/bin/env node + +import { spawnSync } from "child_process"; + +/** + * Resolves the native binary from the platform package npm installed next to this one. + * The package is named `@getsigit/si-${os}-${arch}`, with `win32` mapped to `windows`. + * @see https://nodejs.org/api/os.html#osarch + * @see https://nodejs.org/api/os.html#osplatform + */ +function getExePath(): string { + const arch = process.arch; + let os = process.platform as string; + let extension = ""; + if (["win32", "cygwin"].includes(process.platform)) { + os = "windows"; + extension = ".exe"; + } + + try { + return require.resolve(`@getsigit/si-${os}-${arch}/bin/si${extension}`); + } catch (e) { + throw new Error( + `Couldn't find the si binary for ${os}-${arch} inside node_modules. ` + + "Reinstall without --omit=optional, or install with `cargo install sigit-si-cli`.", + ); + } +} + +function run(): void { + const args = process.argv.slice(2); + const result = spawnSync(getExePath(), args, { stdio: "inherit" }); + + if (result.error) { + console.error(`Failed to run si: ${result.error.message}`); + process.exit(1); + } + + // `status` is null when the child was killed by a signal; report that as a failure rather + // than as success. + process.exit(result.status ?? 1); +} + +run(); diff --git a/packaging/npm/si/tsconfig.json b/packaging/npm/si/tsconfig.json new file mode 100644 index 0000000..8e6c790 --- /dev/null +++ b/packaging/npm/si/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "esModuleInterop": true, + "baseUrl": "./", + "outDir": "lib", + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/packaging/nuget/si/README.md b/packaging/nuget/si/README.md index 7942e32..eec9d27 100644 --- a/packaging/nuget/si/README.md +++ b/packaging/nuget/si/README.md @@ -36,6 +36,9 @@ download. `cargo install sigit-si-cli` builds only for your machine. ## Other installation methods - Cargo: `cargo install sigit-si-cli` +- npm: `npm install -g @getsigit/si` +- PyPI: `pipx install sigit-si-cli` +- Prebuilt binaries: [GitHub Releases](https://github.com/getsigit/si/releases) ## Source diff --git a/packaging/pypi/si/README.md b/packaging/pypi/si/README.md new file mode 100644 index 0000000..356e7f6 --- /dev/null +++ b/packaging/pypi/si/README.md @@ -0,0 +1,52 @@ +# si for Python + +`si` is the command line interface for [sigit.si](https://sigit.si): sign in, manage repositories, +review pull requests, triage issues, search code, and drive Cloud Sessions from the terminal. + +This package is the native `si` binary packaged as a Python wheel. There is no Python API. + +## Install + +```sh +pipx install sigit-si-cli +``` + +Or run it without installing: + +```sh +uvx --from sigit-si-cli si --help +``` + +## Run + +```sh +si auth login +si repo list +``` + +## Platform support + +Prebuilt wheels cover: + +- macOS `arm64`, `x86_64` +- Linux `arm64`, `x86_64` (glibc) +- Windows `x86_64` + +On other platforms pip builds from the source distribution, which needs a Rust toolchain. + +## Other installation methods + +- Cargo: `cargo install sigit-si-cli` +- npm: `npm install -g @getsigit/si` +- .NET: `dotnet tool install --global SiGit.Cli` +- Prebuilt binaries: [GitHub Releases](https://github.com/getsigit/si/releases) + +## Source + +- Repository: +- Website: +- Issues: + +## License + +[Apache 2.0](https://github.com/getsigit/si/blob/main/LICENSE) diff --git a/packaging/pypi/si/pyproject.toml b/packaging/pypi/si/pyproject.toml new file mode 100644 index 0000000..9b8d607 --- /dev/null +++ b/packaging/pypi/si/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["maturin>=1.7,<2.0"] +build-backend = "maturin" + +[project] +name = "sigit-si-cli" +description = "si, the sigit.si command line interface." +readme = "README.md" +requires-python = ">=3.8" +dynamic = ["version"] +license = { text = "Apache-2.0" } +authors = [{ name = "Seto Elkahfi", email = "seto@sigit.si" }] +keywords = ["cli", "git", "sigit", "code-review"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Programming Language :: Rust", + "Topic :: Software Development :: Version Control :: Git", + "Topic :: Utilities", +] + +[project.urls] +Homepage = "https://sigit.si" +Repository = "https://github.com/getsigit/si" +Issues = "https://github.com/getsigit/si/issues" + +[tool.maturin] +manifest-path = "../../../crates/cli/Cargo.toml" +bindings = "bin" +strip = true