The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Publish TrueForge from the TrueFoundry release branch (#882)
Raman Tehlanc9997b38d47f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 1a3471b47..d2298007a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,7 @@ jobs:packages: ${{ steps.packages.outputs.list }}chart: ${{ steps.filter.outputs.chart }}store: ${{ steps.filter.outputs.store }}+ release: ${{ steps.filter.outputs.release }}steps:- name: Check out repository code@@ -96,6 +97,11 @@ jobs:- 'Dockerfile'- 'package.json'- '.github/workflows/ci.yml'+ release:+ - 'scripts/resolve-chart-version.sh'+ - 'tests/scripts/**'+ - 'package.json'+ - '.github/workflows/ci.yml'- name: Build package matrixid: packages@@ -270,6 +276,30 @@ jobs:- name: Lint chartrun: pnpm chart:lint+ # Release-only scripts: not part of the shipped packages, so they stay off the+ # always-on path and run when the release wiring or its tests change.+ release-scripts:+ name: Release Scripts+ needs: detect-changes+ if: needs.detect-changes.outputs.release == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 10++ steps:+ - name: Check out repository code+ uses: actions/checkout@v7++ - name: Setup pnpm+ uses: pnpm/action-setup@v6++ - name: Setup Node.js+ uses: actions/setup-node@v7+ with:+ node-version: '24'++ - name: Chart version resolver+ run: pnpm test:chart-version+# Store contract suites when store paths change. Parallel with typecheck-and-build.store-tests:name: Store Tests@@ -326,6 +356,7 @@ jobs:- typecheck-and-build- package-checks- chart-checks+ - release-scripts- store-testsruns-on: ubuntu-latesttimeout-minutes: 5@@ -337,13 +368,15 @@ jobs:TYPECHECK_AND_BUILD: ${{ needs.typecheck-and-build.result }}PACKAGE_CHECKS: ${{ needs.package-checks.result }}CHART_CHECKS: ${{ needs.chart-checks.result }}+ RELEASE_SCRIPTS: ${{ needs.release-scripts.result }}STORE_TESTS: ${{ needs.store-tests.result }}run: |ok() { [ "$1" = success ] || [ "$1" = skipped ]; }- echo "detect-changes=$DETECT_CHANGES migration-order=$MIGRATION_ORDER typecheck-and-build=$TYPECHECK_AND_BUILD package-checks=$PACKAGE_CHECKS chart-checks=$CHART_CHECKS store-tests=$STORE_TESTS"+ echo "detect-changes=$DETECT_CHANGES migration-order=$MIGRATION_ORDER typecheck-and-build=$TYPECHECK_AND_BUILD package-checks=$PACKAGE_CHECKS chart-checks=$CHART_CHECKS release-scripts=$RELEASE_SCRIPTS store-tests=$STORE_TESTS"[ "$DETECT_CHANGES" = success ] || exit 1[ "$MIGRATION_ORDER" = success ] || exit 1[ "$TYPECHECK_AND_BUILD" = success ] || exit 1ok "$PACKAGE_CHECKS" || exit 1ok "$CHART_CHECKS" || exit 1+ ok "$RELEASE_SCRIPTS" || exit 1ok "$STORE_TESTS" || exit 1diff --git a/.github/workflows/release-chart.yml b/.github/workflows/release-chart.ymlindex e81bf4e0a..c7cda13fc 100644--- a/.github/workflows/release-chart.yml+++ b/.github/workflows/release-chart.yml@@ -3,6 +3,7 @@ name: Publish Helm chart# Publishes the Helm chart for an image that already exists in the registry.# Does not build images: release.yml builds {appVersion}-{shortSha} and then# calls this workflow with (branch, app_version, image_tag).+# branch is the release-vX.Y.Z branch release.yml is running on.## Steps: resolve the next chart version from Chart.yaml on origin/<branch>, write# appVersion / image.tag / version, lint, package, push OCI, commit those files@@ -224,3 +225,16 @@ jobs:doneecho "Could not fast-forward chart metadata onto $BRANCH" >&2exit 1++ - name: Record published chart version+ env:+ VERSION: ${{ steps.chart.outputs.version }}+ run: printf '%s\n' "$VERSION" > "$RUNNER_TEMP/chart-version.txt"++ - name: Upload chart version+ uses: actions/upload-artifact@v4+ with:+ name: trueforge-chart-version+ path: ${{ runner.temp }}/chart-version.txt+ retention-days: 5+ if-no-files-found: errordiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 39d6bc652..b9193d33e 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -3,20 +3,29 @@# npm and PyPI trusted publishers are bound to this filename (`release.yml`).# Do not rename it without updating every package on npmjs.com and PyPI.#-# On every push to main, changesets/action/select-mode chooses:-# - pending `.changeset/*.md` → version job opens/updates the Version Packages PR-# (install only; that PR is gated by CI.yml). When @truefoundry/trueforge-sdk-# moves, scripts/version.mjs mirrors that version into python/trueforge_sdk and rebakes Fern.+# Releases run on release-vX.Y.Z, not main. main only collects changesets.+#+# helm-charts dispatches this workflow with tfy_chart_version (X.Y.Z or+# X.Y.Z-rc.N) on ref release-vX.Y.Z. That run prepares pre mode and any+# 0.0.0 packages, runs changeset version, and auto-merges the Version+# Packages PR. changesets/action/version hard-resets to the triggering SHA+# before its script, which would drop that prep, so the dispatch job runs+# `pnpm run version` itself and opens the same PR.+#+# The merge push to release-v* uses changesets/action/select-mode:+# - pending `.changeset/*.md` → version job opens/updates the Version Packages PR.+# When @truefoundry/trueforge-sdk moves, scripts/version.mjs mirrors that+# version into python/trueforge_sdk and rebakes Fern.# - none pending + unpublished versions → pack (build/test) + Windows npx smoke# in parallel with the from-source image (image waits only on npm view of# @truefoundry/trueforge@version; skip image+chart if that version is already-# on npm). The release image is built on the hardened node bases from the-# TrueFoundry private registry. Local and contributor builds stay on-# node:24-slim.-# After the image is pushed, this workflow calls release-chart.yml with-# branch main, app_version, and image_tag. Helm does not wait on pack.-# Merge the Version Packages PR to publish. After Helm publish, release-chart.yml-# tags charts/trueforge@<chartVersion> on the metadata commit.+# on npm). The release builds two images with the same tag: a public image+# on node:24-slim, and a hardened image on the TrueFoundry private node+# bases. Local and contributor builds stay on node:24-slim.+# After both images are pushed, this workflow calls release-chart.yml+# with this branch, app_version, and image_tag. Helm does not wait on pack.+# After Helm publish, release-chart.yml tags charts/trueforge@<chartVersion>+# on the metadata commit and uploads the trueforge-chart-version artifact.## Auth is GitHub OIDC (no NPM_TOKEN / PYPI_TOKEN). An `_authToken` in user `.npmrc`# disables pnpm's OIDC exchange, so the npm publish job must not set NPM_TOKEN /@@ -26,8 +35,14 @@ name: Version or publish packageson:push:- branches: [main]+ branches:+ - 'release-v*'workflow_dispatch:+ inputs:+ tfy_chart_version:+ description: 'TrueFoundry chart version: X.Y.Z or X.Y.Z-rc.N'+ required: true+ type: stringconcurrency:group: ${{ github.workflow }}-${{ github.ref }}@@ -37,8 +52,96 @@ concurrency:permissions: {}jobs:+ # Dispatch-only. Push runs take the select-mode path below.+ version-release:+ name: Version packages for TrueFoundry release+ if: github.event_name == 'workflow_dispatch'+ runs-on: ubuntu-latest+ timeout-minutes: 30+ outputs:+ mode: ${{ steps.finish.outputs.mode }}+ publish-plan-artifact-id: ${{ steps.select-mode.outputs.publish-plan-artifact-id }}+ permissions:+ contents: write+ pull-requests: write+ steps:+ - id: app-token+ uses: actions/create-github-app-token@v3+ with:+ client-id: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_ID }}+ private-key: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_PRIVATE_KEY }}++ - name: Check out repo+ uses: actions/checkout@v7+ with:+ fetch-depth: 0+ persist-credentials: false+ token: ${{ steps.app-token.outputs.token }}++ - uses: pnpm/action-setup@v6++ - name: Set up Node.js+ uses: actions/setup-node@v7+ with:+ node-version: 24+ cache: pnpm++ - run: pnpm install --frozen-lockfile++ - name: Prepare release and version packages+ env:+ TFY_CHART_VERSION: ${{ inputs.tfy_chart_version }}+ RELEASE_BRANCH: ${{ github.ref_name }}+ FERN_TOKEN: ${{ secrets.FERN_TOKEN }}+ run: |+ node scripts/prepare-release.mjs+ pnpm run version++ - name: Open and auto-merge Version Packages PR+ id: finish+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ RELEASE_BRANCH: ${{ github.ref_name }}+ TFY_CHART_VERSION: ${{ inputs.tfy_chart_version }}+ HUSKY: '0'+ run: |+ set -euo pipefail+ if [ -z "$(git status --porcelain)" ]; then+ echo "mode=publish" >> "$GITHUB_OUTPUT"+ echo "Nothing to version; publishing this branch"+ exit 0+ fi+ gh auth setup-git+ git config user.name "github-actions[bot]"+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"+ VERSION_BRANCH="changeset-release/${RELEASE_BRANCH}"+ git checkout -B "$VERSION_BRANCH"+ git add -A+ git commit -m "Version Packages"+ git push --force origin "HEAD:${VERSION_BRANCH}"+ EXISTING="$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$VERSION_BRANCH" --base "$RELEASE_BRANCH" --state open --json number --jq '.[0].number // empty')"+ if [ -z "$EXISTING" ]; then+ gh pr create \+ --repo "$GITHUB_REPOSITORY" \+ --base "$RELEASE_BRANCH" \+ --head "$VERSION_BRANCH" \+ --title "Version Packages" \+ --body "Versions packages for TrueFoundry chart release ${TFY_CHART_VERSION} on ${RELEASE_BRANCH}. Auto-merge publishes npm, PyPI, the image, and the Helm chart from the merge push."+ EXISTING="$(gh pr view "$VERSION_BRANCH" --repo "$GITHUB_REPOSITORY" --json number --jq .number)"+ fi+ gh pr merge "$EXISTING" --repo "$GITHUB_REPOSITORY" --merge --auto+ echo "mode=version" >> "$GITHUB_OUTPUT"++ # Same-run publish: pack/publish need a publish plan, and the push-path+ # select-mode job never runs on a dispatch.+ - name: Select Changesets mode+ id: select-mode+ if: steps.finish.outputs.mode == 'publish'+ uses: changesets/action/select-mode@v2+select-mode:name: Select mode+ if: github.event_name == 'push'runs-on: ubuntu-latesttimeout-minutes: 10outputs:@@ -106,10 +209,12 @@ jobs:script: pnpm run versionpush-with-git-cli: true+ # Exactly one of select-mode / version-release runs; the other is skipped and+ # reports an empty mode. `!cancelled()` is what stops that skip from cascading.pack:name: Pack packages- if: needs.select-mode.outputs.mode == 'publish'- needs: select-mode+ if: ${{ !cancelled() && (needs.select-mode.outputs.mode == 'publish' || needs.version-release.outputs.mode == 'publish') }}+ needs: [select-mode, version-release]runs-on: ubuntu-latesttimeout-minutes: 30outputs:@@ -145,12 +250,12 @@ jobs:id: packuses: changesets/action/pack@v2with:- publish-plan-artifact-id: ${{ needs.select-mode.outputs.publish-plan-artifact-id }}+ publish-plan-artifact-id: ${{ needs.select-mode.outputs.publish-plan-artifact-id || needs.version-release.outputs.publish-plan-artifact-id }}windows-npx-smoke:name: Windows npx smoke- if: needs.select-mode.outputs.mode == 'publish'- needs: select-mode+ if: ${{ !cancelled() && (needs.select-mode.outputs.mode == 'publish' || needs.version-release.outputs.mode == 'publish') }}+ needs: [select-mode, version-release]runs-on: windows-latesttimeout-minutes: 30permissions:@@ -275,8 +380,8 @@ jobs:resolve-image:name: Resolve image identity- if: needs.select-mode.outputs.mode == 'publish'- needs: select-mode+ if: ${{ !cancelled() && (needs.select-mode.outputs.mode == 'publish' || needs.version-release.outputs.mode == 'publish') }}+ needs: [select-mode, version-release]runs-on: ubuntu-latesttimeout-minutes: 10outputs:@@ -392,7 +497,48 @@ jobs:permissions:contents: writewith:- branch: main+ branch: ${{ github.ref_name }}app_version: ${{ needs.resolve-image.outputs.app_version }}image_tag: ${{ needs.resolve-image.outputs.image_tag }}secrets: inherit++ # release-chart.yml uploads trueforge-chart-version when it publishes.+ # When the package is already on npm, image and chart are skipped and the+ # chart version already on this commit is the one helm-charts should pin.+ record-chart-version:+ name: Record existing chart version+ if: needs.resolve-image.outputs.skip == 'true'+ needs: [resolve-image]+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - name: Check out repo+ uses: actions/checkout@v7+ with:+ persist-credentials: false++ - name: Write chart version+ run: |+ set -euo pipefail+ VERSION="$(node -e '+ const fs = require("fs");+ const text = fs.readFileSync("charts/trueforge/Chart.yaml", "utf8");+ const match = text.match(/^version:\s*"?([^"\n]+)"?\s*$/m);+ if (match === null) {+ process.stderr.write("charts/trueforge/Chart.yaml is missing version\n");+ process.exit(1);+ }+ process.stdout.write(match[1].trim());+ ')"+ printf '%s\n' "$VERSION" > "$RUNNER_TEMP/chart-version.txt"+ echo "chart version $VERSION"++ - name: Upload chart version+ uses: actions/upload-artifact@v4+ with:+ name: trueforge-chart-version+ path: ${{ runner.temp }}/chart-version.txt+ retention-days: 5+ if-no-files-found: errordiff --git a/RELEASING.md b/RELEASING.mdindex 1e3ea4b35..c5758f65f 100644--- a/RELEASING.md+++ b/RELEASING.md@@ -3,14 +3,14 @@This repo ships npm packages, a production container image, a Helm chart, and asandbox image.-| What | Trigger | Workflow |-| ---------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------- |-| npm packages | Push to `main` (Changesets) | [`release.yml`](.github/workflows/release.yml) |-| PyPI `trueforge-sdk` | Same `mode=publish` run as npm (parallel OIDC job) | [`release.yml`](.github/workflows/release.yml) |-| Prod image | Same `mode=publish` run as npm (after pack + smoke) | [`release.yml`](.github/workflows/release.yml) |-| Helm chart | Called from `release.yml` after the image, or manual dispatch | [`release-chart.yml`](.github/workflows/release-chart.yml) |-| Sandbox image + pin PR | Push to `main` when `scripts/sandbox/**` changes, or dispatch | [`push-sandbox-image.yml`](.github/workflows/push-sandbox-image.yml) |-| PR checks | Pull request / merge group | [`ci.yml`](.github/workflows/ci.yml) |+| What | Trigger | Workflow |+| ---------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------- |+| npm packages | Push to `release-vX.Y.Z` (Changesets). `main` collects changesets only | [`release.yml`](.github/workflows/release.yml) |+| PyPI `trueforge-sdk` | Same `mode=publish` run as npm (parallel OIDC job) | [`release.yml`](.github/workflows/release.yml) |+| Prod image | Same `mode=publish` run as npm (after pack + smoke) | [`release.yml`](.github/workflows/release.yml) |+| Helm chart | Called from `release.yml` after the image, or manual dispatch | [`release-chart.yml`](.github/workflows/release-chart.yml) |+| Sandbox image + pin PR | Push to `main` when `scripts/sandbox/**` changes, or dispatch | [`push-sandbox-image.yml`](.github/workflows/push-sandbox-image.yml) |+| PR checks | Pull request / merge group | [`ci.yml`](.github/workflows/ci.yml) |## Versioning@@ -47,26 +47,35 @@ helm install trueforge oci://tfy.jfrog.io/tfy-helm/trueforge --version <chart-se## FlowNo extra GitHub tag on the Version Packages path. [`release.yml`](.github/workflows/release.yml)-is packages plus the from-source image (`select-mode` → `version` \| `pack` in-parallel with image after `npm view`, then Helm):+is packages plus the from-source image. It runs on `release-vX.Y.Z`. `main` collects+changesets and does not publish.1. Add a changeset in the same PR as the code change (`pnpm changeset`, or`pnpm change --bump patch --summary "…" <pkg>`). SDK regen already adds`@truefoundry/trueforge-sdk` via `pnpm changeset:sdk-regen`.-2. Merge to `main`. Pending changesets → **Version Packages** PR- (`pnpm run version`). When `@truefoundry/trueforge-sdk` moves,- `scripts/version.mjs` mirrors that version into `python/trueforge_sdk` and- regenerates both SDKs. Review and merge.-3. With no pending changesets, **pack** (build/test) and **Windows npx smoke**- run in parallel with **Resolve image identity** (`npm view` of- `@truefoundry/trueforge@version`). If that version is already on npm, image+2. Merge to `main`.+3. A TrueFoundry chart release of `V` (`X.Y.Z` or `X.Y.Z-rc.N`) creates+ `release-vX.Y.Z` in this repo (`X.Y.Z` is `V` with any `-rc.N` removed) and+ dispatches this workflow with `tfy_chart_version=V`. The first cut is from+ `main`. An existing branch is kept, and `main` is merged into it.+4. That dispatch runs `scripts/prepare-release.mjs`, then `pnpm run version`.+ Pre mode follows `V` (`rc` enters, a stable version exits). Published+ packages still at `0.0.0` become `X.Y.0` or `X.Y.0-rc.0`. `packages/frontend`+ stays `0.0.0`. The Version Packages PR targets `release-vX.Y.Z` and is+ auto-merged. When `@truefoundry/trueforge-sdk` moves, `scripts/version.mjs`+ mirrors that version into `python/trueforge_sdk` and regenerates both SDKs.+5. The merge push, with no pending changesets, runs **pack** (build/test) and+ **Windows npx smoke** in parallel with **Resolve image identity** (`npm view`+ of `@truefoundry/trueforge@version`). If that version is already on npm, imageand Helm skip. If not, **Build and push server image** runs without waitingon pack. After the image is pushed, this workflow calls- [`release-chart.yml`](.github/workflows/release-chart.yml) with `branch=main`,- `app_version`, and `image_tag`. Helm does not wait on pack or npm.-4. Pin dependents to exact versions during early `0.x`.+ [`release-chart.yml`](.github/workflows/release-chart.yml) with+ `branch=release-vX.Y.Z`, `app_version`, and `image_tag`. Helm does not wait+ on pack or npm. Chart commits land on the release branch.-`workflow_dispatch` on **Version or publish packages** re-runs the same workflow.+If the dispatch has nothing to version, that same run publishes. A later push to+`release-v*` with pending changesets opens a Version Packages PR and does not+auto-merge it.## Prerelease mode@@ -117,7 +126,7 @@ pnpm clean && pnpm build && pnpm standalone:start## Troubleshooting-- **No Version Packages PR** - no `.changeset/*.md` on `main`. Add one, or re-run **Version or publish packages**.+- **No Version Packages PR** - no `.changeset/*.md` on the release branch. Add one on `main` before the TrueFoundry release cuts or updates `release-vX.Y.Z`.- **Publish wants a tag** - RCs need the `rc` dist-tag (set automatically while `pre.json` exists).- **403** - version already on npm, or trusted-publisher config mismatch (filename must be `release.yml`).- **OIDC fail** - pnpm >= 11.0.7; remove registry `_authToken`.@@ -126,27 +135,32 @@ pnpm clean && pnpm build && pnpm standalone:start(`scripts/version.mjs`; needs Docker). That path also mirrors the version into `python/trueforge_sdk`.- **PyPI 403 / invalid-publisher** - register a trusted publisher for `trueforge-sdk` bound to`release.yml` (and create the project if it does not exist yet).-- **Prod image / chart missing after package publish** - re-run **Version or publish packages**,- or publish a chart for an image already in the registry:- `gh workflow run release-chart.yml --ref main -f branch=main -f app_version=X.Y.Z -f image_tag=X.Y.Z-<sha>`.+- **Prod image / chart missing after package publish** - re-run **Version or publish packages**+ on the release branch, or publish a chart for an image already in the registry:+ `gh workflow run release-chart.yml --ref release-vX.Y.Z -f branch=release-vX.Y.Z -f app_version=X.Y.Z -f image_tag=X.Y.Z-<sha>`.---# Image and Helm chart```text-push to main (no pending changesets, unpublished versions)+TrueFoundry chart release V+ → branch release-vX.Y.Z (from main the first time; fail if an existing branch is missing commits from main)+ → workflow_dispatch release.yml --ref release-vX.Y.Z -f tfy_chart_version=V+ → prepare pre mode + 0.0.0 bootstrap+ → changeset version, auto-merge Version Packages PR+merge push to release-vX.Y.Z (no pending changesets, unpublished versions)→ release.yml: pack + smoke | npm view @truefoundry/trueforge@version→ npm | PyPI→ if version not on npm: build image X.Y.Z-<shortSha>- → after image: call release-chart.yml (main, app_version, image_tag)+ → after image: call release-chart.yml (release-vX.Y.Z, app_version, image_tag)→ release-chart.yml→ helm lint/package/push OCI→ commit Chart.yaml + values.yaml to that branch→ tag charts/trueforge@<chartVersion> on that commitmanual chart-only (image already in the registry)- → workflow_dispatch release-chart.yml --ref main -f branch=main+ → workflow_dispatch release-chart.yml --ref <release-branch> -f branch=<release-branch>(empty app_version / image_tag keep Chart.yaml / values.yaml)```@@ -166,7 +180,8 @@ peeled commit SHA (`git rev-parse HEAD`), not an annotated-tag object.[`release.yml`](.github/workflows/release.yml) builds/pushes `{appVersion}-{shortSha}`from the root [`Dockerfile`](Dockerfile), then calls[`release-chart.yml`](.github/workflows/release-chart.yml) (`workflow_call`) with-`branch=main`, `app_version`, and `image_tag`. The chart workflow does not build images.+`branch` set to the `release-vX.Y.Z` branch the workflow is running on,+`app_version`, and `image_tag`. The chart workflow does not build images.`--ref` selects which workflow file GitHub runs. `branch` is the git branch thatreceives `Chart.yaml` / `values.yaml`.diff --git a/charts/trueforge/README.md b/charts/trueforge/README.mdindex 5c8bcc17c..218d9c7f4 100644--- a/charts/trueforge/README.md+++ b/charts/trueforge/README.md@@ -366,7 +366,8 @@ extraObjects:| `server.replicaCount` | `""` | Number of server replicas. Empty derives from the resource tier (small=1, medium=2, large=3; 1 with no tier). || `server.deploymentAnnotations` | `{}` | Annotations on the server Deployment, such as an Argo CD sync wave. || `controller.deploymentAnnotations` | `{}` | Annotations on the controller Deployment, such as an Argo CD sync wave. |-| `image.repository` | `tfy.jfrog.io/tfy-images/trueforge` | Image repository. |+| `image.registry` | `""` | Image registry. Empty uses `global.image.registry`, then `tfy.jfrog.io`. |+| `image.repository` | `tfy-images/trueforge` | Image repository without the registry. || `image.tag` | chart `appVersion` | Image tag; stamped on release. || `server.publicBaseUrl`| `""` | Public application URL for OAuth/OIDC callbacks (required for MCP OAuth / OIDC). A pathname is the UI/API public prefix. || `configs.oidc.enabled`| `false` | Inject `OIDC_*` env for IdP login. |diff --git a/charts/trueforge/templates/_helpers.tpl b/charts/trueforge/templates/_helpers.tplindex 060026b7c..2e6665a31 100644--- a/charts/trueforge/templates/_helpers.tpl+++ b/charts/trueforge/templates/_helpers.tpl@@ -143,7 +143,10 @@ Service account name.Container image reference; tag falls back to the chart appVersion.*/}}{{- define "trueforge.image" -}}-{{- printf "%s:%s" .Values.image.repository (.Values.image.tag | default .Chart.AppVersion) }}+{{- $globalImage := .Values.global.image | default dict -}}+{{- $registry := .Values.image.registry | default ($globalImage.registry | default "tfy.jfrog.io") -}}+{{- $tag := .Values.image.tag | default .Chart.AppVersion -}}+{{- printf "%s/%s:%s" $registry .Values.image.repository $tag -}}{{- end }}{{/*@@ -665,10 +668,13 @@ Scheduling and pull secrets. A parent chart's global.* is the base; the chart'sown value wins. Tolerations append rather than replace.*/}}{{- define "trueforge.imagePullSecrets" -}}-{{- $secrets := .Values.imagePullSecrets | default (.Values.global.imagePullSecrets | default list) -}}-{{- with $secrets }}-{{- toYaml . }}-{{- end }}+{{- if .Values.imagePullSecrets -}}+{{- toYaml .Values.imagePullSecrets -}}+{{- else if .Values.global.imagePullSecrets -}}+{{- toYaml .Values.global.imagePullSecrets -}}+{{- else if .Values.global.truefoundryImagePullConfigJSON -}}+- name: truefoundry-image-pull-secret+{{- end -}}{{- end }}{{- define "trueforge.nodeSelector" -}}diff --git a/charts/trueforge/values.yaml b/charts/trueforge/values.yamlindex 560dd8577..8a3f1294c 100644--- a/charts/trueforge/values.yaml+++ b/charts/trueforge/values.yaml@@ -37,15 +37,20 @@ global:sslCerts:sizeLimit: 10Miimage:- repository: tfy.jfrog.io/tfy-images/trueforge+ # Empty uses global.image.registry, then tfy.jfrog.io.+ registry: ""+ repository: tfy-images/trueforge# Tag defaults to chart appVersion when empty. release-chart.yml sets this# to {appVersion}-{shortSha} for the from-source image already in the# registry.tag: "0.3.0-ebbf6c0"pullPolicy: IfNotPresentimagePullSecrets: []-# Default tfy.jfrog.io repos are anonymously pullable. Set secrets only when-# overriding image.repository / subchart registries to a private registry.+# Default tfy.jfrog.io repos are anonymously pullable. A parent chart's+# global.imagePullSecrets wins when this list is empty. If that is also empty+# and global.truefoundryImagePullConfigJSON is set, pods use the+# truefoundry-image-pull-secret that chart creates. Set this list when the+# pull secret has another name.nameOverride: ""fullnameOverride: ""serviceAccount:diff --git a/scripts/prepare-release.mjs b/scripts/prepare-release.mjsnew file mode 100644index 000000000..6e72f00c3--- /dev/null+++ b/scripts/prepare-release.mjs@@ -0,0 +1,186 @@+/**+ * Prep a TrueForge release branch for one TrueFoundry chart version.+ *+ * `TFY_CHART_VERSION` is `X.Y.Z` or `X.Y.Z-rc.N`.+ * `RELEASE_BRANCH` is `release-vX.Y.Z`.+ *+ * Changesets pre mode follows that version. Published packages still at+ * `0.0.0` move to `X.Y.0` or `X.Y.0-rc.0`; private packages (`packages/frontend`)+ * stay `0.0.0`. Bootstrapping `packages/trueforge-sdk` also writes+ * `python/trueforge_sdk/pyproject.toml`: `scripts/version.mjs` only mirrors the+ * Python version when `changeset version` moves the TS SDK, so a bootstrap alone+ * would leave Poetry behind.+ * `.changeset/config.json` `baseBranch` becomes the release branch so version+ * changelogs are computed against it. `main` is not rewritten here.+ */+import { spawn } from 'node:child_process';+import { readFile, readdir, unlink, writeFile } from 'node:fs/promises';+import path from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';++const rootDirDefault = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const chartVersionPattern = /^(\d+)\.(\d+)\.\d+(?:-rc\.\d+)?$/;+const releaseBranchPattern = /^release-v\d+\.\d+\.\d+$/;++export function parseChartVersion(chartVersion) {+ const match = typeof chartVersion === 'string' ? chartVersionPattern.exec(chartVersion) : null;+ if (match === null) {+ throw new Error(`TFY_CHART_VERSION must be X.Y.Z or X.Y.Z-rc.N, got ${JSON.stringify(chartVersion)}`);+ }+ return {+ major: match[1],+ minor: match[2],+ prerelease: chartVersion.includes('-rc.'),+ };+}++export function bootstrapPackageVersion(chartVersion) {+ const parsed = parseChartVersion(chartVersion);+ const core = `${parsed.major}.${parsed.minor}.0`;+ return parsed.prerelease ? `${core}-rc.0` : core;+}++export function preModeCommand(chartVersion, preState) {+ const prerelease = parseChartVersion(chartVersion).prerelease;+ const inPre = preState !== null && preState.mode === 'pre';+ if (prerelease && !inPre) {+ return 'enter';+ }+ if (!prerelease && inPre) {+ return 'exit';+ }+ return 'keep';+}++function defaultRun(command, args, cwd) {+ return new Promise((resolve, reject) => {+ const child = spawn(command, args, { cwd, stdio: 'inherit', env: process.env });+ child.on('error', error => {+ reject(new Error(`Failed to spawn ${command} ${args.join(' ')}`, { cause: error }));+ });+ child.on('close', code => {+ if (code === 0) {+ resolve();+ return;+ }+ reject(new Error(`${command} ${args.join(' ')} exited with code ${String(code)}`));+ });+ });+}++async function readJson(filePath) {+ let raw;+ try {+ raw = await readFile(filePath, 'utf8');+ } catch (error) {+ if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {+ return null;+ }+ throw error;+ }+ return JSON.parse(raw);+}++async function setBaseBranch(rootDir, branch) {+ const configPath = path.join(rootDir, '.changeset', 'config.json');+ const raw = await readFile(configPath, 'utf8');+ if (!raw.includes('"baseBranch"')) {+ throw new Error('.changeset/config.json is missing baseBranch');+ }+ const next = raw.replace(/"baseBranch"\s*:\s*"[^"]+"/, `"baseBranch": "${branch}"`);+ if (next === raw && !raw.includes(`"baseBranch": "${branch}"`)) {+ throw new Error('failed to set changesets baseBranch');+ }+ if (next !== raw) {+ await writeFile(configPath, next);+ }+}++async function readPreState(rootDir) {+ const prePath = path.join(rootDir, '.changeset', 'pre.json');+ const parsed = await readJson(prePath);+ if (parsed === null) {+ return null;+ }+ if (typeof parsed !== 'object' || parsed === null || typeof parsed.mode !== 'string') {+ throw new Error('.changeset/pre.json must be an object with mode');+ }+ return parsed;+}++async function applyPreMode(rootDir, chartVersion, run) {+ const prePath = path.join(rootDir, '.changeset', 'pre.json');+ const preState = await readPreState(rootDir);+ const command = preModeCommand(chartVersion, preState);+ if (command === 'keep') {+ return command;+ }+ if (command === 'enter' && preState !== null) {+ await unlink(prePath);+ }+ const args = command === 'enter' ? ['changeset', 'pre', 'enter', 'rc'] : ['changeset', 'pre', 'exit'];+ await run('pnpm', args, rootDir);+ return command;+}++async function bootstrapZeroVersions(rootDir, chartVersion) {+ const target = bootstrapPackageVersion(chartVersion);+ const packagesDir = path.join(rootDir, 'packages');+ const entries = await readdir(packagesDir, { withFileTypes: true });+ const changed = [];+ for (const entry of entries) {+ if (!entry.isDirectory()) {+ continue;+ }+ const packagePath = path.join(packagesDir, entry.name, 'package.json');+ let raw;+ try {+ raw = await readFile(packagePath, 'utf8');+ } catch (error) {+ if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {+ continue;+ }+ throw error;+ }+ const parsed = JSON.parse(raw);+ if (parsed.private === true || parsed.version !== '0.0.0') {+ continue;+ }+ // Patch the one field instead of re-stringifying: these files are committed+ // on the release branch, and JSON.stringify would reflow the whole manifest.+ const next = raw.replace(/("version"\s*:\s*")0\.0\.0(")/, `$1${target}$2`);+ if (next === raw) {+ throw new Error(`${packagePath} is 0.0.0 but the version field could not be replaced`);+ }+ await writeFile(packagePath, next);+ changed.push(entry.name);+ }+ return changed;+}++export async function prepareRelease({ rootDir = rootDirDefault, chartVersion, branch, run = defaultRun }) {+ if (typeof branch !== 'string' || !releaseBranchPattern.test(branch)) {+ throw new Error(`RELEASE_BRANCH must be release-vX.Y.Z, got ${JSON.stringify(branch)}`);+ }+ parseChartVersion(chartVersion);+ await setBaseBranch(rootDir, branch);+ const pre = await applyPreMode(rootDir, chartVersion, run);+ const bootstrapped = await bootstrapZeroVersions(rootDir, chartVersion);+ console.log(`prepared ${branch} for ${chartVersion} (pre=${pre}, bootstrapped=${bootstrapped.join(',') || 'none'})`);+ return { pre, bootstrapped };+}++async function main() {+ await prepareRelease({+ chartVersion: process.env.TFY_CHART_VERSION,+ branch: process.env.RELEASE_BRANCH,+ });+}++// Run the release prep only when invoked as a script; tests import the exports.+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {+ main().catch(error => {+ console.error(error);+ process.exitCode = 1;+ });+}