Skip to content

Commit 5a14029

Browse files
0x5457buttercannfly
authored andcommitted
feat: setup npm publishing infrastructure
1 parent 7325359 commit 5a14029

14 files changed

Lines changed: 393 additions & 301 deletions

File tree

.github/workflows/package-only.yml

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

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-node@v6
21+
with:
22+
node-version: lts/*
23+
cache: pnpm
24+
25+
- run: npx changelogithub
26+
env:
27+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
28+
29+
- uses: pnpm/action-setup@v4
30+
with:
31+
version: 10
32+
33+
- name: Install dependencies
34+
run: pnpm install
35+
36+
- name: Build
37+
run: pnpm build
38+
39+
- name: Determine npm tag
40+
id: determine_npm_tag
41+
shell: bash
42+
run: |
43+
TAG="${GITHUB_REF#refs/tags/}"
44+
if [[ "$TAG" =~ -(next|canary|beta|rc) ]]; then
45+
# Extract pre-release tag (e.g., beta, rc)
46+
NPM_TAG=${BASH_REMATCH[1]}
47+
else
48+
# Check if the commit is on the main branch or a version branch
49+
git fetch origin main
50+
CURRENT_BRANCH=$(git branch -r --contains "$GITHUB_SHA" | grep -E 'origin/(main|v[0-9]+\.[0-9]+\.x-latest)' | head -1 | sed 's/.*origin\///')
51+
52+
if [[ "$CURRENT_BRANCH" == "main" ]]; then
53+
NPM_TAG="latest"
54+
elif [[ "$CURRENT_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x-latest$ ]]; then
55+
# For version branches like v1.3.x-latest, v1.4.x-latest, use "latest" tag
56+
NPM_TAG="latest"
57+
else
58+
echo "The tagged commit is not on the main branch or a version branch (v*.*.x-latest)."
59+
echo "::error ::Releases with the 'latest' npm tag must be on the main branch or a version branch."
60+
exit 1
61+
fi
62+
fi
63+
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
64+
echo "Using npm tag: $NPM_TAG"
65+
66+
- name: Publish to npm
67+
run: pnpm -r publish --access public --no-git-checks --tag ${{ steps.determine_npm_tag.outputs.npm_tag }}
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
NPM_CONFIG_PROVENANCE: true

.github/workflows/submit.yml

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

bump.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "bumpp";
2+
import { globSync } from "tinyglobby";
3+
4+
export default defineConfig({
5+
files: globSync(["./packages/*/package.json"], { expandDirectories: false }),
6+
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"scripts": {
1515
"postinstall": "prek install",
16+
"build": "pnpm -r --if-present build",
1617
"dev": "pnpm --filter @aipexstudio/cool-aipex dev",
1718
"preflight": "npm run format && npm run lint:fix && npm run typecheck && npm run test",
1819
"format": "biome format . --write",
@@ -22,14 +23,16 @@
2223
"lint:dependencies": "knip --strict",
2324
"test": "pnpm -r --if-present test",
2425
"typecheck": "tsc --build",
25-
"knip": "knip"
26+
"bump": "bumpp"
2627
},
2728
"devDependencies": {
2829
"@biomejs/biome": "^2.3.8",
2930
"@j178/prek": "^0.2.19",
3031
"@types/chrome": "0.1.32",
3132
"@types/node": "^24.10.1",
33+
"bumpp": "^10.3.2",
3234
"knip": "^5.71.0",
35+
"tinyglobby": "^0.2.15",
3336
"typescript": "^5.9.3",
3437
"vitest": "^4.0.14"
3538
}

0 commit comments

Comments
 (0)