|
1 | 1 | # Publishing to GitHub Packages |
2 | 2 |
|
3 | | -This guide explains how to publish this package to GitHub Packages. |
| 3 | +This package is automatically published to GitHub Packages using GitHub Actions. |
4 | 4 |
|
5 | | -## Method 1: Using GitHub CLI (Recommended) |
| 5 | +## Automatic Publishing with GitHub Actions |
6 | 6 |
|
7 | | -If you have the GitHub CLI installed, you can use it to authenticate and publish the package: |
| 7 | +The package is automatically published to GitHub Packages whenever a new GitHub Release is created. The workflow is defined in `.github/workflows/publish.yml`. |
8 | 8 |
|
9 | | -1. Make sure you're logged in to GitHub CLI: |
10 | | -```bash |
11 | | -gh auth status |
12 | | -``` |
| 9 | +### How to Publish a New Version |
13 | 10 |
|
14 | | -2. If not logged in, authenticate: |
15 | | -```bash |
16 | | -gh auth login |
17 | | -``` |
| 11 | +1. Update the version in `package.json` |
| 12 | +2. Commit and push your changes |
| 13 | +3. Create a new tag: |
| 14 | + ```bash |
| 15 | + git tag -a vX.Y.Z -m "Version X.Y.Z" |
| 16 | + git push origin vX.Y.Z |
| 17 | + ``` |
| 18 | +4. Create a new release on GitHub: |
| 19 | + ```bash |
| 20 | + gh release create vX.Y.Z --title "Version X.Y.Z" --notes "Release notes for version X.Y.Z" |
| 21 | + ``` |
18 | 22 |
|
19 | | -3. Create a temporary .npmrc file with your GitHub token: |
20 | | -```bash |
21 | | -echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc |
22 | | -echo "//npm.pkg.github.com/:_authToken=$(gh auth token)" >> .npmrc |
23 | | -``` |
24 | | - |
25 | | -4. Publish the package: |
26 | | -```bash |
27 | | -npm publish |
28 | | -``` |
29 | | - |
30 | | -5. After publishing, you can remove the token from your .npmrc file: |
31 | | -```bash |
32 | | -echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc |
33 | | -``` |
34 | | - |
35 | | -## Method 2: Using Personal Access Token (PAT) |
36 | | - |
37 | | -If you don't have GitHub CLI, you can use a Personal Access Token: |
38 | | - |
39 | | -### Prerequisites |
40 | | - |
41 | | -1. You need a GitHub Personal Access Token (PAT) with the following scopes: |
42 | | - - `read:packages` |
43 | | - - `write:packages` |
44 | | - - `delete:packages` |
45 | | - - `repo` |
46 | | - |
47 | | -### Setup |
48 | | - |
49 | | -1. Create a `.npmrc` file in your home directory: |
50 | | - |
51 | | -```bash |
52 | | -echo "@aashari:registry=https://npm.pkg.github.com" > ~/.npmrc |
53 | | -echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc |
54 | | -``` |
55 | | - |
56 | | -Replace `YOUR_GITHUB_PAT` with your GitHub Personal Access Token. |
57 | | - |
58 | | -2. Create a `.npmrc` file in the project directory: |
59 | | - |
60 | | -```bash |
61 | | -echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc |
62 | | -``` |
63 | | - |
64 | | -### Publishing |
65 | | - |
66 | | -Once you have set up authentication, you can publish the package: |
67 | | - |
68 | | -```bash |
69 | | -npm publish |
70 | | -``` |
| 23 | +The GitHub Actions workflow will automatically build, test, and publish the package to GitHub Packages. |
71 | 24 |
|
72 | 25 | ## Consuming the Package |
73 | 26 |
|
74 | | -To use this package in another project, add the following to your project's `.npmrc` file: |
| 27 | +To use this package in another project: |
75 | 28 |
|
76 | | -``` |
77 | | -@aashari:registry=https://npm.pkg.github.com |
78 | | -//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT |
79 | | -``` |
| 29 | +1. Create a `.npmrc` file in your project with: |
| 30 | + ``` |
| 31 | + @aashari:registry=https://npm.pkg.github.com |
| 32 | + //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN |
| 33 | + ``` |
80 | 34 |
|
81 | | -Then install the package: |
| 35 | +2. Install the package: |
| 36 | + ```bash |
| 37 | + npm install @aashari/nodejs-geocoding |
| 38 | + ``` |
82 | 39 |
|
83 | | -```bash |
84 | | -npm install @aashari/nodejs-geocoding |
85 | | -``` |
| 40 | +Replace `YOUR_GITHUB_TOKEN` with a GitHub Personal Access Token that has the `read:packages` scope. |
0 commit comments