Skip to content

Commit d3fba1d

Browse files
chore: bump version to 2.0.0
1 parent 5117cac commit d3fba1d

20 files changed

Lines changed: 1104 additions & 37 deletions

File tree

.github/workflows/publish.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Publish to npm and GitHub Packages
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
registry:
9+
description: 'Registry to publish to'
10+
required: true
11+
default: 'npm'
12+
type: choice
13+
options:
14+
- npm
15+
- github
16+
- both
17+
18+
jobs:
19+
build-and-test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v2
27+
with:
28+
version: 8
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '18'
34+
cache: 'pnpm'
35+
36+
- name: Install dependencies
37+
run: pnpm install
38+
39+
- name: Build packages
40+
run: pnpm build
41+
42+
- name: Run tests
43+
run: pnpm test
44+
45+
- name: Upload build artifacts
46+
uses: actions/upload-artifact@v3
47+
with:
48+
name: dist
49+
path: packages/*/dist
50+
51+
publish-npm:
52+
needs: build-and-test
53+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.registry == 'npm' || github.event.inputs.registry == 'both'))
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
59+
- name: Setup pnpm
60+
uses: pnpm/action-setup@v2
61+
with:
62+
version: 8
63+
64+
- name: Setup Node.js for npm
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '18'
68+
registry-url: 'https://registry.npmjs.org'
69+
cache: 'pnpm'
70+
71+
- name: Install dependencies
72+
run: pnpm install
73+
74+
- name: Download build artifacts
75+
uses: actions/download-artifact@v3
76+
with:
77+
name: dist
78+
79+
- name: Publish to npm
80+
run: pnpm -r publish --access public --no-git-checks
81+
env:
82+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
84+
publish-github:
85+
needs: build-and-test
86+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.registry == 'github' || github.event.inputs.registry == 'both'))
87+
runs-on: ubuntu-latest
88+
permissions:
89+
contents: read
90+
packages: write
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v4
94+
95+
- name: Setup pnpm
96+
uses: pnpm/action-setup@v2
97+
with:
98+
version: 8
99+
100+
- name: Setup Node.js for GitHub Packages
101+
uses: actions/setup-node@v4
102+
with:
103+
node-version: '18'
104+
registry-url: 'https://npm.pkg.github.com'
105+
scope: '@meridianalgo'
106+
cache: 'pnpm'
107+
108+
- name: Install dependencies
109+
run: pnpm install
110+
111+
- name: Download build artifacts
112+
uses: actions/download-artifact@v3
113+
with:
114+
name: dist
115+
116+
- name: Publish to GitHub Packages
117+
run: pnpm -r publish --access public --no-git-checks
118+
env:
119+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.npmrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
@MeridianAlgo:registry=https://npm.pkg.github.com
1+
# Default registry for @meridianalgo scope
2+
# Uncomment the line below to publish to GitHub Packages
3+
@meridianalgo:registry=https://npm.pkg.github.com
4+
5+
# For npm publishing (default)
6+
registry=https://registry.npmjs.org/

PUBLISHING_GUIDE.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# Publishing Guide for MeridianAlgo.js
2+
3+
This guide covers how to publish the MeridianAlgo packages to both npm and GitHub Packages.
4+
5+
## Prerequisites
6+
7+
1. **npm Account**: Create an account at [npmjs.com](https://www.npmjs.com/)
8+
2. **GitHub Account**: You need a GitHub account with this repository
9+
3. **Authentication Tokens**:
10+
- npm token for npm publishing
11+
- GitHub Personal Access Token (PAT) for GitHub Packages
12+
13+
## Publishing to npm
14+
15+
### Step 1: Login to npm
16+
17+
```bash
18+
npm login
19+
```
20+
21+
Enter your npm credentials when prompted.
22+
23+
### Step 2: Build All Packages
24+
25+
```bash
26+
pnpm build
27+
```
28+
29+
This will compile all TypeScript packages to JavaScript in the `dist` folders.
30+
31+
### Step 3: Publish All Packages
32+
33+
```bash
34+
pnpm publish:all
35+
```
36+
37+
This will publish all packages under the `@meridianalgo` scope to npm.
38+
39+
### Step 4: Verify Publication
40+
41+
Visit your packages on npm:
42+
- https://www.npmjs.com/package/@meridianalgo/core
43+
- https://www.npmjs.com/package/@meridianalgo/indicators
44+
- https://www.npmjs.com/package/@meridianalgo/data
45+
- (and so on for all packages)
46+
47+
## Publishing to GitHub Packages
48+
49+
### Step 1: Create GitHub Personal Access Token
50+
51+
1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
52+
2. Click "Generate new token (classic)"
53+
3. Select scopes:
54+
- `write:packages` - Upload packages to GitHub Package Registry
55+
- `read:packages` - Download packages from GitHub Package Registry
56+
- `delete:packages` - Delete packages from GitHub Package Registry
57+
4. Generate and copy the token
58+
59+
### Step 2: Configure npm for GitHub Packages
60+
61+
Create or update `.npmrc` in your home directory (`~/.npmrc` or `C:\Users\YourName\.npmrc`):
62+
63+
```
64+
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
65+
@meridianalgo:registry=https://npm.pkg.github.com
66+
```
67+
68+
Replace `YOUR_GITHUB_TOKEN` with your actual token.
69+
70+
### Step 3: Update Package Names for GitHub
71+
72+
GitHub Packages requires the scope to match your GitHub username or organization. Update the root `.npmrc`:
73+
74+
```
75+
@MeridianAlgo:registry=https://npm.pkg.github.com
76+
```
77+
78+
### Step 4: Publish to GitHub Packages
79+
80+
```bash
81+
# Build all packages
82+
pnpm build
83+
84+
# Publish each package
85+
pnpm -r publish --registry=https://npm.pkg.github.com --access=public
86+
```
87+
88+
## Publishing to Both Registries
89+
90+
You can publish to both npm and GitHub Packages by running the commands sequentially:
91+
92+
```bash
93+
# Build once
94+
pnpm build
95+
96+
# Publish to npm
97+
pnpm -r publish --registry=https://registry.npmjs.org/ --access=public
98+
99+
# Publish to GitHub Packages
100+
pnpm -r publish --registry=https://npm.pkg.github.com --access=public
101+
```
102+
103+
## Version Management
104+
105+
### Patch Version (Bug Fixes)
106+
107+
```bash
108+
pnpm version:patch
109+
```
110+
111+
This increments the patch version (2.0.0 → 2.0.1) for all packages.
112+
113+
### Minor Version (New Features)
114+
115+
```bash
116+
pnpm version:minor
117+
```
118+
119+
This increments the minor version (2.0.0 → 2.1.0) for all packages.
120+
121+
### Major Version (Breaking Changes)
122+
123+
```bash
124+
pnpm version:major
125+
```
126+
127+
This increments the major version (2.0.0 → 3.0.0) for all packages.
128+
129+
After updating versions, commit the changes and publish:
130+
131+
```bash
132+
git add .
133+
git commit -m "chore: bump version to X.Y.Z"
134+
git push
135+
pnpm build
136+
pnpm publish:all
137+
```
138+
139+
## Troubleshooting
140+
141+
### Error: "You must be logged in to publish packages"
142+
143+
Run `npm login` and enter your credentials.
144+
145+
### Error: "You do not have permission to publish"
146+
147+
Make sure you're logged in with the correct account and have access to the `@meridianalgo` scope.
148+
149+
### Error: "Package already exists"
150+
151+
You're trying to publish a version that already exists. Increment the version number first.
152+
153+
### Error: "ENEEDAUTH"
154+
155+
Your authentication token is missing or expired. Run `npm login` again or update your `.npmrc` file.
156+
157+
## Best Practices
158+
159+
1. **Always build before publishing**: Run `pnpm build` to ensure all packages are compiled
160+
2. **Test before publishing**: Run `pnpm test` to ensure all tests pass
161+
3. **Update CHANGELOG.md**: Document changes in each release
162+
4. **Use semantic versioning**: Follow semver (major.minor.patch) conventions
163+
5. **Tag releases on GitHub**: Create git tags for each release
164+
6. **Write release notes**: Document what's new in each version
165+
166+
## GitHub Release Workflow
167+
168+
After publishing to npm:
169+
170+
1. Create a git tag:
171+
```bash
172+
git tag -a v2.0.0 -m "Release version 2.0.0"
173+
git push origin v2.0.0
174+
```
175+
176+
2. Create a GitHub Release:
177+
- Go to your repository on GitHub
178+
- Click "Releases" → "Create a new release"
179+
- Select the tag you just created
180+
- Write release notes
181+
- Publish the release
182+
183+
## Automated Publishing with GitHub Actions
184+
185+
You can automate publishing using GitHub Actions. Create `.github/workflows/publish.yml`:
186+
187+
```yaml
188+
name: Publish Packages
189+
190+
on:
191+
release:
192+
types: [created]
193+
194+
jobs:
195+
publish:
196+
runs-on: ubuntu-latest
197+
steps:
198+
- uses: actions/checkout@v3
199+
200+
- uses: pnpm/action-setup@v2
201+
with:
202+
version: 8
203+
204+
- uses: actions/setup-node@v3
205+
with:
206+
node-version: '18'
207+
registry-url: 'https://registry.npmjs.org'
208+
209+
- run: pnpm install
210+
- run: pnpm build
211+
- run: pnpm test
212+
213+
- run: pnpm -r publish --access public
214+
env:
215+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
216+
```
217+
218+
Add your npm token as a GitHub secret named `NPM_TOKEN`.
219+
220+
## Support
221+
222+
For issues with publishing:
223+
- npm: https://docs.npmjs.com/
224+
- GitHub Packages: https://docs.github.com/en/packages
225+
- pnpm: https://pnpm.io/
226+
227+
---
228+
229+
**Last Updated**: November 30, 2025
230+
**Version**: 2.0.0

0 commit comments

Comments
 (0)