Skip to content

Commit fc0ba47

Browse files
committed
feat: first version
1 parent c04406c commit fc0ba47

23 files changed

Lines changed: 3546 additions & 572 deletions

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# NPM and GitHub Packages authentication tokens
2+
# DO NOT commit this file - it's in .gitignore
3+
4+
# NPM registry token
5+
NPM_TOKEN=your_npm_token_here
6+
7+
# GitHub token (optional - usually provided by GitHub Actions)
8+
# GITHUB_TOKEN=your_github_token_here

.github/workflows/publish-python.yml

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

.github/workflows/publish.yml

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

.github/workflows/release-auth.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release Auth Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- beta
8+
- alpha
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
issues: write
14+
pull-requests: write
15+
16+
jobs:
17+
release:
18+
name: Release @cortex-reply/auth
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
persist-credentials: false
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
33+
- name: Setup pnpm
34+
uses: pnpm/action-setup@v2
35+
with:
36+
version: 9.0.0
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Build auth package
42+
run: pnpm run build --filter=@cortex-shared/auth
43+
44+
- name: Verify built dist
45+
working-directory: packages/auth
46+
run: ls -la dist/
47+
48+
- name: Release with semantic-release
49+
uses: cycjimmy/semantic-release-action@v4
50+
with:
51+
working_directory: ./packages/auth
52+
branches: |
53+
[
54+
"main",
55+
{"name": "beta", "prerelease": true},
56+
{"name": "alpha", "prerelease": true}
57+
]
58+
extra_plugins: |
59+
@semantic-release/commit-analyzer
60+
@semantic-release/release-notes-generator
61+
@semantic-release/changelog
62+
@semantic-release/git
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.releaserc.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"branches": [
3+
"main",
4+
{
5+
"name": "beta",
6+
"prerelease": true
7+
},
8+
{
9+
"name": "alpha",
10+
"prerelease": true
11+
}
12+
],
13+
"plugins": [
14+
"@semantic-release/commit-analyzer",
15+
"@semantic-release/release-notes-generator",
16+
"@semantic-release/changelog",
17+
[
18+
"@semantic-release/npm",
19+
{
20+
"pkgRoot": "packages/auth",
21+
"tarballDir": "packages/auth/release"
22+
}
23+
],
24+
[
25+
"@semantic-release/exec",
26+
{
27+
"publishCmd": "npm publish --registry https://npm.pkg.github.com --access public",
28+
"shell": true
29+
}
30+
],
31+
[
32+
"@semantic-release/git",
33+
{
34+
"assets": [
35+
"packages/auth/package.json",
36+
"packages/auth/CHANGELOG.md"
37+
],
38+
"message": "chore(auth): release v${nextRelease.version}\n\n${nextRelease.notes}"
39+
}
40+
],
41+
"@semantic-release/github"
42+
]
43+
}

