Skip to content

Commit 8c5d442

Browse files
committed
feat: Set up Craft-based release workflow for npm and GitHub Releases
Configure the project for release as `sentry` package on npm (v0.2.0) using Craft and the getsentry/publish workflow. Distribution: - npm: Single bundled JS file (42KB) via esbuild for fast `npx sentry` startup - GitHub Releases: Native Bun binaries for all platforms Key changes: - Add .craft.yml with npm + github targets - Add build.yml workflow with matrix builds and smoke tests - Add release.yml and changelog-preview.yml workflows - Add esbuild bundler with Bun API polyfills for Node.js compatibility - Rename package to `sentry`, set version to 0.2.0 - Move all dependencies to devDependencies (bundled at build time) - Remove old publish.yml and platform package scripts
1 parent 3918e5b commit 8c5d442

File tree

19 files changed

+585
-426
lines changed

19 files changed

+585
-426
lines changed

.craft.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
minVersion: '2.14.0'
2+
changelog:
3+
policy: auto
4+
preReleaseCommand: >-
5+
node -p "
6+
const {execSync} = require('child_process');
7+
execSync('npm --no-git-tag-version version ' + process.env.CRAFT_NEW_VERSION, {cwd: 'packages/cli'}).toString();
8+
"
9+
postReleaseCommand: >-
10+
node -p "
11+
const {execSync} = require('child_process');
12+
execSync('npm --no-git-tag-version version preminor --preid=dev', {cwd: 'packages/cli'});
13+
execSync('git diff --quiet || git commit -anm \"meta: Bump new development version\\n\\n#skip-changelog\" && git pull --rebase && git push').toString();
14+
"
15+
requireNames:
16+
- /^sentry-.+$/
17+
- /^sentry-.*\.tgz$/
18+
targets:
19+
- name: npm
20+
- name: github

