Skip to content

Commit 784cae5

Browse files
authored
Merge pull request #6 from bitrefill/chore/npm-publish-0.2-beta
chore: npm beta publish via GitHub Release (0.2.0-beta.0)
2 parents a1db292 + 9a62b35 commit 784cae5

File tree

6 files changed

+69
-7
lines changed

6 files changed

+69
-7
lines changed

.github/RELEASING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Releasing `@bitrefill/cli` to npm
2+
3+
Publishing runs automatically when a **GitHub Release** is published (see [npm-publish.yml](./workflows/npm-publish.yml)).
4+
5+
## Prerelease (e.g. `0.2.0-beta.0`)
6+
7+
1. Merge the version bump on `master` (or your release branch). `package.json` must use a **semver prerelease** (a hyphen in the version, e.g. `0.2.0-beta.0`, `0.2.0-rc.1`).
8+
2. Create and push an annotated tag matching the version:
9+
10+
```bash
11+
git checkout master && git pull
12+
git tag -a v0.2.0-beta.0 -m "v0.2.0-beta.0"
13+
git push origin v0.2.0-beta.0
14+
```
15+
16+
3. On GitHub: **Releases → Draft a new release → Choose tag `v0.2.0-beta.0`** describe changes → check **Set as a pre-release** (optional but recommended) → **Publish release**.
17+
18+
4. The workflow publishes to npm with the **`beta`** dist-tag so `latest` stays on the last stable version. Install with:
19+
20+
```bash
21+
npm install -g @bitrefill/cli@beta
22+
```
23+
24+
## Stable release (e.g. `0.2.0`)
25+
26+
1. Merge `package.json` version **`0.2.0`** (no prerelease suffix) and sync CLI/MCP version strings in `src/` if you still duplicate them.
27+
2. Tag and push:
28+
29+
```bash
30+
git tag -a v0.2.0 -m "v0.2.0"
31+
git push origin v0.2.0
32+
```
33+
34+
3. **Publish release** on GitHub (not marked as pre-release). The workflow publishes as **latest**.
35+
36+
## Requirements
37+
38+
- **npm:** [Trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC) for this repo, or a valid `NPM_TOKEN` if your org uses classic tokens instead.
39+
- **Version:** The tag should match the commit that contains the same `version` in `package.json` as what you intend to ship.

.github/workflows/npm-publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ jobs:
2323
- run: pnpm format
2424
- run: pnpm test
2525
- run: pnpm build
26-
- run: pnpm publish --provenance --access public --no-git-checks
26+
- name: Publish to npm
27+
run: |
28+
VERSION=$(node -p "require('./package.json').version")
29+
if [[ "$VERSION" == *-* ]]; then
30+
echo "Publishing prerelease ${VERSION} with dist-tag beta (npm install @bitrefill/cli@beta)"
31+
pnpm publish --provenance --access public --no-git-checks --tag beta
32+
else
33+
echo "Publishing ${VERSION} as latest"
34+
pnpm publish --provenance --access public --no-git-checks
35+
fi

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ pnpm build # Compile to dist/
159159
pnpm dev -- --help # Run CLI via tsx without building
160160
```
161161

162+
Publishing to npm is triggered by [GitHub Releases](https://github.com/bitrefill/cli/releases); see [.github/RELEASING.md](.github/RELEASING.md).
163+
162164
## Paying
163165

164166
**Flow:** `get-product-details` → pick `product_id` + `package_id``buy-products` with `--cart_items` and `--payment_method`.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitrefill/cli",
3-
"version": "0.1.1",
3+
"version": "0.2.0-beta.0",
44
"description": "Bitrefill - browse, buy, and manage gift cards, mobile top-ups, and eSIMs",
55
"type": "module",
66
"bin": {

src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ async function createMcpClient(
224224
};
225225

226226
if (!useOAuth) {
227-
const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
227+
const c = new Client({
228+
name: 'bitrefill-cli',
229+
version: '0.2.0-beta.0',
230+
});
228231
c.onerror = suppressNoise;
229232
const t = new StreamableHTTPClientTransport(new URL(url));
230233
await c.connect(t);
@@ -234,7 +237,10 @@ async function createMcpClient(
234237
const authProvider = createOAuthProvider(url, formatter);
235238

236239
const tryConnect = async () => {
237-
const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
240+
const c = new Client({
241+
name: 'bitrefill-cli',
242+
version: '0.2.0-beta.0',
243+
});
238244
c.onerror = suppressNoise;
239245
const t = new StreamableHTTPClientTransport(new URL(url), {
240246
authProvider,
@@ -252,7 +258,10 @@ async function createMcpClient(
252258
const code = await waitForCallback();
253259
formatter.info('Authorization code received.');
254260

255-
const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
261+
const c = new Client({
262+
name: 'bitrefill-cli',
263+
version: '0.2.0-beta.0',
264+
});
256265
c.onerror = suppressNoise;
257266
const t = new StreamableHTTPClientTransport(new URL(url), {
258267
authProvider,
@@ -359,7 +368,7 @@ async function main(): Promise<void> {
359368
.description(
360369
'Bitrefill CLI - browse, buy, and manage gift cards, mobile top-ups, and eSIMs.\n\nTerms: https://www.bitrefill.com/terms\nPrivacy: https://www.bitrefill.com/privacy'
361370
)
362-
.version('0.1.1')
371+
.version('0.2.0-beta.0')
363372
.option(
364373
'--api-key <key>',
365374
'Bitrefill API key (overrides BITREFILL_API_KEY env var)'

src/init.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ function resolveInitApiKey(opts: InitOptions): string | undefined {
106106

107107
async function validateApiKey(apiKey: string): Promise<{ tools: Tool[] }> {
108108
const url = `${BASE_MCP_URL}/${apiKey}`;
109-
const client = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
109+
const client = new Client({
110+
name: 'bitrefill-cli',
111+
version: '0.2.0-beta.0',
112+
});
110113
const transport = new StreamableHTTPClientTransport(new URL(url));
111114

112115
try {

0 commit comments

Comments
 (0)