Skip to content

Commit ae59bf5

Browse files
committed
Add GitHub CLI publishing method and script
1 parent 6c2e53b commit ae59bf5

2 files changed

Lines changed: 64 additions & 3 deletions

File tree

PUBLISHING.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,49 @@
22

33
This guide explains how to publish this package to GitHub Packages.
44

5-
## Prerequisites
5+
## Method 1: Using GitHub CLI (Recommended)
6+
7+
If you have the GitHub CLI installed, you can use it to authenticate and publish the package:
8+
9+
1. Make sure you're logged in to GitHub CLI:
10+
```bash
11+
gh auth status
12+
```
13+
14+
2. If not logged in, authenticate:
15+
```bash
16+
gh auth login
17+
```
18+
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
640

741
1. You need a GitHub Personal Access Token (PAT) with the following scopes:
842
- `read:packages`
943
- `write:packages`
1044
- `delete:packages`
1145
- `repo`
1246

13-
## Setup
47+
### Setup
1448

1549
1. Create a `.npmrc` file in your home directory:
1650

@@ -27,7 +61,7 @@ Replace `YOUR_GITHUB_PAT` with your GitHub Personal Access Token.
2761
echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc
2862
```
2963

30-
## Publishing
64+
### Publishing
3165

3266
Once you have set up authentication, you can publish the package:
3367

publish.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Check if GitHub CLI is installed
4+
if ! command -v gh &> /dev/null; then
5+
echo "GitHub CLI is not installed. Please install it first:"
6+
echo "https://cli.github.com/manual/installation"
7+
exit 1
8+
fi
9+
10+
# Check if logged in to GitHub
11+
if ! gh auth status &> /dev/null; then
12+
echo "You are not logged in to GitHub. Please login first:"
13+
gh auth login
14+
fi
15+
16+
# Create temporary .npmrc file with GitHub token
17+
echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc
18+
echo "//npm.pkg.github.com/:_authToken=$(gh auth token)" >> .npmrc
19+
20+
# Publish the package
21+
echo "Publishing package to GitHub Packages..."
22+
npm publish
23+
24+
# Clean up - remove token from .npmrc
25+
echo "@aashari:registry=https://npm.pkg.github.com" > .npmrc
26+
27+
echo "Package published successfully!"

0 commit comments

Comments
 (0)