Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 69 additions & 50 deletions .github/workflows/publish-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ on:
- "packages/sdk/**"
- "packages/bare-sdk/**"
- "packages/sdk-python/**"
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited
- labeled
branches:
- release-*
- feature-*
- tmp-*
- main
paths:
- "packages/inference/**"
- "packages/sdk/**"
- "packages/bare-sdk/**"
- "packages/sdk-python/**"

workflow_dispatch:
inputs:
Expand Down Expand Up @@ -90,6 +73,7 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false
fetch-depth: 0
- uses: ./.github/actions/release-merge-guard
with:
Expand Down Expand Up @@ -119,29 +103,19 @@ jobs:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
repository: ${{ github.event.pull_request.base.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.base.sha || github.sha }}
repository: ${{ github.repository }}
ref: ${{ github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
fetch-depth: 0

- name: Fetch PR head commits
if: github.event_name == 'pull_request_target'
run: |
git fetch origin ${{ github.event.pull_request.head.sha }}

- name: Verify inference / sdk / bare-sdk / python version lockstep
shell: bash
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# pull_request_target pins the working tree to base.sha; read manifests
# from the PR head SHA so a missed sdk / bare-sdk / python bump fails
# pre-merge (pr-checks-sdk-python.yml may not run on an engine-only bump).
#
# @qvac/inference is the sole version anchor: sdk, bare-sdk and
# sdk-python must all match it. Run /qv-sdk-lockstep-sync to align.
set -euo pipefail
REF="${PR_HEAD_SHA:-${GITHUB_SHA}}"
REF="${GITHUB_SHA}"
INF_VER=$(git show "${REF}":packages/inference/package.json | jq -r .version)
SDK_VER=$(git show "${REF}":packages/sdk/package.json | jq -r .version)
BARE_VER=$(git show "${REF}":packages/bare-sdk/package.json | jq -r .version)
Expand Down Expand Up @@ -206,6 +180,16 @@ jobs:
run: bun install
working-directory: ${{ env.WORKDIR }}

# Compile the SDK against the in-repo @qvac/inference at this commit, not
# the previously-published npm release (which lags behind engine API the
# SDK already consumes). This only affects the dist built here; the
# published dependency is set per channel below β€” GPR is pinned to the
# co-published @tetherto/inference-mono (see publish-gpr), npm keeps its
# committed range (resolved to the inference released in the same run).
- name: Build against workspace @qvac/inference
run: bun run sdk-source:workspace
working-directory: ${{ env.WORKDIR }}

- name: Modify package name for branch-based builds
working-directory: ${{ env.WORKDIR }}
run: |
Expand Down Expand Up @@ -316,9 +300,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
repository: ${{ github.event.pull_request.base.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.base.sha || github.sha }}
repository: ${{ github.repository }}
ref: ${{ github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # 2.2.0
Expand Down Expand Up @@ -360,9 +345,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
repository: ${{ github.event.pull_request.base.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.base.sha || github.sha }}
repository: ${{ github.repository }}
ref: ${{ github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # 2.2.0
Expand Down Expand Up @@ -419,21 +405,13 @@ jobs:
run:
working-directory: packages/sdk-python
steps:
# pull_request_target: keep working tree on base.sha (do not execute PR head
# under this job's secrets). Contract/build smoke the base tree; PR contract
# coverage is pr-checks-sdk-python.yml. Lockstep reads head.sha like `build`.
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
repository: ${{ github.event.pull_request.base.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.base.sha || github.sha }}
repository: ${{ github.repository }}
ref: ${{ github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch PR head commits
if: github.event_name == 'pull_request_target'
working-directory: ${{ github.workspace }}
run: |
git fetch origin ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
Expand All @@ -454,13 +432,11 @@ jobs:

- name: Verify version lockstep with @qvac/inference
working-directory: ${{ github.workspace }}
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# @qvac/inference is the sole version anchor. This job can run
# standalone (publish_pypi_only), so check python against the anchor.
set -euo pipefail
REF="${PR_HEAD_SHA:-${GITHUB_SHA}}"
REF="${GITHUB_SHA}"
INF_VER=$(git show "${REF}":packages/inference/package.json | jq -r .version)
PY_VER=$(git show "${REF}":packages/sdk-python/src/tetherto/qvac_sdk/_generated/sdk_version.py | sed -n 's/^SDK_VERSION = "\(.*\)"/\1/p')
if [ -z "$PY_VER" ]; then
Expand Down Expand Up @@ -534,7 +510,7 @@ jobs:

publish-gpr:
name: Publish to GitHub Packages (GPR)
needs: [build, publish-logic]
needs: [build, publish-logic, publish-gpr-inference]
if: ${{ needs.publish-logic.outputs.publish_main == 'true' || needs.publish-logic.outputs.publish_feature == 'true' || needs.publish-logic.outputs.publish_tmp == 'true' }}
runs-on: ubuntu-latest
continue-on-error: true
Expand All @@ -544,6 +520,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download build artifacts
uses: ./.github/actions/download-release-artifact
Expand Down Expand Up @@ -590,6 +568,35 @@ jobs:
MODIFIED_NAME=$(node -p "require('./package.json').name")
echo "Package name: $ORIGINAL_NAME β†’ $MODIFIED_NAME"

# The dist was compiled against the in-repo engine, so the published mono
# build must depend on the inference published in THIS run, not the stale
# public @qvac/inference. GPR uses ${version}-tmp.runid-${run_id}, and
# run_id is shared across jobs, so this pin matches the co-published
# @tetherto/inference-mono exactly. An npm alias keeps the SDK's own
# `import '@qvac/inference'` resolving to that package.
# Fail closed: only pin when the inference GPR publish actually succeeded.
# publish-gpr-inference is continue-on-error and its action writes
# gpr_published_version even on a failed publish, so a non-empty check
# alone could pin to a version that was never published (install -> 404).
# If inference didn't publish, leave the committed range β€” installable,
# just not this run's engine.
- name: Pin @qvac/inference to the co-published inference-mono
if: needs.publish-gpr-inference.result == 'success'
working-directory: ${{ env.WORKDIR }}
env:
INFERENCE_MONO_VERSION: ${{ needs.publish-gpr-inference.outputs.published_version }}
run: |
set -euo pipefail
if [ -z "${INFERENCE_MONO_VERSION}" ]; then
echo "::warning::inference-mono version unavailable; leaving @qvac/inference unchanged"
exit 0
fi
SPEC="npm:@tetherto/inference-mono@${INFERENCE_MONO_VERSION}"
echo "Pinning @qvac/inference -> ${SPEC}"
jq --arg spec "$SPEC" '.dependencies["@qvac/inference"] = $spec' package.json > package.json.tmp
mv package.json.tmp package.json
node -p "'@qvac/inference -> ' + require('./package.json').dependencies['@qvac/inference']"

- name: Publish to GitHub Package Registry
id: publish
uses: ./.github/actions/publish-library-to-gpr
Expand All @@ -613,6 +620,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download bare-sdk dist artifact
uses: ./.github/actions/download-release-artifact
Expand Down Expand Up @@ -664,6 +673,8 @@ jobs:
if: ${{ needs.publish-logic.outputs.publish_main == 'true' || needs.publish-logic.outputs.publish_feature == 'true' || needs.publish-logic.outputs.publish_tmp == 'true' }}
runs-on: ubuntu-latest
continue-on-error: true
outputs:
published_version: ${{ steps.publish.outputs.gpr_published_version }}
permissions:
contents: read
packages: write
Expand All @@ -674,6 +685,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download inference dist artifact
uses: ./.github/actions/download-release-artifact
Expand Down Expand Up @@ -751,6 +764,8 @@ jobs:

- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download build artifacts
uses: ./.github/actions/download-release-artifact
Expand Down Expand Up @@ -814,6 +829,8 @@ jobs:

- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download bare-sdk dist artifact
uses: ./.github/actions/download-release-artifact
Expand Down Expand Up @@ -871,6 +888,8 @@ jobs:

- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Download inference dist artifact
uses: ./.github/actions/download-release-artifact
Expand Down
Loading