Repository navigation
HIGHLY EXPERIMENTAL (do not open this pr 🤫) #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f5cb5e7
7e7198c
5d055e3
f5b98a1
9b98445
9cb7015
3b2088e
29bf48d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ jobs: | |
| name: Release to NPM | ||
| if: startsWith(github.event.head_commit.message, 'chore(release):') | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -104,22 +104,52 @@ jobs: | |
| run: cd packages/types && bun publish --access public | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| BTS_TELEMETRY: 1 | ||
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | ||
|
|
||
| - name: Update CLI types dependency and version | ||
| - name: Update CLI version and types dependency | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| cd apps/cli | ||
| jq --arg v "^$VERSION" '.dependencies["@better-t-stack/types"] = $v' package.json > tmp.json && mv tmp.json package.json | ||
| jq --arg v "$VERSION" --arg dep "^$VERSION" '.version = $v | .dependencies["@better-t-stack/types"] = $dep' package.json > tmp.json && mv tmp.json package.json | ||
|
|
||
| - name: Build CLI | ||
| - name: Update CLI optionalDependencies versions | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| cd apps/cli | ||
| jq --arg v "$VERSION" ' | ||
| .optionalDependencies["@better-t-stack/cli-darwin-arm64"] = $v | | ||
| .optionalDependencies["@better-t-stack/cli-darwin-x64"] = $v | | ||
| .optionalDependencies["@better-t-stack/cli-linux-arm64"] = $v | | ||
| .optionalDependencies["@better-t-stack/cli-linux-x64"] = $v | | ||
| .optionalDependencies["@better-t-stack/cli-windows-x64"] = $v | ||
| ' package.json > tmp.json && mv tmp.json package.json | ||
|
|
||
| - name: Build CLI binaries | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: cd apps/cli && bun run build | ||
|
|
||
| - name: Publish CLI platform packages to NPM | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: | | ||
| cd apps/cli/dist | ||
| ls -la | ||
| for dir in */; do | ||
| if [ -f "$dir/package.json" ]; then | ||
| echo "Publishing $dir..." | ||
| cd "$dir" | ||
| bun publish --access public | ||
| cd .. | ||
| fi | ||
| done | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
|
||
| - name: Publish CLI main package to NPM | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: cd apps/cli && bun publish --access public | ||
| env: | ||
| BTS_TELEMETRY: 1 | ||
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
Comment on lines
+132
to
+152
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider verifying platform package availability before publishing main package. The main CLI package (lines 148-152) is published immediately after the platform packages (lines 132-146). Since the main package lists these as optionalDependencies, there's a potential race condition if NPM registry propagation hasn't completed. Users installing immediately after the release might not receive the platform-specific binaries until propagation finishes (typically a few minutes). While optionalDependencies won't cause installation failures, consider adding a brief delay or verification step between publishing platform and main packages to ensure better user experience for early adopters. 💡 Example verification step - name: Verify platform packages are available
if: steps.check-version.outputs.exists == 'false'
run: |
VERSION="${{ steps.version.outputs.version }}"
PACKAGES=(
"@better-t-stack/cli-darwin-arm64"
"@better-t-stack/cli-darwin-x64"
"@better-t-stack/cli-linux-arm64"
"@better-t-stack/cli-linux-x64"
"@better-t-stack/cli-windows-x64"
)
for pkg in "${PACKAGES[@]}"; do
echo "Checking $pkg@$VERSION..."
for i in {1..30}; do
if npm view "$pkg@$VERSION" version 2>/dev/null; then
echo "✓ $pkg@$VERSION is available"
break
fi
if [ $i -eq 30 ]; then
echo "✗ $pkg@$VERSION not available after 5 minutes"
exit 1
fi
echo " Waiting... (attempt $i/30)"
sleep 10
done
done🤖 Prompt for AI Agents |
||
|
|
||
| - name: Update create-bts alias package version | ||
| if: steps.check-version.outputs.exists == 'false' | ||
|
|
@@ -128,21 +158,29 @@ jobs: | |
| cd packages/create-bts | ||
| jq --arg v "$VERSION" --arg dep "^$VERSION" '.version = $v | .dependencies["create-better-t-stack"] = $dep' package.json > tmp.json && mv tmp.json package.json | ||
|
|
||
| - name: Publish CLI to NPM | ||
| - name: Publish create-bts alias to NPM | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: cd apps/cli && bun publish --access public | ||
| run: cd packages/create-bts && bun publish --access public | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| BTS_TELEMETRY: 1 | ||
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | ||
|
|
||
| - name: Publish create-bts alias to NPM | ||
| - name: Upload binaries to GitHub Release | ||
| if: steps.check-version.outputs.exists == 'false' | ||
| run: cd packages/create-bts && bun publish --access public | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| cd apps/cli/dist | ||
| for dir in better-t-stack-cli-*/; do | ||
| name="${dir%/}" | ||
| if [[ "$name" == *"linux"* ]]; then | ||
| tar -czf "${name}.tar.gz" -C "$dir/bin" . | ||
| gh release upload "v$VERSION" "${name}.tar.gz" --clobber | ||
| else | ||
| zip -j "${name}.zip" "$dir/bin/"* | ||
| gh release upload "v$VERSION" "${name}.zip" --clobber | ||
| fi | ||
| done | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| BTS_TELEMETRY: 1 | ||
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Release Summary | ||
| if: steps.check-version.outputs.exists == 'false' | ||
|
|
@@ -154,6 +192,11 @@ jobs: | |
| echo "- [create-better-t-stack@$VERSION](https://www.npmjs.com/package/create-better-t-stack/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- [create-bts@$VERSION](https://www.npmjs.com/package/create-bts/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- [@better-t-stack/types@$VERSION](https://www.npmjs.com/package/@better-t-stack/types/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- @better-t-stack/cli-darwin-arm64@$VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "- @better-t-stack/cli-darwin-x64@$VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "- @better-t-stack/cli-linux-arm64@$VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "- @better-t-stack/cli-linux-x64@$VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "- @better-t-stack/cli-windows-x64@$VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### GitHub Release" >> $GITHUB_STEP_SUMMARY | ||
| echo "[v$VERSION](https://github.com/${{ github.repository }}/releases/tag/v$VERSION)" >> $GITHUB_STEP_SUMMARY | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * Bin stub for create-better-t-stack. | ||
| * Finds and runs the platform-specific compiled binary. | ||
| * | ||
| * The binary is installed as an optional dependency: | ||
| * @better-t-stack/cli-{platform}-{arch} | ||
| * | ||
| * This stub searches node_modules for the matching binary package. | ||
| */ | ||
|
|
||
| import { spawnSync } from "node:child_process"; | ||
| import { existsSync, realpathSync } from "node:fs"; | ||
| import { dirname, join } from "node:path"; | ||
| import { platform as osPlatform, arch as osArch } from "node:os"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| function run(target) { | ||
| const result = spawnSync(target, process.argv.slice(2), { | ||
| stdio: "inherit", | ||
| }); | ||
| if (result.error) { | ||
| console.error(result.error.message); | ||
| process.exit(1); | ||
| } | ||
| const code = typeof result.status === "number" ? result.status : 0; | ||
| process.exit(code); | ||
| } | ||
|
|
||
| // Allow override via environment variable | ||
| const envPath = process.env.CREATE_BETTER_T_STACK_BIN_PATH; | ||
| if (envPath) { | ||
| run(envPath); | ||
| } | ||
|
|
||
| const scriptPath = realpathSync(__filename); | ||
| const scriptDir = dirname(scriptPath); | ||
|
|
||
| const platformMap = { | ||
| darwin: "darwin", | ||
| linux: "linux", | ||
| win32: "windows", | ||
| }; | ||
|
|
||
| const archMap = { | ||
| x64: "x64", | ||
| arm64: "arm64", | ||
| }; | ||
|
|
||
| let platform = platformMap[osPlatform()]; | ||
| if (!platform) { | ||
| platform = osPlatform(); | ||
| } | ||
|
|
||
| let arch = archMap[osArch()]; | ||
| if (!arch) { | ||
| arch = osArch(); | ||
| } | ||
|
|
||
| // Scoped package name: @better-t-stack/cli-{platform}-{arch} | ||
| const scopedPackage = "@better-t-stack/cli-" + platform + "-" + arch; | ||
| const binary = platform === "windows" ? "create-better-t-stack.exe" : "create-better-t-stack"; | ||
|
|
||
| function findBinary(startDir) { | ||
| let current = startDir; | ||
| for (; ;) { | ||
| const modules = join(current, "node_modules"); | ||
| if (existsSync(modules)) { | ||
| // Check for scoped package: node_modules/@better-t-stack/cli-{platform}-{arch} | ||
| const scopedPath = join(modules, "@better-t-stack", "cli-" + platform + "-" + arch); | ||
| const candidate = join(scopedPath, "bin", binary); | ||
| if (existsSync(candidate)) { | ||
| return candidate; | ||
| } | ||
| } | ||
| const parent = dirname(current); | ||
| if (parent === current) { | ||
| return; | ||
| } | ||
| current = parent; | ||
| } | ||
| } | ||
|
|
||
| const resolved = findBinary(scriptDir); | ||
|
|
||
| if (!resolved) { | ||
| console.error( | ||
| 'No binary found for your platform (' + platform + '-' + arch + ').\n' + | ||
| 'You can try manually installing the "' + scopedPackage + '" package.', | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| run(resolved); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling to prevent partial platform releases.
The publishing loop continues even if a platform package fails to publish, which could result in a partial release where some platform binaries are available but others are not. This would create an inconsistent release state.
🔎 Proposed fix to fail fast on publish errors
- name: Publish CLI platform packages to NPM if: steps.check-version.outputs.exists == 'false' run: | + set -e cd apps/cli/dist ls -la for dir in */; do if [ -f "$dir/package.json" ]; then echo "Publishing $dir..." - cd "$dir" - bun publish --access public - cd .. + (cd "$dir" && bun publish --access public) || exit 1 fi done env: NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}📝 Committable suggestion
🤖 Prompt for AI Agents