Skip to content

Commit f4d624a

Browse files
authored
feat: Set up Craft-based release workflow for npm and GitHub Releases (#28)
## Summary Sets up a complete release pipeline using Craft for publishing to npm and GitHub Releases. Flattens the monorepo structure (moves `packages/cli/*` to root) and consolidates CI workflows into a single `ci.yml` with lint, test, and multi-platform builds. **npm package**: Single-file ESM bundle (~165KB) that works standalone without dependencies. Replaced `fast-glob` with `tinyglobby` for ESM compatibility and fixed the bundle to inline all npm packages (`external: ["node:*"]`). **GitHub Releases**: Native Bun-compiled binaries for darwin-arm64, darwin-x64, linux-arm64, linux-x64, and windows-x64. Cross-compilation enabled for platforms without available CI runners. **CI improvements**: Consolidated test workflows (removed duplicate `test.yml`), added coverage reporting, proper `node_modules` caching, and cross-compilation support via `--target` flag for unavailable runners (macOS-13 retired, ARM runners not available for private repos).
1 parent 3918e5b commit f4d624a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+826
-706
lines changed

.craft.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
minVersion: '2.14.0'
2+
changelog:
3+
policy: auto
4+
preReleaseCommand: npm --no-git-tag-version version ${CRAFT_NEW_VERSION}
5+
postReleaseCommand: >-
6+
npm --no-git-tag-version version preminor --preid=dev &&
7+
git diff --quiet || (git commit -anm "meta: Bump new development version
8+
9+
#skip-changelog" && git pull --rebase && git push)
10+
requireNames:
11+
- /^sentry-.+$/
12+
- /^sentry-.*\.tgz$/
13+
targets:
14+
- name: npm
15+
- name: github
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Changelog Preview
2+
on:
3+
pull_request_target:
4+
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
changelog-preview:
12+
uses: getsentry/craft/.github/workflows/changelog-preview.yml@v2
13+
secrets: inherit

.github/workflows/ci.yml

Lines changed: 147 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,168 @@
11
name: CI
22

33
on:
4+
push:
5+
branches: [main, release/**]
6+
paths:
7+
- 'src/**'
8+
- 'test/**'
9+
- 'script/**'
10+
- 'package.json'
11+
- 'bun.lock'
12+
- '.github/workflows/ci.yml'
413
pull_request:
514
paths:
6-
- 'packages/cli/**'
15+
- 'src/**'
16+
- 'test/**'
17+
- 'script/**'
18+
- 'package.json'
19+
- 'bun.lock'
720
- '.github/workflows/ci.yml'
21+
workflow_call:
822

923
concurrency:
1024
group: ci-${{ github.ref }}
1125
cancel-in-progress: true
1226

13-
defaults:
14-
run:
15-
working-directory: packages/cli
16-
1727
jobs:
18-
build:
19-
name: Build
28+
lint:
29+
name: Lint & Typecheck
2030
runs-on: ubuntu-latest
2131
steps:
2232
- uses: actions/checkout@v4
23-
24-
- name: Setup Bun
25-
uses: oven-sh/setup-bun@v2
33+
- uses: oven-sh/setup-bun@v2
34+
- uses: actions/cache@v4
35+
id: cache
2636
with:
27-
bun-version: latest
37+
path: node_modules
38+
key: node-modules-${{ hashFiles('bun.lock') }}
39+
- if: steps.cache.outputs.cache-hit != 'true'
40+
run: bun install --frozen-lockfile
41+
- run: bun run lint
42+
- run: bun run typecheck
2843

29-
- name: Install dependencies
30-
run: bun install
31-
32-
- name: Build (current platform only)
44+
test:
45+
name: Test
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
actions: read
50+
pull-requests: write
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: oven-sh/setup-bun@v2
54+
- uses: actions/cache@v4
55+
id: cache
56+
with:
57+
path: node_modules
58+
key: node-modules-${{ hashFiles('bun.lock') }}
59+
- if: steps.cache.outputs.cache-hit != 'true'
60+
run: bun install --frozen-lockfile
61+
- name: Test
3362
env:
34-
SENTRY_CLIENT_ID: ${{ secrets.SENTRY_CLIENT_ID }}
35-
run: bun run build
63+
SENTRY_TEST_AUTH_TOKEN: ${{ secrets.SENTRY_TEST_AUTH_TOKEN }}
64+
SENTRY_TEST_ORG: ${{ secrets.SENTRY_TEST_ORG }}
65+
SENTRY_TEST_PROJECT: ${{ secrets.SENTRY_TEST_PROJECT }}
66+
run: bun test --coverage --coverage-reporter=lcov
67+
- name: Upload Coverage
68+
uses: getsentry/codecov-action@main
69+
with:
70+
token: ${{ secrets.GITHUB_TOKEN }}
71+
post-pr-comment: true
3672

73+
build-binary:
74+
name: Build Binary (${{ matrix.target }})
75+
needs: [lint, test]
76+
runs-on: ${{ matrix.os }}
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
include:
81+
# Native builds (can run smoke test)
82+
- target: darwin-arm64
83+
os: macos-latest
84+
can-test: true
85+
- target: linux-x64
86+
os: ubuntu-latest
87+
can-test: true
88+
- target: windows-x64
89+
os: windows-latest
90+
can-test: true
91+
# Cross-compiled builds (cannot run smoke test)
92+
- target: darwin-x64
93+
os: macos-latest
94+
can-test: false
95+
- target: linux-arm64
96+
os: ubuntu-latest
97+
can-test: false
98+
steps:
99+
- uses: actions/checkout@v4
100+
- uses: oven-sh/setup-bun@v2
101+
- uses: actions/cache@v4
102+
id: cache
103+
with:
104+
path: node_modules
105+
key: node-modules-${{ matrix.os }}-${{ hashFiles('bun.lock') }}
106+
- if: steps.cache.outputs.cache-hit != 'true'
107+
run: bun install --frozen-lockfile
108+
- name: Build
109+
env:
110+
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
111+
run: bun run build --target ${{ matrix.target }}
37112
- name: Smoke test
113+
if: matrix.can-test
114+
shell: bash
38115
run: |
39-
./dist/sentry-linux-x64/bin/sentry --help
40-
echo "Build successful!"
116+
if [[ "${{ matrix.target }}" == "windows-x64" ]]; then
117+
./dist/sentry-windows-x64/bin/sentry.exe --help
118+
else
119+
./dist/sentry-${{ matrix.target }}/bin/sentry --help
120+
fi
121+
- name: Upload artifact
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: sentry-${{ matrix.target }}
125+
path: dist/sentry-*/bin/sentry*
126+
127+
build-npm:
128+
name: Build npm Package
129+
needs: [lint, test]
130+
runs-on: ubuntu-latest
131+
steps:
132+
- uses: actions/checkout@v4
133+
- uses: oven-sh/setup-bun@v2
134+
- uses: actions/setup-node@v4
135+
with:
136+
node-version: '22'
137+
- uses: actions/cache@v4
138+
id: cache
139+
with:
140+
path: node_modules
141+
key: node-modules-${{ hashFiles('bun.lock') }}
142+
- if: steps.cache.outputs.cache-hit != 'true'
143+
run: bun install --frozen-lockfile
144+
- name: Bundle
145+
env:
146+
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
147+
run: bun run bundle
148+
- name: Smoke test (Node.js)
149+
run: node dist/bin.mjs --help
150+
- run: npm pack
151+
- name: Upload artifact
152+
uses: actions/upload-artifact@v4
153+
with:
154+
name: npm-package
155+
path: '*.tgz'
156+
157+
merge-artifacts:
158+
name: Merge Artifacts
159+
needs: [build-binary, build-npm]
160+
runs-on: ubuntu-latest
161+
steps:
162+
- uses: actions/download-artifact@v4
163+
- uses: actions/upload-artifact@v4
164+
with:
165+
name: ${{ github.sha }}
166+
path: |
167+
sentry-*/
168+
npm-package/*.tgz

.github/workflows/publish.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: Version to release (semver, bump type, or "auto")
7+
required: true
8+
default: 'auto'
9+
force:
10+
description: Force release even with blockers
11+
required: false
12+
13+
jobs:
14+
ci:
15+
uses: ./.github/workflows/ci.yml
16+
permissions:
17+
contents: read
18+
secrets: inherit
19+
20+
release:
21+
needs: [ci]
22+
uses: getsentry/craft/.github/workflows/release.yml@v2
23+
with:
24+
version: ${{ inputs.version }}
25+
force: ${{ inputs.force }}
26+
publish_repo: getsentry/publish
27+
secrets: inherit
28+
permissions:
29+
contents: write

.github/workflows/test.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)