Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Releasing `@bitrefill/cli` to npm

Publishing runs automatically when a **GitHub Release** is published (see [npm-publish.yml](./workflows/npm-publish.yml)).

## Prerelease (e.g. `0.2.0-beta.0`)

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`).
2. Create and push an annotated tag matching the version:

```bash
git checkout master && git pull
git tag -a v0.2.0-beta.0 -m "v0.2.0-beta.0"
git push origin v0.2.0-beta.0
```

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**.

4. The workflow publishes to npm with the **`beta`** dist-tag so `latest` stays on the last stable version. Install with:

```bash
npm install -g @bitrefill/cli@beta
```

## Stable release (e.g. `0.2.0`)

1. Merge `package.json` version **`0.2.0`** (no prerelease suffix) and sync CLI/MCP version strings in `src/` if you still duplicate them.
2. Tag and push:

```bash
git tag -a v0.2.0 -m "v0.2.0"
git push origin v0.2.0
```

3. **Publish release** on GitHub (not marked as pre-release). The workflow publishes as **latest**.

## Requirements

- **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.
- **Version:** The tag should match the commit that contains the same `version` in `package.json` as what you intend to ship.
11 changes: 10 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ jobs:
- run: pnpm format
- run: pnpm test
- run: pnpm build
- run: pnpm publish --provenance --access public --no-git-checks
- name: Publish to npm
run: |
VERSION=$(node -p "require('./package.json').version")
if [[ "$VERSION" == *-* ]]; then
echo "Publishing prerelease ${VERSION} with dist-tag beta (npm install @bitrefill/cli@beta)"
pnpm publish --provenance --access public --no-git-checks --tag beta
else
echo "Publishing ${VERSION} as latest"
pnpm publish --provenance --access public --no-git-checks
fi
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ pnpm build # Compile to dist/
pnpm dev -- --help # Run CLI via tsx without building
```

Publishing to npm is triggered by [GitHub Releases](https://github.com/bitrefill/cli/releases); see [.github/RELEASING.md](.github/RELEASING.md).

## Paying

**Flow:** `get-product-details` → pick `product_id` + `package_id` → `buy-products` with `--cart_items` and `--payment_method`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitrefill/cli",
"version": "0.1.1",
"version": "0.2.0-beta.0",
"description": "Bitrefill - browse, buy, and manage gift cards, mobile top-ups, and eSIMs",
"type": "module",
"bin": {
Expand Down
17 changes: 13 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ async function createMcpClient(
};

if (!useOAuth) {
const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
const c = new Client({
name: 'bitrefill-cli',
version: '0.2.0-beta.0',
});
c.onerror = suppressNoise;
const t = new StreamableHTTPClientTransport(new URL(url));
await c.connect(t);
Expand All @@ -234,7 +237,10 @@ async function createMcpClient(
const authProvider = createOAuthProvider(url, formatter);

const tryConnect = async () => {
const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
const c = new Client({
name: 'bitrefill-cli',
version: '0.2.0-beta.0',
});
c.onerror = suppressNoise;
const t = new StreamableHTTPClientTransport(new URL(url), {
authProvider,
Expand All @@ -252,7 +258,10 @@ async function createMcpClient(
const code = await waitForCallback();
formatter.info('Authorization code received.');

const c = new Client({ name: 'bitrefill-cli', version: '0.1.1' });
const c = new Client({
name: 'bitrefill-cli',
version: '0.2.0-beta.0',
});
c.onerror = suppressNoise;
const t = new StreamableHTTPClientTransport(new URL(url), {
authProvider,
Expand Down Expand Up @@ -359,7 +368,7 @@ async function main(): Promise<void> {
.description(
'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'
)
.version('0.1.1')
.version('0.2.0-beta.0')
.option(
'--api-key <key>',
'Bitrefill API key (overrides BITREFILL_API_KEY env var)'
Expand Down
5 changes: 4 additions & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ function resolveInitApiKey(opts: InitOptions): string | undefined {

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

try {
Expand Down
Loading