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