Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 7 additions & 14 deletions .github/workflows/publish-sim-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:

concurrency:
group: publish-sim-cli-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false

jobs:
publish-npm:
Expand Down Expand Up @@ -50,6 +50,9 @@ jobs:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bun pm whoami

- name: Auto-bump package version
run: bun run bump:npm-packages sim-cli

- name: Run tests
working-directory: packages/sim-cli
run: bun run test
Expand Down Expand Up @@ -115,35 +118,25 @@ jobs:
tar -xzf "$PACKAGE_PATH" -C "$SMOKE_DIR"
"$SMOKE_DIR/package/dist/index.js" --version

- name: Check if version already exists
id: version_check
- name: Verify version is unpublished
working-directory: packages/sim-cli
env:
VERSION: ${{ steps.release.outputs.version }}
run: |
if bun pm view "sim@$VERSION" version > /dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "sim@$VERSION is already published. The automatic version bump did not produce a unique release." >&2
exit 1
fi

- name: Publish to npm
if: steps.version_check.outputs.exists == 'false'
working-directory: packages/sim-cli
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: ${{ steps.release.outputs.tag }}
run: bun publish --access public --tag "$NPM_TAG" --no-save

- name: Summarize release
if: steps.version_check.outputs.exists == 'false'
env:
VERSION: ${{ steps.release.outputs.version }}
NPM_TAG: ${{ steps.release.outputs.tag }}
run: echo "Published sim@$VERSION with the '$NPM_TAG' tag."

- name: Summarize skipped release
if: steps.version_check.outputs.exists == 'true'
env:
VERSION: ${{ steps.release.outputs.version }}
run: echo "Skipped sim@$VERSION because that version is already published."
5 changes: 4 additions & 1 deletion .github/workflows/publish-sim-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bun pm whoami

- name: Auto-bump package version
run: bun run bump:npm-packages sim-setup

- name: Check generated deployment config
run: bun run deployment-config:check

Expand Down Expand Up @@ -156,7 +159,7 @@ jobs:
VERSION: ${{ steps.release.outputs.version }}
run: |
if bun pm view "sim-setup@$VERSION" version > /dev/null 2>&1; then
echo "sim-setup@$VERSION is already published. Bump packages/sim-setup/package.json before releasing another build." >&2
echo "sim-setup@$VERSION is already published. The automatic version bump did not produce a unique release." >&2
exit 1
fi

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"dev:sockets": "cd apps/realtime && bun run dev",
"dev:full": "bunx concurrently -n \"App,Realtime\" -c \"cyan,magenta\" \"cd apps/sim && bun run dev\" \"cd apps/realtime && bun run dev\"",
"dev:full:capped": "bunx concurrently -n \"App,Realtime\" -c \"cyan,magenta\" \"cd apps/sim && bun run dev:capped\" \"cd apps/realtime && bun run dev\"",
"test": "bun run test:setup && bun run test:icon-path-precision && bun run test:tool-registry-boundary && bun run test:tool-request-boundary && bun run test:generators && turbo run test",
"test": "bun run test:setup && bun run test:npm-package-versions && bun run test:icon-path-precision && bun run test:tool-registry-boundary && bun run test:tool-request-boundary && bun run test:generators && turbo run test",
"test:setup": "bun run --cwd packages/sim-setup test",
"test:npm-package-versions": "bunx vitest run scripts/bump-npm-package-versions.test.ts",
"test:icon-path-precision": "bunx vitest run scripts/check-icon-path-precision.test.ts",
"test:tool-registry-boundary": "bunx vitest run scripts/check-tool-registry-boundary.test.ts",
"test:tool-request-boundary": "bunx vitest run scripts/check-tool-request-boundary.test.ts",
Expand Down Expand Up @@ -93,6 +94,7 @@
"library:covers": "bun run scripts/generate-library-covers.tsx",
"library:covers:check": "bun run scripts/generate-library-covers.tsx --check",
"skills:sync": "bun run scripts/sync-skills.ts",
"bump:npm-packages": "bun run scripts/bump-npm-package-versions.ts",
"sim": "bun run packages/sim-cli/src/index.ts",
"sim-setup": "bun run packages/sim-setup/src/index.ts",
"agent-stream-docs:generate": "bun run scripts/sync-agent-stream-docs.ts",
Expand Down
71 changes: 71 additions & 0 deletions scripts/bump-npm-package-versions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { describe, expect, it } from 'vitest'
import {
resolveNextStableVersion,
updateLockfileWorkspaceVersion,
} from './bump-npm-package-versions'
Comment thread
TheodoreSpeaks marked this conversation as resolved.

describe('resolveNextStableVersion', () => {
it('increments the highest published stable patch and ignores prereleases', () => {
expect(
resolveNextStableVersion('2.1.2', [
'2.1.3-preview.10.1',
'1.9.9',
'2.1.2',
'2.1.3-dev.11.1',
'2.0.8',
])
).toBe('2.1.3')
})

it('preserves a higher unpublished manifest version', () => {
expect(resolveNextStableVersion('3.0.0', ['2.1.2', '2.1.3-preview.10.1'])).toBe('3.0.0')
})

it('advances from the registry when the manifest is stale', () => {
expect(resolveNextStableVersion('1.5.0', ['2.0.0', '2.1.2'])).toBe('2.1.3')
})

it('fails on a prerelease manifest or a registry without a stable version', () => {
expect(() => resolveNextStableVersion('2.1.3-preview.1', ['2.1.2'])).toThrow(
"Manifest version must be a stable X.Y.Z version, got '2.1.3-preview.1'"
)
expect(() => resolveNextStableVersion('2.1.3', ['2.1.3-preview.1'])).toThrow(
'npm returned no published stable versions'
)
})
})

describe('updateLockfileWorkspaceVersion', () => {
const lockfile = `{
"workspaces": {
"packages/sim-cli": {
"name": "sim",
"version": "2.1.2",
},
"packages/sim-setup": {
"name": "sim-setup",
"version": "1.0.2",
},
},
}`

it('updates only the selected workspace', () => {
const next = updateLockfileWorkspaceVersion(
lockfile,
'packages/sim-cli',
'sim',
'2.1.2',
'2.1.3'
)

expect(next).toContain('"version": "2.1.3"')
expect(next).toContain('"version": "1.0.2"')
expect(next).not.toContain('"version": "2.1.2"')
})

it('fails when the lockfile disagrees with the manifest', () => {
expect(() =>
updateLockfileWorkspaceVersion(lockfile, 'packages/sim-cli', 'sim', '2.1.1', '2.1.3')
).toThrow("bun.lock must contain exactly one sim@2.1.1 entry in 'packages/sim-cli'")
})
})
Loading
Loading