-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (45 loc) · 1.45 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Publish package to NPM
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
# Setup Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest # Or specify a specific version like '1.0.0'
# Install dependencies using Bun
- name: Install dependencies
run: bun install
# Build package using Bun (adjust if needed)
- name: Build package
run: bun run build # Assuming you have a 'build' script in your package.json
# Configure npm registry and authentication
- name: Setup .npmrc
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
# Publish package using Bun (with fallbacks)
- name: Publish package
run: |
if ! command -v bunx &> /dev/null; then
echo "bunx could not be found. Installing npm globally as a fallback."
curl -fsSL https://bun.sh/install | bash
export PATH="$HOME/.bun/bin:$PATH"
bunx --bun install -g npm
fi
if bunx --bun --trust pnpm publish; then
echo "Published using bunx pnpm."
elif pnpm publish; then
echo "Published using globally installed pnpm."
else
echo "Publish failed."
exit 1
fi