Skip to content

Commit 6d6cbf7

Browse files
committed
feat: support 95% of Hypay + add docs site
1 parent f816d8f commit 6d6cbf7

92 files changed

Lines changed: 47790 additions & 235 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs-deploy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: 'pages'
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0 # Fetch all history for better build performance
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
cache: 'npm'
33+
cache-dependency-path: docs/package-lock.json
34+
35+
- name: Install dependencies
36+
working-directory: ./docs
37+
run: npm ci
38+
39+
- name: Build documentation
40+
working-directory: ./docs
41+
run: npm run build
42+
43+
- name: Setup Pages
44+
uses: actions/configure-pages@v4
45+
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: ./docs/build
50+
51+
deploy:
52+
if: github.ref == 'refs/heads/main'
53+
needs: build
54+
runs-on: ubuntu-latest
55+
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
60+
steps:
61+
- name: Deploy to GitHub Pages
62+
id: deployment
63+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version-file: .nvmrc
21+
registry-url: 'https://npm.pkg.github.com'
2122
- name: Install dependencies
2223
run: npm ci
2324
- name: Build
@@ -28,6 +29,6 @@ jobs:
2829
uses: cycjimmy/semantic-release-action@v4
2930
env:
3031
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3233
GIT_AUTHOR_NAME: 'ci'
3334
GIT_AUTHOR_EMAIL: 'yossisaadi@gmail.com'

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@ lib/
121121
# ESLint cache
122122
.eslintcache
123123

124-
.env
124+
.env
125+
126+
# NPM configuration with tokens
127+
.npmrc

.npmrc.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copy this file to .npmrc and replace with your actual GitHub token
2+
# Get token from: https://github.com/settings/tokens
3+
# Required scopes: read:packages, write:packages
4+
5+
@yosolutions:registry=https://npm.pkg.github.com
6+
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN_HERE

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

PUBLISHING_GUIDE.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# 🚀 Publishing Guide: Multiple Methods
2+
3+
## 🎯 **Method 1: Semantic Release (Recommended)**
4+
5+
Your `release.yml` workflow is now configured for GitHub Packages. Here's how to use it:
6+
7+
### Prerequisites
8+
9+
1. **Commit Message Format**: Use conventional commits for semantic versioning
10+
```bash
11+
feat: add new payment method (creates minor version bump)
12+
fix: resolve validation bug (creates patch version bump)
13+
BREAKING CHANGE: remove deprecated API (creates major version bump)
14+
```
15+
16+
### Steps to Publish
17+
18+
1. **Make your changes and commit with proper format:**
19+
20+
```bash
21+
git add .
22+
git commit -m "feat: add Apple Pay integration"
23+
git push origin main
24+
```
25+
26+
2. **Trigger the release workflow:**
27+
- Go to GitHub → Actions tab
28+
- Click "Release" workflow
29+
- Click "Run workflow" button
30+
- Select "main" branch and click "Run workflow"
31+
32+
3. **What happens automatically:**
33+
- ✅ Builds and tests your package
34+
- ✅ Analyzes commits to determine version bump
35+
- ✅ Updates package.json version
36+
- ✅ Generates CHANGELOG.md
37+
- ✅ Creates GitHub release
38+
- ✅ Publishes to GitHub Packages
39+
- ✅ Commits version changes back to repo
40+
41+
---
42+
43+
## **Method 2: Manual Release**
44+
45+
For quick releases without semantic versioning:
46+
47+
### Steps
48+
49+
1. **Version bump locally:**
50+
51+
```bash
52+
npm version patch # 0.1.0 → 0.1.1
53+
npm version minor # 0.1.1 → 0.2.0
54+
npm version major # 0.2.0 → 1.0.0
55+
```
56+
57+
2. **Set up authentication:**
58+
59+
```bash
60+
# Copy and edit the .npmrc file
61+
cp .npmrc.example .npmrc
62+
# Edit .npmrc and add your GitHub token
63+
```
64+
65+
3. **Build and publish:**
66+
67+
```bash
68+
npm run build
69+
npm test
70+
npm publish
71+
```
72+
73+
4. **Push version tags:**
74+
```bash
75+
git push origin main --tags
76+
```
77+
78+
---
79+
80+
## 🔧 **Method 3: GitHub Actions (Simple)**
81+
82+
Use the existing `publish.yml` workflow:
83+
84+
1. **Create a GitHub release:**
85+
- Go to GitHub → Releases
86+
- Click "Create a new release"
87+
- Create new tag (e.g., `v0.1.1`)
88+
- Add release title and description
89+
- Click "Publish release"
90+
91+
2. **Workflow runs automatically:**
92+
- Triggered by release creation
93+
- Builds, tests, and publishes to GitHub Packages
94+
95+
---
96+
97+
## 📋 **Quick Comparison**
98+
99+
| Method | Best For | Automation Level | Version Control |
100+
| -------------------- | --------------- | ---------------- | --------------- |
101+
| **Semantic Release** | Teams, CI/CD | Fully Automated | Commit-based |
102+
| **Manual** | Quick fixes | Manual | Manual |
103+
| **GitHub Actions** | Simple releases | Semi-automated | Manual |
104+
105+
---
106+
107+
## 🎯 **Recommended Workflow**
108+
109+
### For Regular Development:
110+
111+
```bash
112+
# 1. Make changes
113+
git add .
114+
git commit -m "feat: add query functionality"
115+
git push origin main
116+
117+
# 2. Go to GitHub Actions → Release → Run workflow
118+
# 3. Done! Package automatically published
119+
```
120+
121+
### For Hotfixes:
122+
123+
```bash
124+
# Quick manual release
125+
npm version patch
126+
npm run build && npm publish
127+
git push origin main --tags
128+
```
129+
130+
---
131+
132+
## 🔍 **Verification Steps**
133+
134+
After publishing, verify your package:
135+
136+
1. **Check GitHub Packages:**
137+
- Go to your repository
138+
- Click "Packages" tab
139+
- Verify new version is listed
140+
141+
2. **Test import:**
142+
143+
```typescript
144+
// In your Supabase Edge Function
145+
import { HypClient } from 'hyp-api';
146+
console.log('Package imported successfully!');
147+
```
148+
149+
3. **Check version:**
150+
```bash
151+
# From another project
152+
npm install hyp-api@latest
153+
```
154+
155+
---
156+
157+
## 🚨 **Troubleshooting**
158+
159+
### "Package not found"
160+
161+
- Check GitHub token has `write:packages` permission
162+
- Verify package name matches repo owner: `hyp-api`
163+
164+
### "Authentication failed"
165+
166+
- Ensure `.npmrc` has correct token
167+
- Token must have `repo` scope for private repos
168+
169+
### "Semantic release failed"
170+
171+
- Check commit message format
172+
- Ensure there are new commits since last release
173+
- Verify all tests pass
174+
175+
### "Import map not working in Supabase"
176+
177+
- ESM.sh needs time to index new packages (~5-10 minutes)
178+
- Try direct URL: `https://esm.sh/gh/yossisaadi/hyp-pay@0.1.1/lib/index.js`
179+
180+
---
181+
182+
## 🎉 **Next Steps**
183+
184+
1. **Choose your preferred method** (I recommend Semantic Release)
185+
2. **Make a test change** and commit with conventional format
186+
3. **Run the release workflow**
187+
4. **Update your Supabase import map** with the new version
188+
5. **Test in a simple Edge Function**
189+
190+
Your package is ready for automated publishing! 🚀

0 commit comments

Comments
 (0)