Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

sdk: publish via OIDC trusted publishing (drop NPM_TOKEN/PYPI_TOKEN)

Rach Pradhan920d9184e59e
diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml
index ca8ece86..f6e32304 100644
--- a/.github/workflows/sdk.yml
+++ b/.github/workflows/sdk.yml
@@ -1,21 +1,20 @@
name: sdk
-# Regenerate the TS + Python SDKs from `harness --schema` on every release tag,
-# so the SDKs never drift from the binary. Publishes to npm/PyPI when the
-# matching token secret is set; otherwise just uploads the generated SDKs as
-# build artifacts.
+# Regenerate the TS + Python SDKs from `graff --schema` on every SDK release tag
+# (sdk-v*), so they never drift from the binary, then publish to npm + PyPI via
+# OIDC trusted publishing (no tokens). workflow_dispatch stops at the artifact.
on:
push:
tags: ["sdk-v*"]
workflow_dispatch: {}
+permissions:
+ id-token: write # OIDC trusted publishing (npm + PyPI)
+ contents: read # checkout
+
jobs:
generate:
runs-on: ubuntu-latest
- # `secrets` cannot be used in `if:` — hoist presence to env flags first.
- env:
- HAVE_NPM_TOKEN: ${{ secrets.NPM_TOKEN != '' }}
- HAVE_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}
steps:
- uses: actions/checkout@v4
@@ -43,33 +42,35 @@ jobs:
sdk/py
schema.json
- # --- Publish (only fires when the token secret exists) ---
+ # --- Publish via OIDC trusted publishing (NO tokens) ---
+ # Fires only on sdk-v* tags. Requires trusted publishers configured for
+ # repo justrach/codegraff + workflow sdk.yml on BOTH npmjs.com and pypi.org.
- uses: actions/setup-node@v4
- if: ${{ env.HAVE_NPM_TOKEN == 'true' }}
+ if: ${{ startsWith(github.ref, 'refs/tags/sdk-v') }}
with:
- node-version: "20"
+ node-version: "24"
registry-url: "https://registry.npmjs.org"
- - name: Publish TS SDK to npm
- if: ${{ env.HAVE_NPM_TOKEN == 'true' && startsWith(github.ref, 'refs/tags/sdk-v') }}
+ - name: Publish TS SDK to npm (OIDC + provenance)
+ if: ${{ startsWith(github.ref, 'refs/tags/sdk-v') }}
working-directory: sdk/ts
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
+ npm install -g npm@latest # trusted publishing needs npm >= 11.5.1
npm version "${GITHUB_REF_NAME#sdk-v}" --no-git-tag-version --allow-same-version
npm publish --access public
- uses: actions/setup-python@v5
- if: ${{ env.HAVE_PYPI_TOKEN == 'true' }}
+ if: ${{ startsWith(github.ref, 'refs/tags/sdk-v') }}
with:
python-version: "3.12"
- - name: Publish Python SDK to PyPI
- if: ${{ env.HAVE_PYPI_TOKEN == 'true' && startsWith(github.ref, 'refs/tags/sdk-v') }}
+ - name: Build Python SDK (codegraff)
+ if: ${{ startsWith(github.ref, 'refs/tags/sdk-v') }}
working-directory: sdk/py
- env:
- TWINE_USERNAME: __token__
- TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
- python3 -m pip install build twine
sed -i "s/^version = .*/version = \"${GITHUB_REF_NAME#sdk-v}\"/" pyproject.toml
+ python3 -m pip install build
python3 -m build
- python3 -m twine upload dist/*
+ - name: Publish Python SDK to PyPI (OIDC)
+ if: ${{ startsWith(github.ref, 'refs/tags/sdk-v') }}
+ uses: pypa/gh-action-pypi-publish@release/v1
+ with:
+ packages-dir: sdk/py/dist