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
183 changes: 151 additions & 32 deletions .github/workflows/publish-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ name: Publish TypeScript Client
on:
workflow_dispatch:
inputs:
publish-to-npm:
description: 'Publish to npm registry'
required: true
default: true
type: boolean
create-github-release:
description: 'Create GitHub release'
dry-run:
description: 'Dry run (unchecked will publish to npm, push git tag, and create GitHub release)'
required: true
default: true
type: boolean

permissions:
contents: write
id-token: write
pull-requests: write

concurrency:
group: ts-client-publish
Expand All @@ -37,14 +33,22 @@ jobs:
;;
esac

# Run full test suite before publishing
test:
needs: guard-allowed-branch
uses: ./.github/workflows/test.yml
secrets: inherit

publish:
name: Publish @subscriptions/client package
name: Publish @solana/subscriptions package
runs-on: ubuntu-latest
needs: guard-allowed-branch
needs: [guard-allowed-branch, test]
env:
NPM_CONFIG_PROVENANCE: true

steps:
- uses: actions/checkout@v6
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -65,6 +69,21 @@ jobs:

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -74,30 +93,102 @@ jobs:
cd program && cargo build
cd .. && pnpm run generate-clients

- name: Build TypeScript client
working-directory: clients/typescript
run: pnpm build

- name: Get version
id: version
working-directory: clients/typescript
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing @subscriptions/client v$VERSION"
echo "Publishing version: $VERSION"

