|
| 1 | +# Release Process |
| 2 | + |
| 3 | +This document explains how to release a new version of `@permify/permify-node` to NPM. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The release process is fully automated using GitHub Actions. When you create a GitHub release, the package is automatically published to NPM. |
| 8 | + |
| 9 | +## How to Release |
| 10 | + |
| 11 | +### 1. Prepare |
| 12 | + |
| 13 | +Make sure everything is ready: |
| 14 | + |
| 15 | +```bash |
| 16 | +# Pull latest changes |
| 17 | +git checkout main |
| 18 | +git pull origin main |
| 19 | + |
| 20 | +# Run tests |
| 21 | +yarn run-test |
| 22 | + |
| 23 | +# Build the project |
| 24 | +yarn build |
| 25 | +``` |
| 26 | + |
| 27 | +### 2. Choose Version Number |
| 28 | + |
| 29 | +Follow [Semantic Versioning](https://semver.org/): |
| 30 | + |
| 31 | +- **MAJOR** (x.0.0) - Breaking changes |
| 32 | +- **MINOR** (0.x.0) - New features (backward compatible) |
| 33 | +- **PATCH** (0.0.x) - Bug fixes |
| 34 | + |
| 35 | +Examples: |
| 36 | +- `1.1.1` → `1.1.2` (bug fix) |
| 37 | +- `1.1.2` → `1.2.0` (new feature) |
| 38 | +- `1.2.0` → `2.0.0` (breaking change) |
| 39 | + |
| 40 | +### 3. Create GitHub Release |
| 41 | + |
| 42 | +1. Go to [Releases](https://github.com/Permify/permify-node/releases) |
| 43 | +2. Click **"Draft a new release"** |
| 44 | +3. Fill in the details: |
| 45 | + - **Tag version**: `v1.2.0` (must start with `v`) |
| 46 | + - **Release title**: `v1.2.0` |
| 47 | + - **Description**: List changes, new features, and bug fixes |
| 48 | +4. Click **"Publish release"** |
| 49 | + |
| 50 | +### 4. Automatic Publishing |
| 51 | + |
| 52 | +Once published, GitHub Actions will: |
| 53 | +- Build the package |
| 54 | +- Extract version from tag (e.g., `v1.2.0` → `1.2.0`) |
| 55 | +- Update `package.json` version |
| 56 | +- Publish to NPM |
| 57 | + |
| 58 | +Track progress at: https://github.com/Permify/permify-node/actions |
| 59 | + |
| 60 | +### 5. Verify |
| 61 | + |
| 62 | +Check that the new version is live: |
| 63 | + |
| 64 | +```bash |
| 65 | +npm view @permify/permify-node version |
| 66 | +``` |
| 67 | + |
| 68 | +## Proto Updates |
| 69 | + |
| 70 | +Proto definitions are automatically synced from [Buf Schema Registry](https://buf.build/permifyco/permify). |
| 71 | + |
| 72 | +### Automatic Updates |
| 73 | + |
| 74 | +The proto workflow runs on every push to `main`: |
| 75 | +- Generates TypeScript code from latest proto definitions |
| 76 | +- Creates a pull request if changes are detected |
| 77 | +- PR branch: `proto-update/permify-latest` |
| 78 | + |
| 79 | +### Manual Update |
| 80 | + |
| 81 | +To manually update protos: |
| 82 | + |
| 83 | +```bash |
| 84 | +yarn buf:generate |
| 85 | +``` |
| 86 | + |
| 87 | +## Configuration |
| 88 | + |
| 89 | +### Required Secrets |
| 90 | + |
| 91 | +Set in GitHub repository settings: |
| 92 | + |
| 93 | +- **NPM_TOKEN**: Authentication token for publishing to NPM |
| 94 | + - Create at [npmjs.com](https://www.npmjs.com/) → Access Tokens |
| 95 | + - Type: **Automation** |
| 96 | + - Permission: **Read and Write** |
| 97 | + |
| 98 | +## Workflows |
| 99 | + |
| 100 | +### 1. Publish Workflow (`.github/workflows/publish.yml`) |
| 101 | + |
| 102 | +**Trigger**: GitHub release published |
| 103 | + |
| 104 | +**Steps**: |
| 105 | +1. Checkout code |
| 106 | +2. Setup Node.js 20 |
| 107 | +3. Install dependencies |
| 108 | +4. Build (`yarn build`) |
| 109 | +5. Update version |
| 110 | +6. Publish to NPM |
| 111 | + |
| 112 | +### 2. Proto Update Workflow (`.github/workflows/protos.yml`) |
| 113 | + |
| 114 | +**Trigger**: Push to `main` or manual dispatch |
| 115 | + |
| 116 | +**Steps**: |
| 117 | +1. Setup Buf CLI |
| 118 | +2. Generate TypeScript code |
| 119 | +3. Create PR if changes detected |
| 120 | + |
| 121 | +## Troubleshooting |
| 122 | + |
| 123 | +### Build Failed |
| 124 | + |
| 125 | +```bash |
| 126 | +# Test locally |
| 127 | +yarn build |
| 128 | +``` |
| 129 | + |
| 130 | +### Publish Failed |
| 131 | + |
| 132 | +- Check if `NPM_TOKEN` is valid |
| 133 | +- Verify version doesn't already exist on NPM |
| 134 | +- Check [Actions logs](https://github.com/Permify/permify-node/actions) |
| 135 | + |
| 136 | +### Wrong Version Published |
| 137 | + |
| 138 | +If you published the wrong version: |
| 139 | + |
| 140 | +1. Delete the GitHub release |
| 141 | +2. Delete the Git tag: |
| 142 | + ```bash |
| 143 | + git tag -d v1.2.0 |
| 144 | + git push origin :refs/tags/v1.2.0 |
| 145 | + ``` |
| 146 | +3. Unpublish from NPM (within 24 hours): |
| 147 | + ```bash |
| 148 | + npm unpublish @permify/permify-node@1.2.0 |
| 149 | + ``` |
| 150 | + |
| 151 | +**Note**: After 24 hours, you cannot unpublish. Release a new patch version instead. |
| 152 | + |
| 153 | +## Release Checklist |
| 154 | + |
| 155 | +Before releasing: |
| 156 | + |
| 157 | +- [ ] All tests pass |
| 158 | +- [ ] Code reviewed and merged |
| 159 | +- [ ] Version number follows semantic versioning |
| 160 | +- [ ] Release notes prepared |
| 161 | +- [ ] Breaking changes documented (if any) |
| 162 | +- [ ] NPM_TOKEN is valid |
| 163 | + |
| 164 | +## Links |
| 165 | + |
| 166 | +- [NPM Package](https://www.npmjs.com/package/@permify/permify-node) |
| 167 | +- [GitHub Repository](https://github.com/Permify/permify-node) |
| 168 | +- [Buf Schema Registry](https://buf.build/permifyco/permify) |
| 169 | + |
0 commit comments