Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
feat: add release infrastructure with cross-compiled binaries#31
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9671e4f458ad76f3560b2d4ebb775f2b957e9268b3dc801a0d6da7fe88ddd5331b83b7bffd158a14084ca18767045abd2b29670637ffc7f31b238a93f52d84975ab131a828149b0508d27df13e8749cacd7994500599b1efa6d7f9cebde2c109556ff482ff04199333507f311e89d2b07d4e38f6490b2658efb32edc36cb55ee2092d76c86f30646c077275b2d01b4466c394cfd316a60847f26File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Changesets | ||
| This directory is used by [Changesets](https://github.com/changesets/changesets) to manage versioning and changelogs. | ||
| To add a changeset, run: | ||
| ```sh | ||
| bunx changeset | ||
| ``` | ||
| This will prompt you to select the packages that changed and the type of change (patch, minor, major). A markdown file will be created in this directory describing the change — commit it with your PR. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", | ||
| "changelog": "@changesets/cli/changelog", | ||
| "commit": false, | ||
| "linked": [], | ||
| "access": "public", | ||
| "baseBranch": "origin/main", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": ["@clerk/cli-core"], | ||
| "snapshot": { | ||
| "useCalculatedVersion": true, | ||
| "prereleaseTemplate": "{tag}.v{datetime}" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Build Binaries | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| ref: | ||
| required: true | ||
| type: string | ||
| artifact-prefix: | ||
| required: true | ||
| type: string | ||
| description: "Prefix for artifact names (e.g. 'clerk', 'clerk-canary', 'clerk-snapshot')" | ||
| jobs: | ||
| build: | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - name: Build all targets | ||
| env: | ||
| CLI_VERSION: ${{ inputs.version }} | ||
| run: bun run scripts/build.ts --version="${CLI_VERSION}" | ||
Comment on lines
+26
to
+31
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. 🧩 Analysis chain🏁 Script executed: # First, find and examine the build script
find . -name "build.ts" -o -name "build.js"| head -20Repository: clerk/cli-new Length of output: 75 🏁 Script executed: # Check the workflow file structure to understand how targets are built
cat -n .github/workflows/build-binaries.yml | head -50Repository: clerk/cli-new Length of output: 1722 🏁 Script executed: # Find and examine the cli-core package.json
find . -path "*/packages/cli-core/package.json"Repository: clerk/cli-new Length of output: 89 🏁 Script executed: cat -n ./scripts/build.tsRepository: clerk/cli-new Length of output: 2701 🏁 Script executed: cat -n ./packages/cli-core/package.json | head -40Repository: clerk/cli-new Length of output: 1105 🏁 Script executed: cat -n ./scripts/releaser/targets.tsRepository: clerk/cli-new Length of output: 2532 🏁 Script executed: grep -r "@napi-rs/keyring" ./packages/cli-core/src/ --include="*.ts" -nRepository: clerk/cli-new Length of output: 799 🌐 Web query:
💡 Result:
Citations:
🌐 Web query:
💡 Result: To cross-compile a single-file executable with Bun, you use bun build --compile --target=bun-linux-x64 ./index.ts --outfile myapp
# examples: bun-linux-arm64, bun-windows-x64, bun-darwin-arm64, etc.Bun documents these Native modules ( | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-darwin-arm64 | ||
| path: dist/artifacts/darwin-arm64/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-darwin-x64 | ||
| path: dist/artifacts/darwin-x64/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-linux-arm64 | ||
| path: dist/artifacts/linux-arm64/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-linux-arm64-musl | ||
| path: dist/artifacts/linux-arm64-musl/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-linux-x64 | ||
| path: dist/artifacts/linux-x64/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-linux-x64-musl | ||
| path: dist/artifacts/linux-x64-musl/clerk | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-win32-arm64 | ||
| path: dist/artifacts/win32-arm64/clerk.exe | ||
| retention-days: 1 | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-win32-x64 | ||
| path: dist/artifacts/win32-x64/clerk.exe | ||
| retention-days: 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| name: Release | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| concurrency: | ||
| group: release | ||
| cancel-in-progress: false | ||
| permissions: | ||
| contents: read | ||
wyattjoh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| jobs: | ||
| versioning: | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| outputs: | ||
| release_created: ${{ steps.check.outputs.release_created }} | ||
| version: ${{ steps.check.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - id: changesets | ||
| uses: changesets/action@v1 | ||
| with: | ||
| version: bun run version-packages | ||
| commit: "ci(repo): version packages" | ||
| title: "ci(repo): Version Packages" | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| - name: Check if release needed | ||
| id: check | ||
| run: bun run scripts/check-release.ts | ||
| # ─── Stable release ──────────────────────────────────────────────── | ||
| build: | ||
| needs: versioning | ||
| if: ${{ needs.versioning.outputs.release_created == 'true' }} | ||
| uses: ./.github/workflows/build-binaries.yml | ||
| with: | ||
| version: ${{ needs.versioning.outputs.version }} | ||
| ref: ${{ github.sha }} | ||
| artifact-prefix: clerk | ||
| smoke-test: | ||
| needs: [versioning, build] | ||
| uses: ./.github/workflows/smoke-test.yml | ||
| with: | ||
| version: ${{ needs.versioning.outputs.version }} | ||
| artifact-prefix: clerk | ||
| preset: stable | ||
| publish-npm: | ||
| needs: [versioning, build, smoke-test] | ||
| # Must run on GitHub-hosted runner for npm OIDC trusted publishing | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22" | ||
| registry-url: "https://registry.npmjs.org" | ||
| - name: Upgrade npm for OIDC trusted publishing | ||
| run: npm install -g npm@11 | ||
| - run: bun install --frozen-lockfile | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: clerk-* | ||
| path: dist/artifacts | ||
| - name: Publish packages | ||
| run: bun run release | ||
| env: | ||
| ARTIFACTS_DIR: ${{ github.workspace }}/dist/artifacts | ||
| GH_TOKEN: ${{ github.token }} | ||
| upload-github-assets: | ||
| needs: [versioning, build, smoke-test, publish-npm] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: clerk-* | ||
| path: dist/artifacts | ||
| - name: Upload binaries to GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| run: | | ||
| tag="v${{ needs.versioning.outputs.version }}" | ||
| for dir in dist/artifacts/clerk-*/; do | ||
| target=${dir#dist/artifacts/clerk-} && target=${target%/} | ||
| ext=""; [[ "$target" == win32-* ]] && ext=".exe" | ||
| gh release upload "$tag" "${dir}clerk${ext}#clerk-${target}${ext}" | ||
| done | ||
| # ─── Canary release ──────────────────────────────────────────────── | ||
| canary-version: | ||
| needs: versioning | ||
| if: ${{ needs.versioning.outputs.release_created != 'true' }} | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| timeout-minutes: 5 | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - name: Version packages for canary | ||
| id: version | ||
| run: | | ||
| bun run version-packages:canary | ||
| version=$(jq -r '.version' packages/cli/package.json) | ||
| echo "version=${version}" >> "$GITHUB_OUTPUT" | ||
| canary-build: | ||
| needs: canary-version | ||
| uses: ./.github/workflows/build-binaries.yml | ||
| with: | ||
| version: ${{ needs.canary-version.outputs.version }} | ||
| ref: ${{ github.sha }} | ||
| artifact-prefix: clerk-canary | ||
| canary-smoke-test: | ||
| needs: [canary-version, canary-build] | ||
| uses: ./.github/workflows/smoke-test.yml | ||
| with: | ||
| version: ${{ needs.canary-version.outputs.version }} | ||
| artifact-prefix: clerk-canary | ||
| preset: canary | ||
| canary-publish: | ||
| needs: [canary-version, canary-build, canary-smoke-test] | ||
| # Must run on GitHub-hosted runner for npm OIDC trusted publishing | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22" | ||
| registry-url: "https://registry.npmjs.org" | ||
| - name: Upgrade npm for OIDC trusted publishing | ||
| run: npm install -g npm@11 | ||
| - run: bun install --frozen-lockfile | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: clerk-canary-* | ||
| path: dist/artifacts | ||
| - name: Rename artifact directories | ||
| run: | | ||
| cd dist/artifacts | ||
| for dir in clerk-canary-*/; do | ||
| target=${dir#clerk-canary-} && target=${target%/} | ||
| mv "$dir" "clerk-${target}" | ||
| done | ||
| - name: Publish canary packages | ||
| run: bun run release:canary --version "$CANARY_VERSION" | ||
| env: | ||
| CANARY_VERSION: ${{ needs.canary-version.outputs.version }} | ||
| ARTIFACTS_DIR: ${{ github.workspace }}/dist/artifacts | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Is there a practical benefit to parallelizing these? For a larger project I could see the argument, but these builds should be really quick.
I expect the overhead of the GH actions setup here to build / upload / download the artifacts might end up taking longer than doing everything inline.