Skip to content

Commit f838c95

Browse files
authored
feat: add bun support (#62)
* add bun support [WIP]
1 parent 8ad4e27 commit f838c95

File tree

10 files changed

+290
-16
lines changed

10 files changed

+290
-16
lines changed

src/cli.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,29 @@ const templateSummaries: Record<string, string> = {
165165
};
166166

167167
async function runInteractive(opts: CLIOptions): Promise<CLIOptions> {
168+
const pm = await prompts.select({
169+
message: 'What package manager do you use?',
170+
options: [
171+
{
172+
value: '',
173+
label: 'npm'
174+
},
175+
{
176+
value: 'bun',
177+
label: 'Bun'
178+
},
179+
{
180+
value: 'other',
181+
label: 'Other (fallbacks to npm)'
182+
}
183+
],
184+
initialValue: opts.pm
185+
});
186+
187+
if (prompts.isCancel(pm)) {
188+
cancelInteractive();
189+
}
190+
168191
const template = await prompts.select({
169192
message: 'Select a changelog tool',
170193
options: [
@@ -223,6 +246,7 @@ async function runInteractive(opts: CLIOptions): Promise<CLIOptions> {
223246
return {
224247
...opts,
225248
template,
249+
pm,
226250
...userOptions
227251
};
228252
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sade from 'sade';
22
import {runCLI} from './cli.js';
33

44
const cli = sade('@e18e/setup-publish', true);
5-
const CLI_VERSION = '0.0.0-dev';
5+
const CLI_VERSION = '0.0.10';
66

77
/*
88
* - changesets

src/templates.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ export async function createTemplate(opts: CLIOptions): Promise<void> {
3333

3434
// Shouldn't ever happen but just in case
3535
if (!templates.includes(opts.template)) {
36+
prompts.log.error('❌ Template for current configuration not found');
3637
return;
3738
}
3839

39-
const templatePath = path.join(templatesDir, `${opts.template}.yml`);
40+
if (opts.pm && !templates.includes(`${opts.template}+${opts.pm}`)) {
41+
prompts.log.warn(
42+
'⚠️ Template for your package manager does not exist. Falling back to npm'
43+
);
44+
opts.pm = '';
45+
}
46+
47+
const templatePath = opts.pm
48+
? path.join(templatesDir, `${opts.template}+${opts.pm}.yml`)
49+
: path.join(templatesDir, `${opts.template}.yml`);
50+
4051
let templateContent: string;
4152

4253
try {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export interface CLIOptions {
33
env: string | undefined;
44
interactive: boolean;
55
template: string;
6+
pm?: string;
67
}

templates/changelogithub+bun.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish to bun
2+
permissions: {}
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
with:
15+
persist-credentials: false
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
18+
with:
19+
bun-version: latest
20+
- name: Install dependencies
21+
run: bun ci --ignore-scripts
22+
- name: Run tests
23+
run: bun test
24+
build:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
outputs:
29+
tarball: ${{ steps.pack.outputs.tarball }}
30+
steps:
31+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
with:
33+
persist-credentials: false
34+
- name: Setup Bun
35+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
36+
with:
37+
bun-version: latest
38+
- name: Install dependencies
39+
run: bun ci --ignore-scripts
40+
- run: bun run build
41+
- run: bun version $TAG_NAME --git-tag-version=false
42+
env:
43+
TAG_NAME: ${{ github.ref_name }}
44+
- id: pack
45+
run: |-
46+
TARBALL=$(bun pack)
47+
echo "tarball=$TARBALL" >> $GITHUB_OUTPUT
48+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
49+
with:
50+
name: tarball
51+
path: ${{ steps.pack.outputs.tarball }}
52+
publish:
53+
needs:
54+
- test
55+
- build
56+
runs-on: ubuntu-latest
57+
permissions:
58+
id-token: write
59+
env:
60+
TARBALL: ${{ needs.build.outputs.tarball }}
61+
steps:
62+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
63+
with:
64+
name: tarball
65+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
66+
with:
67+
node-version: 24
68+
package-manager-cache: false
69+
- run: bun publish --provenance --access public --tag next $TARBALL
70+
if: github.event.release.prerelease
71+
env:
72+
TARBALL: ${{ needs.build.outputs.tarball }}
73+
- run: bun publish --provenance --access public $TARBALL
74+
if: "!github.event.release.prerelease"
75+
env:
76+
TARBALL: ${{ needs.build.outputs.tarball }}
77+
- name: Generate Change Log
78+
run: bunx changelogithub
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

templates/changesets+bun.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish to npm
2+
permissions: {}
3+
on:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
with:
15+
persist-credentials: false
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
18+
with:
19+
bun-version: latest
20+
- name: Install dependencies
21+
run: bun ci --ignore-scripts
22+
- name: Run tests
23+
run: bun test
24+
publish:
25+
needs:
26+
- test
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
pull-requests: write
31+
id-token: write
32+
steps:
33+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34+
with:
35+
persist-credentials: false
36+
- name: Setup Bun
37+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
38+
with:
39+
bun-version: latest
40+
- name: Install dependencies
41+
run: bun ci --ignore-scripts
42+
- run: bun run build
43+
- name: Create Release or Publish
44+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
45+
with:
46+
publish: bunx changeset publish
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
NPM_TOKEN: "" # Workaround. See https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868

templates/changesets.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,34 @@ jobs:
1313
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1414
with:
1515
persist-credentials: false
16-
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
16+
- name: Setup Node
17+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
1718
with:
1819
node-version: 24
1920
cache: npm
20-
- run: npm ci --ignore-scripts
21-
- run: npm test
21+
- name: Install dependencies
22+
run: npm ci --ignore-scripts
23+
- name: Run tests
24+
run: npm test
2225
publish:
26+
needs:
27+
- test
2328
runs-on: ubuntu-latest
2429
permissions:
2530
contents: read
2631
pull-requests: write
2732
id-token: write
28-
outputs:
29-
tarball: ${{ steps.pack.outputs.tarball }}
3033
steps:
3134
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3235
with:
3336
persist-credentials: false
34-
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
37+
- name: Setup Node
38+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3539
with:
3640
node-version: 24
3741
package-manager-cache: false
38-
- run: npm ci --ignore-scripts
42+
- name: Install dependencies
43+
run: npm ci --ignore-scripts
3944
- run: npm run build
4045
- name: Create Release or Publish
4146
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3

templates/default+bun.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Publish to npm
2+
permissions: {}
3+
on:
4+
release:
5+
types:
6+
- published
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
with:
15+
persist-credentials: false
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
18+
with:
19+
bun-version: latest
20+
- name: Install dependencies
21+
run: bun ci --ignore-scripts
22+
- name: Run tests
23+
run: bun test
24+
build:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
outputs:
29+
tarball: ${{ steps.pack.outputs.tarball }}
30+
steps:
31+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
with:
33+
persist-credentials: false
34+
- name: Setup Bun
35+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
36+
with:
37+
bun-version: latest
38+
- name: Install dependencies
39+
run: bun ci --ignore-scripts
40+
- run: bun run build
41+
- run: bun pm version $TAG_NAME --git-tag-version=false
42+
env:
43+
TAG_NAME: ${{ github.ref_name }}
44+
- id: pack
45+
run: |-
46+
TARBALL=$(bun pm pack)
47+
echo "tarball=$TARBALL" >> $GITHUB_OUTPUT
48+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
49+
with:
50+
name: tarball
51+
path: ${{ steps.pack.outputs.tarball }}
52+
publish:
53+
needs:
54+
- test
55+
- build
56+
runs-on: ubuntu-latest
57+
permissions:
58+
id-token: write
59+
env:
60+
TARBALL: ${{ needs.build.outputs.tarball }}
61+
steps:
62+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
63+
with:
64+
name: tarball
65+
- name: Setup Bun
66+
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
67+
with:
68+
bun-version: latest
69+
- run: bun publish --provenance --access public --tag next $TARBALL
70+
if: github.event.release.prerelease
71+
env:
72+
TARBALL: ${{ needs.build.outputs.tarball }}
73+
- run: bun publish --provenance --access public $TARBALL
74+
if: "!github.event.release.prerelease"
75+
env:
76+
TARBALL: ${{ needs.build.outputs.tarball }}

templates/default.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ jobs:
1313
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1414
with:
1515
persist-credentials: false
16-
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
16+
- name: Setup Node
17+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
1718
with:
1819
node-version: 24
1920
cache: npm
20-
- run: npm ci --ignore-scripts
21-
- run: npm test
21+
- name: Install dependencies
22+
run: npm ci --ignore-scripts
23+
- name: Run tests
24+
run: npm test
2225
build:
2326
runs-on: ubuntu-latest
2427
permissions:
@@ -29,11 +32,13 @@ jobs:
2932
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3033
with:
3134
persist-credentials: false
32-
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
35+
- name: Setup Node
36+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3337
with:
3438
node-version: 24
3539
package-manager-cache: false
36-
- run: npm ci --ignore-scripts
40+
- name: Install dependencies
41+
run: npm ci --ignore-scripts
3742
- run: npm run build
3843
- run: npm version $TAG_NAME --git-tag-version=false
3944
env:
@@ -59,7 +64,8 @@ jobs:
5964
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
6065
with:
6166
name: tarball
62-
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
67+
- name: Setup Node
68+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
6369
with:
6470
node-version: 24
6571
package-manager-cache: false

0 commit comments

Comments
 (0)