.github/workflows/build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [main, release/**]
5+
pull_request:
6+
workflow_call:
7+
8+
concurrency:
9+
group: build-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build-binary:
14+
name: Build Binary (${{ matrix.target }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- target: darwin-arm64
21+
os: macos-latest
22+
- target: darwin-x64
23+
os: macos-13
24+
- target: linux-arm64
25+
os: ubuntu-24.04-arm
26+
- target: linux-x64
27+
os: ubuntu-latest
28+
- target: windows-x64
29+
os: windows-latest
30+
steps:
31+
- uses: actions/checkout@v6
32+
- uses: oven-sh/setup-bun@v2
33+
- run: bun install
34+
working-directory: packages/cli
35+
- name: Build
36+
working-directory: packages/cli
37+
env:
38+
SENTRY_CLIENT_ID: ${{ secrets.SENTRY_CLIENT_ID }}
39+
run: bun run build
40+
- name: Smoke test
41+
working-directory: packages/cli
42+
shell: bash
43+
run: |
44+
if [[ "${{ matrix.target }}" == "windows-x64" ]]; then
45+
./dist/sentry-windows-x64/bin/sentry.exe --help
46+
else
47+
./dist/sentry-${{ matrix.target }}/bin/sentry --help
48+
fi
49+
- name: Upload artifact
50+
uses: actions/upload-artifact@v6
51+
with:
52+
name: sentry-${{ matrix.target }}
53+
path: packages/cli/dist/sentry-*/bin/sentry*
54+
55+
build-npm:
56+
name: Build npm Package
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v6
60+
- uses: oven-sh/setup-bun@v2
61+
- uses: actions/setup-node@v6
62+
with:
63+
node-version: '22'
64+
- run: bun install
65+
working-directory: packages/cli
66+
- name: Bundle
67+
working-directory: packages/cli
68+
env:
69+
SENTRY_CLIENT_ID: ${{ secrets.SENTRY_CLIENT_ID }}
70+
run: bun run bundle
71+
- name: Smoke test (Node.js)
72+
working-directory: packages/cli
73+
run: node dist/bin.mjs --help
74+
- name: Pack
75+
working-directory: packages/cli
76+
run: npm pack
77+
- name: Upload artifact
78+
uses: actions/upload-artifact@v6
79+
with:
80+
name: npm-package
81+
path: packages/cli/*.tgz
82+
83+
merge-artifacts:
84+
name: Merge Artifacts
85+
needs: [build-binary, build-npm]
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/download-artifact@v7
89+
- name: List artifacts
90+
run: find . -type f
91+
- name: Upload combined artifacts
92+
uses: actions/upload-artifact@v6
93+
with:
94+
name: ${{ github.sha }}
95+
path: |
96+
sentry-*/
97+
npm-package/*.tgz
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: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,44 @@ on:
55
paths:
66
- 'packages/cli/**'
77
- '.github/workflows/ci.yml'
8+
- '.github/workflows/build.yml'
89

910
concurrency:
1011
group: ci-${{ github.ref }}
1112
cancel-in-progress: true
1213

13-
defaults:
14-
run:
15-
working-directory: packages/cli
16-
1714
jobs:
18-
build:
19-
name: Build
15+
lint:
16+
name: Lint & Typecheck
2017
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: packages/cli
2121
steps:
22-
- uses: actions/checkout@v4
23-
24-
- name: Setup Bun
25-
uses: oven-sh/setup-bun@v2
26-
with:
27-
bun-version: latest
28-
29-
- name: Install dependencies
30-
run: bun install
31-
32-
- name: Build (current platform only)
22+
- uses: actions/checkout@v6
23+
- uses: oven-sh/setup-bun@v2
24+
- run: bun install
25+
- run: bun run lint
26+
- run: bun run typecheck
27+
28+
test:
29+
name: Test
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: packages/cli
34+
steps:
35+
- uses: actions/checkout@v6
36+
- uses: oven-sh/setup-bun@v2
37+
- run: bun install
38+
- name: Test
3339
env:
34-
SENTRY_CLIENT_ID: ${{ secrets.SENTRY_CLIENT_ID }}
35-
run: bun run build
40+
SENTRY_TEST_AUTH_TOKEN: ${{ secrets.SENTRY_TEST_AUTH_TOKEN }}
41+
SENTRY_TEST_ORG: ${{ secrets.SENTRY_TEST_ORG }}
42+
SENTRY_TEST_PROJECT: ${{ secrets.SENTRY_TEST_PROJECT }}
43+
run: bun test
3644

37-
- name: Smoke test
38-
run: |
39-
./dist/sentry-linux-x64/bin/sentry --help
40-
echo "Build successful!"
45+
build:
46+
name: Build
47+
uses: ./.github/workflows/build.yml
48+
secrets: inherit

.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+
build:
15+
uses: ./.github/workflows/build.yml
16+
permissions:
17+
contents: read
18+
secrets: inherit
19+
20+
release:
21+
needs: [build]
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: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,10 @@ on:
66
paths:
77
- 'packages/cli/**'
88
- '.github/workflows/test.yml'
9-
pull_request:
10-
branches: [main]
11-
paths:
12-
- 'packages/cli/**'
13-
- '.github/workflows/test.yml'
14-
workflow_dispatch: # Manual trigger
9+
workflow_dispatch:
1510

1611
permissions:
1712
contents: read
18-
actions: read
19-
pull-requests: write
2013

2114
jobs:
2215
test:
@@ -27,13 +20,9 @@ jobs:
2720
working-directory: packages/cli
2821

2922
steps:
30-
- name: Checkout
31-
uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
3224

33-
- name: Setup Bun
34-
uses: oven-sh/setup-bun@v2
35-
with:
36-
bun-version: latest
25+
- uses: oven-sh/setup-bun@v2
3726

3827
- name: Install dependencies
3928
run: bun install
@@ -43,11 +32,10 @@ jobs:
4332
SENTRY_TEST_AUTH_TOKEN: ${{ secrets.SENTRY_TEST_AUTH_TOKEN }}
4433
SENTRY_TEST_ORG: ${{ secrets.SENTRY_TEST_ORG }}
4534
SENTRY_TEST_PROJECT: ${{ secrets.SENTRY_TEST_PROJECT }}
46-
run: bun test --reporter=junit --reporter-outfile=./report.junit.xml --coverage --coverage-reporter=lcov
35+
run: bun test --reporter=junit --reporter-outfile=./report.junit.xml --coverage --coverage-reporter=lcov
4736

4837
- name: Upload Coverage
49-
uses: getsentry/codecov-action@main
38+
uses: codecov/codecov-action@v5
5039
with:
51-
token: ${{ secrets.GITHUB_TOKEN }}
52-
post-pr-comment: true
53-
40+
token: ${{ secrets.CODECOV_TOKEN }}
41+
files: packages/cli/coverage/lcov.info

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
<!-- Craft will auto-populate this file -->

0 commit comments

Comments
 (0)