- name: Check if prerelease
id: prerelease
run: |
if [[ "${{ steps.version.outputs.version }}" == *"-"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "npm_tag=beta" >> $GITHUB_OUTPUT
echo "Pre-release version detected, using 'beta' npm tag"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "npm_tag=latest" >> $GITHUB_OUTPUT
fi

- name: Build TypeScript client
run: pnpm --filter "@solana/subscriptions" build

- name: Pack tarball
working-directory: clients/typescript
run: |
mkdir -p ../../.npm-pack
pnpm pack --pack-destination ../../.npm-pack
echo ""
echo "Packed tarball:"
ls -la ../../.npm-pack/

- name: 'Guard - Fail if tarball contains workspace: protocol'
run: |
echo "Checking tarball for workspace: protocol..."

for tarball in .npm-pack/*.tgz; do
tar -xzf "$tarball" package/package.json -O > /tmp/pkg.json

if grep -q '"workspace:' /tmp/pkg.json; then
echo "FAIL: ${tarball} contains workspace: dependencies!"
grep '"workspace:' /tmp/pkg.json || true
exit 1
fi
done

echo "All tarballs are clean (no workspace: dependencies)"

- name: Guard - Fail if tarball missing dist/ artifacts
run: |
echo "Checking tarball for dist/ artifacts..."

for tarball in .npm-pack/*.tgz; do
CONTENTS=$(tar -tzf "$tarball")

if ! echo "$CONTENTS" | grep -q "package/dist/index.js"; then
echo "FAIL: ${tarball} is missing dist/index.js!"
exit 1
fi

if ! echo "$CONTENTS" | grep -q "package/dist/index.d.ts"; then
echo "FAIL: ${tarball} is missing dist/index.d.ts!"
exit 1
fi

echo "dist/index.js and dist/index.d.ts present"
done

echo "All tarballs contain required dist/ artifacts"

- name: Publish to npm
run: |
VERSION="${{ steps.version.outputs.version }}"
NPM_TAG="${{ steps.prerelease.outputs.npm_tag }}"
TARBALL=".npm-pack/solana-subscriptions-${VERSION}.tgz"
DRY_RUN="${{ github.event.inputs.dry-run }}"

if [ -f "$TARBALL" ]; then
if [ "$DRY_RUN" == "true" ]; then
echo "DRY RUN: Publishing ${TARBALL} with tag '${NPM_TAG}'..."
npm publish "$TARBALL" --access public --tag "$NPM_TAG" --dry-run
echo "Dry run completed successfully (OIDC auth validated, no package uploaded)"
else
echo "Publishing ${TARBALL} with tag '${NPM_TAG}'..."
npm publish "$TARBALL" --access public --tag "$NPM_TAG"
echo "Published successfully"
fi
else
echo "Tarball not found: ${TARBALL}"
echo "Available tarballs:"
ls -la .npm-pack/ || true
exit 1
fi

- name: Create and push tag
if: ${{ github.event.inputs.dry-run != 'true' }}
run: |
TAG="ts-client-v${{ steps.version.outputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
Expand All @@ -108,21 +199,29 @@ jobs:
fi
git push origin "$TAG" 2>/dev/null || echo "Tag already pushed"

- name: Publish to npm (with provenance)
if: ${{ inputs.publish-to-npm }}
working-directory: clients/typescript
run: pnpm publish --access public --no-git-checks --tag ${{ steps.prerelease.outputs.npm_tag }} --provenance

- name: Create GitHub Release
if: ${{ inputs.create-github-release }}
uses: actions/github-script@v8
if: ${{ github.event.inputs.dry-run != 'true' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tagName = `ts-client-v${{ steps.version.outputs.version }}`;
const releaseName = `TypeScript Client v${{ steps.version.outputs.version }}`;
const version = `${{ steps.version.outputs.version }}`;
const releaseName = `TypeScript Client v${version}`;
const isPrerelease = '${{ steps.prerelease.outputs.is_prerelease }}' === 'true';

const body = [
`## @solana/subscriptions v${version}`,
'',
'### Installation',
'',
'```bash',
'pnpm add @solana/subscriptions',
'```',
'',
`https://www.npmjs.com/package/@solana/subscriptions/v/${version}`,
].join('\n');

try {
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
Expand All @@ -140,20 +239,40 @@ jobs:
repo: context.repo.repo,
tag_name: tagName,
name: releaseName,
body: `Release of @subscriptions/client v${{ steps.version.outputs.version }}\n\n**npm:** https://www.npmjs.com/package/@subscriptions/client/v/${{ steps.version.outputs.version }}`,
body: body.trim(),
draft: false,
prerelease: isPrerelease,
});

console.log(`Created release: ${releaseName}`);

- name: Publish summary
run: |
echo "## @subscriptions/client Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version**: \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Tag**: \`ts-client-v${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.publish-to-npm }}" == "true" ]; then
echo "Published to npm: https://www.npmjs.com/package/@subscriptions/client/v/${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
VERSION="${{ steps.version.outputs.version }}"
NPM_TAG="${{ steps.prerelease.outputs.npm_tag }}"
DRY_RUN="${{ github.event.inputs.dry-run }}"

if [ "$DRY_RUN" == "true" ]; then
cat >> $GITHUB_STEP_SUMMARY << EOF
## TypeScript Client Publish — DRY RUN

**Version**: \`${VERSION}\`
**Package**: \`@solana/subscriptions\`
**npm tag**: \`${NPM_TAG}\`
**Mode**: Dry run (OIDC auth validated, no package uploaded, no tag, no release)

EOF
else
echo "Skipped npm publish" >> $GITHUB_STEP_SUMMARY
cat >> $GITHUB_STEP_SUMMARY << EOF
## TypeScript Client Published

**Version**: \`${VERSION}\`
**Package**: \`@solana/subscriptions\`
**Tag**: \`ts-client-v${VERSION}\`
**npm tag**: \`${NPM_TAG}\`

Published to npm: https://www.npmjs.com/package/@solana/subscriptions/v/${VERSION}
GitHub release: https://github.com/${{ github.repository }}/releases/tag/ts-client-v${VERSION}

EOF
fi
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Audited by Cantina. See [audits/AUDIT_STATUS.md](audits/AUDIT_STATUS.md) for the

- `program/` — Pinocchio program (workspace member `subscriptions`)
- `clients/rust/` — Codama-generated Rust client (`subscriptions-client`)
- `clients/typescript/` — Hand-written SDK wrapping Codama-generated TS (`@subscriptions/client`)
- `clients/typescript/` — Hand-written SDK wrapping Codama-generated TS (`@solana/subscriptions`)
- `webapp/` — Vite + React 19 + Node API demo (faucet, deploy wizard, marketplace)
- `docs/` — Numbered ADRs
- `audits/` — Audit report and AUDIT_STATUS.md
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This repository contains:
- A Rust Solana program built with [Pinocchio](https://github.com/febo/pinocchio)
- IDL generation via [Codama](https://github.com/codama-idl/codama)
- Generated clients via Codama:
- TypeScript client (`@subscriptions/client`) in `clients/typescript`
- TypeScript client (`@solana/subscriptions`) in `clients/typescript`
- Rust client (`subscriptions-client`) in `clients/rust`
- A local demo webapp in `webapp/`
- CI pipeline with build, test, lint, and CU benchmarking
Expand Down Expand Up @@ -188,7 +188,7 @@ Both default to `http://localhost:8899`.

## TypeScript Client SDK

The `@subscriptions/client` package in `clients/typescript` provides a high-level `SubscriptionsClient` class wrapping all program instructions:
The `@solana/subscriptions` package in `clients/typescript` provides a high-level `SubscriptionsClient` class wrapping all program instructions:

| Method | Purpose |
| ----------------------------------------------------------- | -------------------------------------------------------------- |
Expand All @@ -206,11 +206,11 @@ PDA derivation helpers are exported from `pdas.ts`: `getSubscriptionAuthorityPDA
Install and use:

```bash
pnpm add @subscriptions/client
pnpm add @solana/subscriptions
```

```typescript
import { SubscriptionsClient } from '@subscriptions/client';
import { SubscriptionsClient } from '@solana/subscriptions';
```

## Webapp Demo
Expand Down
1 change: 1 addition & 0 deletions apps/web/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions clients/typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# @subscriptions/client
# @solana/subscriptions

TypeScript SDK for the Subscriptions Solana program: token delegation, recurring payments, and subscriptions.
TypeScript SDK for the [Subscriptions Solana program](https://github.com/solana-program/subscriptions): token delegation, recurring payments, and subscriptions. Ships as a [`@solana/kit`](https://github.com/anza-xyz/kit) plugin.

**Source & issues:** https://github.com/solana-program/subscriptions

## Installation

```bash
npm install @subscriptions/client
npm install @solana/subscriptions
```

## Quick Start
Expand All @@ -16,7 +18,7 @@ The SDK exports a `subscriptionsProgram()` Kit plugin. The plugin derives progra
import { address, createClient } from '@solana/kit';
import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
import { signer } from '@solana/kit-plugin-signer';
import { subscriptionsProgram } from '@subscriptions/client';
import { subscriptionsProgram } from '@solana/subscriptions';

const client = createClient()
.use(signer(walletSigner))
Expand Down
21 changes: 20 additions & 1 deletion clients/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
{
"name": "@subscriptions/client",
"name": "@solana/subscriptions",
"version": "0.1.0",
"description": "TypeScript SDK and @solana/kit plugin for the Subscriptions Solana program: token delegations, recurring payments, and subscription plans.",
"type": "module",
"license": "MIT",
"homepage": "https://github.com/solana-program/subscriptions#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/solana-program/subscriptions.git",
"directory": "clients/typescript"
},
"bugs": {
"url": "https://github.com/solana-program/subscriptions/issues"
},
"keywords": [
"solana",
"solana-kit",
"subscriptions",
"recurring-payments",
"token-delegation",
"pinocchio"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* import { createClient } from '@solana/kit';
* import { signer } from '@solana/kit-plugin-signer';
* import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
* import { subscriptionsProgram } from '@subscriptions/client';
* import { subscriptionsProgram } from '@solana/subscriptions';
*
* const client = createClient()
* .use(signer(mySigner))
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"excludeInternal": true,
"excludeExternals": true,
"readme": "none",
"name": "@subscriptions/client"
"name": "@solana/subscriptions"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"format:check": "prettier --check .",
"generate-idl": "cd program && GENERATE_IDL=1 cargo check",
"generate-clients": "tsx ./scripts/generate-clients.ts",
"lint": "pnpm run generate-clients && pnpm --filter @subscriptions/client build && eslint .",
"lint:fix": "pnpm run generate-clients && pnpm --filter @subscriptions/client build && eslint . --fix"
"lint": "pnpm run generate-clients && pnpm --filter @solana/subscriptions build && eslint .",
"lint:fix": "pnpm run generate-clients && pnpm --filter @solana/subscriptions build && eslint . --fix"
},
"devDependencies": {
"@codama/nodes-from-anchor": "^1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading