Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
fix(ci): depend on the SDK via workspace:^ so releases tag the version bump (#1619)
Mish Ushakov05b7a792ffc2
diff --git a/.changeset/quiet-pugs-listen.md b/.changeset/quiet-pugs-listen.mdnew file mode 100644index 000000000..57bb96ba2--- /dev/null+++ b/.changeset/quiet-pugs-listen.md@@ -0,0 +1,5 @@+---+'@e2b/cli': patch+---++Depend on `e2b` through pnpm's `workspace:^` protocol instead of a registry range. `pnpm publish` rewrites it to the same concrete `^<version>` it had before, so the published package is unchanged — but the lockfile no longer has to be re-resolved against the tarballs a release uploads, which is what forced the release tags onto the commit before their own version bump.diff --git a/.github/actions/build-cli/action.yml b/.github/actions/build-cli/action.ymlindex 35f6eccdb..0bfa71d20 100644--- a/.github/actions/build-cli/action.yml+++ b/.github/actions/build-cli/action.yml@@ -35,7 +35,10 @@ runs:run: pnpm buildworking-directory: ./packages/cli+ # `pnpm link`, not `npm install -g`: npm cannot resolve the `workspace:^` range+ # the CLI declares for `e2b`. It only gets away with it today because npm+ # symlinks a local directory without resolving its dependencies at all.- name: Install the CLI globallyshell: bash- run: npm install -g .+ run: pnpm link --globalworking-directory: ./packages/clidiff --git a/.github/workflows/pkg_artifacts.yml b/.github/workflows/pkg_artifacts.ymlindex bd20116ed..c59b4dfb6 100644--- a/.github/workflows/pkg_artifacts.yml+++ b/.github/workflows/pkg_artifacts.yml@@ -52,27 +52,18 @@ jobs:working-directory: packages/js-sdkrun: pnpm run build- - name: Pack JS SDK- working-directory: packages/js-sdk- run: |- npm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version- npm pack-- - name: Upload JS SDK artifact- uses: actions/upload-artifact@v4- with:- name: e2b-js-sdk- path: packages/js-sdk/*.tgz-- name: Build CLIworking-directory: packages/clirun: pnpm run build+ # Before the SDK is renamed below: `pnpm pack` resolves the CLI's `workspace:^`+ # range to whatever version the workspace SDK has now, and a prerelease that+ # was never published would leave `e2b` unresolvable.- name: Pack CLIworking-directory: packages/clirun: |- npm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version- npm pack+ pnpm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version+ pnpm pack- name: Upload CLI artifactuses: actions/upload-artifact@v4@@ -80,6 +71,22 @@ jobs:name: e2b-clipath: packages/cli/*.tgz+ # Independent of the CLI steps above: a CLI failure should still leave+ # reviewers a usable SDK tarball, as it did before the CLI moved ahead of it.+ - name: Pack JS SDK+ if: ${{ !cancelled() }}+ working-directory: packages/js-sdk+ run: |+ pnpm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version+ pnpm pack++ - name: Upload JS SDK artifact+ if: ${{ !cancelled() }}+ uses: actions/upload-artifact@v4+ with:+ name: e2b-js-sdk+ path: packages/js-sdk/*.tgz+- name: Install uvuses: astral-sh/setup-uv@v6with:diff --git a/.github/workflows/publish_candidates.yml b/.github/workflows/publish_candidates.ymlindex bc6aaeea7..f3d3608d4 100644--- a/.github/workflows/publish_candidates.yml+++ b/.github/workflows/publish_candidates.yml@@ -96,13 +96,14 @@ jobs:RC_PREID: ${{ inputs.preid }}RC_TAG: ${{ inputs.tag }}run: |- npm version prerelease --preid="${RC_PREID}.${{ github.run_id }}" --no-git-tag-version- npm publish --tag "$RC_TAG" --provenance-- - name: Reinstall dependencies- if: ${{ inputs.js-sdk || inputs.cli }}- run: pnpm install --frozen-lockfile+ pnpm version prerelease --preid="${RC_PREID}.${{ github.run_id }}" --no-git-tag-version+ pnpm publish --tag "$RC_TAG" --provenance --no-git-checks+ # `pnpm publish`, not `npm publish`: it resolves the `workspace:^` range the+ # CLI declares for `e2b` to a concrete version — here the RC the step above+ # just published, or the last release when only the CLI is being cut.+ # `--no-git-checks` because candidates are cut from a feature branch with the+ # version bump above still uncommitted.- name: Publish CLI RCif: ${{ inputs.cli }}working-directory: packages/cli@@ -110,5 +111,5 @@ jobs:RC_PREID: ${{ inputs.preid }}RC_TAG: ${{ inputs.tag }}run: |- npm version prerelease --preid="${RC_PREID}.${{ github.run_id }}" --no-git-tag-version- npm publish --tag "$RC_TAG" --provenance+ pnpm version prerelease --preid="${RC_PREID}.${{ github.run_id }}" --no-git-tag-version+ pnpm publish --tag "$RC_TAG" --provenance --no-git-checksdiff --git a/.github/workflows/publish_packages.yml b/.github/workflows/publish_packages.ymlindex 4229291aa..84a3d0ff8 100644--- a/.github/workflows/publish_packages.yml+++ b/.github/workflows/publish_packages.yml@@ -71,7 +71,29 @@ jobs:env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ - name: Commit new versions+ # Commit before publishing, because `changeset publish` tags whatever HEAD+ # it publishes from — tagging afterwards is what left every tag on the+ # commit before its own version bump (SDK-298). Nothing in the tree+ # references the artifacts about to be uploaded, so the commit is already+ # complete. It stays local until something is actually published, so a+ # publish that uploads nothing leaves the branch untouched and the+ # changesets intact for a re-run.+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"++ # `add -A`, not `commit -a`: `changeset version` writes each package's+ # CHANGELOG.md as a new file the first time, which `-a` would drop.+ git add -A+ if git diff --cached --quiet; then+ echo "::error::'changeset version' produced no changes, so there is no version bump to publish or tag."+ exit 1+ fi+ git commit -m "[skip ci] Release new versions"+- name: Release new versions+ id: releaseuses: changesets/action@v1with:publish: pnpm run publish@@ -81,39 +103,25 @@ jobs:NPM_TOKEN: "" # See https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}- - name: Update lock file- # The npm registry is eventually consistent: versions published- # seconds earlier may not resolve yet, so retry with backoff.+ - name: Push new versions+ # Gate on the tags rather than on whether the publish step succeeded: they+ # are what has to end up reachable. `changeset publish` tags at HEAD and the+ # step above pushes them to origin, so if any exist — even from a publish+ # that then failed partway — the commit they point at has to land, or they+ # hang off no branch, which is the SDK-298 breakage this change prevents.+ if: always()run: |- for delay in 10 20 40 80 160; do- pnpm i --no-link --no-frozen-lockfile && exit 0- echo "Registry has not propagated the new versions yet, retrying in ${delay}s..."- sleep "$delay"- done- pnpm i --no-link --no-frozen-lockfile-- - name: Commit new versions- run: |- git config user.name "github-actions[bot]"- git config user.email "github-actions[bot]@users.noreply.github.com"- git commit -am "[skip ci] Release new versions" || exit 0-- # A PR merging mid-release makes this push a non-fast-forward. The- # artifacts were already published from the checked-out tree, so we- # only rebase the version bump over incoming changes that don't touch- # packages/. Otherwise the source would claim the published version- # contains code that isn't in the artifacts, so we fail loudly.- if git push; then+ if [ -z "$(git tag --points-at HEAD)" ]; then+ echo "Nothing was published; the version bump stays local and the changesets are intact for a re-dispatch."exit 0fi- git fetch origin "${GITHUB_REF_NAME}"- if git diff --name-only "HEAD~1" FETCH_HEAD -- packages/ | grep -q .; then- echo "::error::'${GITHUB_REF_NAME}' advanced with changes under packages/ during the release. Refusing to rebase the version bump onto unpublished package code (the source would diverge from the published artifacts). Reconcile manually."- exit 1+ if ! git push; then+ # A PR merged mid-release. Merge rather than rebase: the tags already+ # point at this commit and rewriting it would strand them off the branch.+ git fetch origin "${GITHUB_REF_NAME}"+ git merge --no-edit FETCH_HEAD+ git pushfi-- git pull --rebase origin "${GITHUB_REF_NAME}"- git pushenv:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex a10d19da6..071626518 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -81,7 +81,7 @@"cli-highlight": "^2.1.11","commander": "^11.1.0","console-table-printer": "^2.11.2",- "e2b": "^2.36.1",+ "e2b": "workspace:^","handlebars": "^4.7.9","inquirer": "^12.10.0","simple-update-notifier": "^2.0.0",diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.tsindex 01f8d84dd..d7ea50662 100644--- a/packages/cli/vitest.config.ts+++ b/packages/cli/vitest.config.ts@@ -13,6 +13,10 @@ export default defineConfig({resolve: {alias: {src: path.resolve(__dirname, './src'),+ // Mirror the `e2b` path in tsconfig.json, which is what tsc and the bundle+ // already resolve to. Without it `e2b` resolves to the workspace package's+ // `main`, which only exists once the SDK has been built.+ e2b: path.resolve(__dirname, '../js-sdk/src'),},},})diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2dbc3b7b3..e61d5ffc1 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -73,8 +73,8 @@ importers:specifier: ^2.11.2version: 2.11.2e2b:- specifier: ^2.36.1- version: 2.36.1+ specifier: workspace:^+ version: link:../js-sdkhandlebars:specifier: ^4.7.9version: 4.7.9@@ -2286,10 +2286,6 @@ packages:resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}engines: {node: '>= 0.4'}- resolution: {integrity: sha512-ERDTKfIM14mQX0cizRpfLCWDX4A83rGvbAbnUISDExM26WuMS4Jd9v2EWrY03LXfEKBst954SzFvKIZZEiKwng==}- engines: {node: '>=20.18.1 <21 || >=22'}-resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}@@ -5673,22 +5669,6 @@ snapshots:es-errors: 1.3.0gopd: 1.2.0- dependencies:- '@bufbuild/protobuf': 2.12.1- '@connectrpc/connect': 2.1.2(@bufbuild/[email protected])- '@connectrpc/connect-web': 2.1.2(@bufbuild/[email protected])(@connectrpc/[email protected](@bufbuild/[email protected]))- chalk: 5.3.0- compare-versions: 6.1.1- dockerfile-ast: 0.7.1- glob: 13.0.6- openapi-fetch: 0.14.1- platform: 1.3.6- tar: 7.5.21- undici: 7.28.0- optionalDependencies:- undici8: [email protected]-