1
- # Publishing to GitHub Package Registry
1
+ # Publishing to npm Registry
2
2
3
- This guide explains how to publish the ` ngx-angular-query-builder ` library to GitHub Package Registry .
3
+ This guide explains how to publish the ` @csfloat/ ngx-angular-query-builder` library to the npm registry .
4
4
5
5
## Prerequisites
6
6
7
- 1 . ** GitHub Repository** : Ensure your code is pushed to a GitHub repository
8
- 2 . ** GitHub Personal Access Token** : Create a token with ` write:packages ` scope
9
- 3 . ** Updated Configuration** : Make sure all configuration files are properly set up
7
+ 1 . ** npm Account** : Create an account at [ npmjs.com] ( https://www.npmjs.com/ )
8
+ 2 . ** npm Access Token** : Create an automation token from your npm account settings
9
+ 3 . ** GitHub Repository** : Ensure your code is pushed to a GitHub repository
10
+ 4 . ** Organization Access** : Ensure you have publish permissions for the ` @csfloat ` organization on npm
10
11
11
- ## Local Publishing (Manual)
12
+ ## Setup Steps
13
+
14
+ ### 1. Configure npm Token for GitHub Actions
15
+
16
+ 1 . ** Create npm Access Token:**
17
+ - Go to [ npmjs.com] ( https://www.npmjs.com/ ) → Account Settings → Access Tokens
18
+ - Click "Generate New Token" → "Automation"
19
+ - Copy the token
20
+
21
+ 2 . ** Add token to GitHub Secrets:**
22
+ - Go to your GitHub repository → Settings → Secrets and variables → Actions
23
+ - Click "New repository secret"
24
+ - Name: ` NPM_TOKEN `
25
+ - Value: Your npm access token
26
+
27
+ ### 2. Local Publishing (Manual)
12
28
13
29
If you want to publish manually:
14
30
@@ -22,45 +38,142 @@ If you want to publish manually:
22
38
cd dist/ngx-angular-query-builder
23
39
```
24
40
25
- 3 . ** Login to GitHub Package Registry :**
41
+ 3 . ** Login to npm :**
26
42
``` bash
27
- npm login --registry=https://npm.pkg.github.com
43
+ npm login
28
44
```
29
- - Username: Your GitHub username (lowercase)
30
- - Password: Your GitHub Personal Access Token (classic)
45
+ - Username: Your npm username
46
+ - Password: Your npm password
47
+ - Email: Your npm email
48
+ - One-time password: If you have 2FA enabled
31
49
32
50
4 . ** Publish:**
33
51
``` bash
34
52
npm publish
35
53
```
36
54
37
- ## Installation for Users
55
+ ### 3. Automated Publishing (Recommended)
56
+
57
+ The project is configured for automated publishing via GitHub Actions.
38
58
39
- Once published, users can install your package by :
59
+ #### Publishing Process :
40
60
41
- 1 . ** Creating ` .npmrc ` in their project:**
61
+ 1 . ** Update version number:**
62
+ ``` bash
63
+ # Update version in projects/ngx-angular-query-builder/package.json
64
+ # For example, change "19.0.0" to "19.0.1"
42
65
```
43
- @YOUR_GITHUB_USERNAME:registry=https://npm.pkg.github.com
44
- //npm.pkg.github.com/:_authToken=THEIR_GITHUB_TOKEN
66
+
67
+ 2 . ** Create a new release:**
68
+ - Go to your GitHub repository
69
+ - Click "Releases" → "Create a new release"
70
+ - Tag version: ` v19.0.1 ` (match your package version)
71
+ - Release title: ` Release v19.0.1 `
72
+ - Describe the changes
73
+ - Click "Publish release"
74
+
75
+ 3 . ** GitHub Actions will automatically:**
76
+ - Install dependencies
77
+ - Build the library
78
+ - Run tests
79
+ - Publish to npm
80
+
81
+ #### Manual Trigger:
82
+ You can also manually trigger the workflow:
83
+ - Go to Actions tab in your GitHub repository
84
+ - Select "Publish to npm" workflow
85
+ - Click "Run workflow"
86
+
87
+ ## Version Management
88
+
89
+ Before publishing a new version:
90
+
91
+ 1 . ** Update the library package.json:**
92
+ ``` json
93
+ // projects/ngx-angular-query-builder/package.json
94
+ {
95
+ "version" : " 19.0.1" // Update this
96
+ }
45
97
```
46
98
47
- 2 . ** Installing the package :**
99
+ 2 . ** Commit and tag :**
48
100
``` bash
49
- npm install @YOUR_GITHUB_USERNAME/ngx-angular-query-builder
101
+ git add .
102
+ git commit -m " Release v19.0.1"
103
+ git tag v19.0.1
104
+ git push origin main --tags
50
105
```
51
106
107
+ ## Installation for Users
108
+
109
+ Once published, users can install your package easily:
110
+
111
+ ``` bash
112
+ npm install @csfloat/ngx-angular-query-builder
113
+ ```
114
+
115
+ No authentication required! 🎉
116
+
52
117
## Troubleshooting
53
118
54
119
### Common Issues:
55
120
56
121
1 . ** Authentication Error:**
57
- - Ensure you are using a GitHub classic access token with ` write:packages ` scope
58
- - Verify the token is not expired
122
+ - Ensure your npm token is valid and has publish permissions
123
+ - Check that the NPM_TOKEN secret is correctly set in GitHub
124
+ - Verify you have access to publish under the ` @csfloat ` organization
125
+
126
+ 2 . ** Organization Access:**
127
+ - You must be a member of the ` @csfloat ` organization on npm
128
+ - The organization must exist on npm
129
+ - Your npm token must have permission to publish to the organization
130
+
131
+ 3 . ** Version Already Published:**
132
+ - You cannot publish the same version twice
133
+ - Increment the version number in package.json
134
+
135
+ 4 . ** Build Errors:**
136
+ - Run ` npm run build-package ` locally to check for issues
137
+ - Ensure all dependencies are correctly specified
138
+
139
+ ### Useful Commands:
140
+
141
+ ``` bash
142
+ # Check what will be published
143
+ cd dist/ngx-angular-query-builder
144
+ npm pack --dry-run
145
+
146
+ # View package info
147
+ npm view @csfloat/ngx-angular-query-builder
148
+
149
+ # List published versions
150
+ npm view @csfloat/ngx-angular-query-builder versions --json
151
+
152
+ # Check if organization exists
153
+ npm org ls @csfloat
154
+ ```
155
+
156
+ ## Security Notes
157
+
158
+ - Never commit npm tokens to your repository
159
+ - Use GitHub secrets for sensitive information
160
+ - Regularly rotate your npm access tokens
161
+ - Consider enabling 2FA on your npm account
162
+
163
+ ## Organization Setup
164
+
165
+ If the ` @csfloat ` organization doesn't exist on npm yet:
166
+
167
+ 1 . ** Create the organization:**
168
+ - Go to [ npmjs.com] ( https://www.npmjs.com/ )
169
+ - Click your profile → "Add Organization"
170
+ - Name: ` csfloat `
171
+ - Choose organization type (free for public packages)
59
172
60
- 2 . ** Package Not Found :**
61
- - Check the package name includes the @ csfloat scope
62
- - Ensure the repository is public and you have access to it
173
+ 2 . ** Add team members :**
174
+ - Invite other CSFloat team members to the organization
175
+ - Set appropriate permissions for each member
63
176
64
- 4 . ** Workflow Failures :**
65
- - Check the Actions tab for detailed error logs
66
- - Ensure GITHUB_TOKEN has sufficient permissions
177
+ 3 . ** Configure organization settings :**
178
+ - Set up organization profile and description
179
+ - Configure package access policies if needed
0 commit comments