Publish Python SDK #225
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # GENERATED by sdk-actions `bin/workflow` — update with: bin/workflow update <this file> | |
| # sdk-actions: {"template":"release/py/turnkey","ref":"71731d4a726df3e3bf42e50c2da4a75842b038dd","version":"1.0.0","params":{"dry_run_environment":"publish-dry-run","emoji":":python:","package_name":"braintrust","publish_environment":"publish","python_version":".tool-versions","slack_channel_var":"SLACK_SDK_RELEASE_CHANNEL","slack_token_secret":"SLACK_BOT_TOKEN","version_file":"py/src/braintrust/version.py","workflow_name":"Publish Python SDK","working_directory":"py"}} | |
| name: Publish Python SDK | |
| # Releases braintrust to PyPI via braintrustdata/sdk-actions. Dispatch after merging | |
| # the commit that bumps VERSION in py/src/braintrust/version.py; the release runs against that commit's SHA. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| _instructions: | |
| description: "⚠️ Before starting: Merge a version bump PR to the target branch. The version is read from the SHA: it cannot be overridden." | |
| type: string | |
| default: "I have merged a version bump PR" | |
| required: false | |
| release_type: | |
| description: "Release type (stable → GitHub release; prerelease → none)" | |
| type: choice | |
| default: stable | |
| options: [stable, prerelease] | |
| sha: | |
| description: "Commit SHA (of the version bump) to release" | |
| required: true | |
| type: string | |
| prev_release: | |
| description: "Release-notes anchor: a tag or SHA (empty → the previous tag)" | |
| type: string | |
| required: false | |
| dry_run: | |
| description: "Dry run: build without tagging or publishing" | |
| type: boolean | |
| default: false | |
| jobs: | |
| # FACT-FIND — derive version/tag/notes, check the registry, and emit the package manifest. | |
| # contents: write is for the releases/generate-notes API. | |
| configure: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.configure.outputs.version }} | |
| release_tag: ${{ steps.configure.outputs.release_tag }} | |
| prev_release: ${{ steps.configure.outputs.prev_release }} | |
| branch: ${{ steps.configure.outputs.branch }} | |
| on_release_branch: ${{ steps.configure.outputs.on_release_branch }} | |
| commit_message: ${{ steps.configure.outputs.commit_message }} | |
| github_release: ${{ steps.configure.outputs.github_release }} | |
| already_published: ${{ steps.configure.outputs.already_published }} | |
| notes: ${{ steps.configure.outputs.notes }} | |
| package: ${{ steps.configure.outputs.package }} | |
| steps: | |
| - name: Configure release | |
| id: configure | |
| uses: braintrustdata/sdk-actions/actions/release/lang/py/configure@71731d4a726df3e3bf42e50c2da4a75842b038dd | |
| with: | |
| version_file: py/src/braintrust/version.py | |
| sha: ${{ inputs.sha }} | |
| working_directory: py | |
| tag_format: py-sdk-v{version} | |
| release_type: ${{ inputs.release_type }} | |
| pypi_package_name: braintrust | |
| package_label: braintrust | |
| emoji: ':python:' | |
| prev_release: ${{ inputs.prev_release }} | |
| validate: | |
| needs: [configure] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| env: | |
| BRAINTRUST_RELEASE_CHANNEL: ${{ inputs.release_type }} | |
| steps: | |
| - name: Validate release | |
| uses: braintrustdata/sdk-actions/actions/release/lang/py/validate@71731d4a726df3e3bf42e50c2da4a75842b038dd | |
| with: | |
| sha: ${{ inputs.sha }} | |
| dry_run: ${{ inputs.dry_run }} | |
| working_directory: py | |
| python_version: .tool-versions | |
| release_tag: ${{ needs.configure.outputs.release_tag }} | |
| on_release_branch: ${{ needs.configure.outputs.on_release_branch }} | |
| enforce_release_branch: ${{ inputs.release_type == 'stable' }} | |
| notes: ${{ needs.configure.outputs.notes }} | |
| already_published: ${{ needs.configure.outputs.already_published }} | |
| build_command: make install-dev verify-build | |
| request-approval: | |
| needs: [configure, validate] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| permissions: {} | |
| steps: | |
| - name: Request release approval | |
| uses: braintrustdata/sdk-actions/actions/release/request-approval@71731d4a726df3e3bf42e50c2da4a75842b038dd | |
| with: | |
| packages: '{"packages":[${{ needs.configure.outputs.package }}]}' | |
| sha: ${{ inputs.sha }} | |
| branch: ${{ needs.configure.outputs.branch }} | |
| on_release_branch: ${{ needs.configure.outputs.on_release_branch }} | |
| commit_message: ${{ needs.configure.outputs.commit_message }} | |
| dry_run: ${{ inputs.dry_run }} | |
| slack_token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| slack_channel: ${{ vars.SLACK_SDK_RELEASE_CHANNEL }} | |
| slack_mention: '@sdk-eng' | |
| build-and-ship: | |
| needs: [configure, validate, request-approval] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| environment: ${{ inputs.dry_run && 'publish-dry-run' || 'publish' }} | |
| permissions: | |
| contents: write | |
| id-token: write # OIDC trusted publishing + PEP 740 attestations | |
| attestations: write # signed SBOM attestation | |
| env: | |
| BRAINTRUST_RELEASE_CHANNEL: ${{ inputs.release_type }} | |
| steps: | |
| - name: Build and ship | |
| uses: braintrustdata/sdk-actions/actions/release/lang/py/build-and-ship@71731d4a726df3e3bf42e50c2da4a75842b038dd | |
| with: | |
| sha: ${{ inputs.sha }} | |
| working_directory: py | |
| python_version: .tool-versions | |
| build_command: make install-dev verify-build | |
| dry_run: ${{ inputs.dry_run }} | |
| release_tag: ${{ needs.configure.outputs.release_tag }} | |
| already_published: ${{ needs.configure.outputs.already_published }} | |
| github_release: ${{ needs.configure.outputs.github_release }} | |
| version: ${{ needs.configure.outputs.version }} | |
| package_name: braintrust | |
| label: braintrust | |
| notes: ${{ needs.configure.outputs.notes }} | |
| prev_release: ${{ needs.configure.outputs.prev_release }} | |
| branch: ${{ needs.configure.outputs.branch }} | |
| on_release_branch: ${{ needs.configure.outputs.on_release_branch }} | |
| slack_token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| slack_channel: ${{ vars.SLACK_SDK_RELEASE_CHANNEL }} | |
| emoji: ':python:' |