.storybook/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { StorybookConfig } from '@storybook/react-vite';
33
const config: StorybookConfig = {
44
stories: [
55
'../packages/ui/**/*.stories.@(js|jsx|mjs|ts|tsx)',
6-
'../packages/ui/*.mdx',
7-
'../packages/auth/*.mdx',
6+
'../packages/ui/**/*.mdx',
7+
'../packages/auth/**/*.mdx',
88
'../python/*.mdx',
99
'../docs/*.mdx',
1010
],

PUBLISHING.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Publishing cortex-auth Package
2+
3+
This guide explains how to publish the auth package to npm and GitHub Packages.
4+
5+
## Configuration Overview
6+
7+
The auth package is configured for publishing to:
8+
- **npm**: Published as `cortex-auth` (manual via script)
9+
- **GitHub Packages**: Published as `@cortex-reply/auth` (automatic via GitHub Actions)
10+
11+
## Prerequisites
12+
13+
### 1. NPM Token for npm Registry
14+
1. Go to [npmjs.com](https://www.npmjs.com)
15+
2. Create an account if you don't have one
16+
3. Navigate to Access Tokens → Generate New Token
17+
4. Choose "Automation" or "Publish" level access
18+
5. Add as a GitHub Actions secret named `NPM_TOKEN`
19+
20+
### 2. GitHub Token
21+
The `GITHUB_TOKEN` is automatically provided by GitHub Actions for publishing to GitHub Packages.
22+
23+
## Publishing
24+
25+
### Publish to npm
26+
```bash
27+
# Set your npm token
28+
export NPM_TOKEN=<your-npm-token>
29+
30+
# Run from the root directory
31+
bash scripts/publish-auth.sh
32+
```
33+
34+
### Publish to GitHub Packages (Automatic)
35+
Publishing to GitHub Packages happens automatically via GitHub Actions workflow when you create a tag matching `auth-v*`.
36+
37+
```bash
38+
# Create a release tag
39+
git tag auth-v0.0.2
40+
git push origin auth-v0.0.2
41+
```
42+
43+
This will trigger the workflow defined in [.github/workflows/publish-auth.yml](.github/workflows/publish-auth.yml).
44+
45+
#### Or trigger manually:
46+
Go to Actions → "Publish Auth Package" → Run workflow → Select branch and click "Run workflow"
47+
48+
## Installation for Users
49+
50+
### Install from npm
51+
```bash
52+
npm install cortex-auth
53+
# or
54+
yarn add cortex-auth
55+
# or
56+
pnpm add cortex-auth
57+
```
58+
59+
### Install from GitHub Packages
60+
Add to `.npmrc`:
61+
```
62+
@cortex-reply:registry=https://npm.pkg.github.com
63+
//npm.pkg.github.com/:_authToken=<your-github-token>
64+
```
65+
66+
Then install:
67+
```bash
68+
npm install @cortex-reply/auth
69+
# or
70+
yarn add @cortex-reply/auth
71+
# or
72+
pnpm add @cortex-reply/auth
73+
```
74+
75+
## Package Configuration Details
76+
77+
### package.json Fields
78+
- **name**: `cortex-auth` (for npm)
79+
- **publishConfig**: Specifies npm registry and public access
80+
- **repository**: Links to the GitHub repository with the package directory
81+
- **keywords**: Helps with npm discoverability
82+
83+
### .npmrc Configuration
84+
The `.npmrc` file in `packages/auth/` handles:
85+
- Routing `@cortex-reply` scope to GitHub Packages
86+
- Using the `GITHUB_TOKEN` environment variable for authentication
87+
- Default registry pointing to npm
88+
89+
## Troubleshooting
90+
91+
### Authentication Errors
92+
- Verify `NPM_TOKEN` is set correctly for npm publishing
93+
- GitHub token is automatically provided by GitHub Actions
94+
95+
### Version Already Published
96+
- Increment the version in `packages/auth/package.json`
97+
- Create a new tag for GitHub Packages: `git tag auth-v<new-version>`
98+
99+
### Workflow Not Triggering
100+
- Verify the tag matches the pattern `auth-v*`
101+
- Check workflow permissions in repository settings
102+
103+
## Setting Up GitHub Secrets
104+
105+
1. Go to Settings → Secrets and variables → Actions
106+
2. Click "New repository secret"
107+
3. Add `NPM_TOKEN` with your npm token value
108+
4. GitHub provides `GITHUB_TOKEN` automatically
109+
110+
## Workflow Details
111+
112+
The GitHub Actions workflow (`.github/workflows/publish-auth.yml`):
113+
1. Triggers on tags matching `auth-v*` or manual workflow dispatch
114+
2. Checks out the code
115+
3. Sets up Node.js with GitHub Packages registry
116+
4. Installs dependencies
117+
5. Builds the auth package
118+
6. Temporarily updates the package name to `@cortex-reply/auth`
119+
7. Publishes to GitHub Packages
120+
8. Restores the original package name
121+
9. Creates a GitHub Release

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
"type-check": "turbo run type-check",
1111
"test": "turbo run test",
1212
"storybook": "storybook dev -p 6066",
13-
"storybook:build": "storybook build -o storybook-static"
13+
"storybook:build": "storybook build -o storybook-static",
14+
"publish:auth": "sh scripts/publish-auth.sh"
1415
},
1516
"devDependencies": {
17+
"@semantic-release/changelog": "^6.0.3",
18+
"@semantic-release/commit-analyzer": "^11.1.0",
19+
"@semantic-release/exec": "^6.0.3",
20+
"@semantic-release/git": "^10.0.1",
21+
"@semantic-release/github": "^9.2.5",
22+
"@semantic-release/release-notes-generator": "^12.1.0",
1623
"@storybook/addon-essentials": "^8.6.14",
1724
"@storybook/addon-interactions": "^8.6.14",
1825
"@storybook/addon-links": "^8.6.15",
@@ -29,6 +36,7 @@
2936
"autoprefixer": "^10.4.16",
3037
"eslint": "^8.56.0",
3138
"prettier": "^3.1.1",
39+
"semantic-release": "^23.0.2",
3240
"storybook": "^8.6.14",
3341
"tailwindcss": "^4.1.0",
3442
"turbo": "^2.0.0",

packages/auth/.npmrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# GitHub Packages configuration
2+
@cortex-reply:registry=https://npm.pkg.github.com
3+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
4+
5+
# NPM registry configuration
6+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
7+
registry=https://registry.npmjs.org/
8+

0 commit comments

Comments
 (0)