|
| 1 | +# SDK Release Automation |
| 2 | + |
| 3 | +Release all 5 SDK packages with a synchronized version bump. |
| 4 | + |
| 5 | +**Version to release: $ARGUMENTS** |
| 6 | + |
| 7 | +## Instructions |
| 8 | + |
| 9 | +You are performing an SDK release for the sodax-frontend monorepo. Follow these steps precisely and in order. Stop and report errors at any step rather than continuing. |
| 10 | + |
| 11 | +### Package list |
| 12 | + |
| 13 | +All 5 packages must be updated to the same version: |
| 14 | +- `@sodax/types` — `packages/types/package.json` |
| 15 | +- `@sodax/sdk` — `packages/sdk/package.json` |
| 16 | +- `@sodax/wallet-sdk-core` — `packages/wallet-sdk-core/package.json` |
| 17 | +- `@sodax/wallet-sdk-react` — `packages/wallet-sdk-react/package.json` |
| 18 | +- `@sodax/dapp-kit` — `packages/dapp-kit/package.json` |
| 19 | + |
| 20 | +Additionally, `CONFIG_VERSION` in `packages/types/src/constants/index.ts` must be incremented by 1. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +### Step 0: Parse and validate version |
| 25 | + |
| 26 | +1. Parse the version from: `$ARGUMENTS` |
| 27 | +2. Trim whitespace. If empty, print this usage message and STOP: |
| 28 | + ``` |
| 29 | + Usage: /project:release-sdk <version> |
| 30 | +
|
| 31 | + Examples: |
| 32 | + /project:release-sdk 1.2.5 |
| 33 | + /project:release-sdk 1.2.5-beta |
| 34 | + /project:release-sdk 1.2.5-rc.1 |
| 35 | +
|
| 36 | + The version is applied to all 5 SDK packages. |
| 37 | + Versions containing "rc" are marked as pre-releases on GitHub. |
| 38 | + ``` |
| 39 | +3. Validate the version looks like a valid semver (digits.digits.digits with optional pre-release suffix like `-beta`, `-rc.1`, `-beta-rc1`). If invalid, print an error with the usage examples above and STOP. |
| 40 | +4. Determine if this is a **pre-release**: the version contains `rc` (case-insensitive). Save this as IS_PRERELEASE (true/false). This controls the `--prerelease` flag when creating GitHub releases. |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +### Step 1: Pre-flight safety checks |
| 45 | + |
| 46 | +Run ALL of these checks before making any changes: |
| 47 | + |
| 48 | +1. **gh auth check**: Run `gh auth status`. If not authenticated, tell the user to run `gh auth login` and STOP. |
| 49 | + |
| 50 | +2. **Branch check**: Run `git branch --show-current`. Must be `release/sdk`. If not, ask the user: "You are on branch X. Switch to release/sdk?" If they say yes, run `git checkout release/sdk`. If they decline, STOP. |
| 51 | + |
| 52 | +3. **Clean working tree**: Run `git status --porcelain`. If there is ANY output, show it to the user and say "Working tree must be clean before releasing. Please commit or stash your changes." and STOP. |
| 53 | + |
| 54 | +4. **Fetch latest**: Run `git fetch origin`. |
| 55 | + |
| 56 | +5. **Check main has been merged**: Run `git log release/sdk..origin/main --oneline`. If there are commits, save this fact — a `git pull --no-ff origin main` will be needed in Step 3. Show the user how many commits from main are not yet in release/sdk. |
| 57 | + |
| 58 | +6. **Read current version**: Read `packages/sdk/package.json` and extract the current `"version"` value. Save this as `CURRENT_VERSION`. |
| 59 | + |
| 60 | +7. **Read current CONFIG_VERSION**: Read `packages/types/src/constants/index.ts` and find the line with `CONFIG_VERSION = <number>`. Extract the number. Save as `CURRENT_CONFIG_VERSION`. |
| 61 | + |
| 62 | +8. **Tag conflict check**: Run `git tag -l "@sodax/sdk@$ARGUMENTS"`. If a tag already exists, say "Tag @sodax/sdk@$ARGUMENTS already exists. This version has already been released." and STOP. |
| 63 | + |
| 64 | +9. **Version sanity**: If `$ARGUMENTS` equals `CURRENT_VERSION`, warn "New version is the same as current version" and ask the user to confirm they want to proceed. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +### Step 2: Confirm with user |
| 69 | + |
| 70 | +Present this summary using AskUserQuestion and ask for explicit confirmation: |
| 71 | + |
| 72 | +``` |
| 73 | +SDK Release Plan: |
| 74 | + Current version: {CURRENT_VERSION} |
| 75 | + New version: {$ARGUMENTS} |
| 76 | + CONFIG_VERSION: {CURRENT_CONFIG_VERSION} -> {CURRENT_CONFIG_VERSION + 1} |
| 77 | + Pre-release: {Yes/No based on IS_PRERELEASE} |
| 78 | + Branch: release/sdk |
| 79 | + Main merge needed: {Yes/No based on step 1.5} |
| 80 | +
|
| 81 | + Files to modify: |
| 82 | + - packages/types/package.json |
| 83 | + - packages/sdk/package.json |
| 84 | + - packages/wallet-sdk-core/package.json |
| 85 | + - packages/wallet-sdk-react/package.json |
| 86 | + - packages/dapp-kit/package.json |
| 87 | + - packages/types/src/constants/index.ts |
| 88 | +``` |
| 89 | + |
| 90 | +Options: "Proceed with release" / "Abort" |
| 91 | + |
| 92 | +If they choose Abort, STOP. |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +### Step 3: Merge from main (if needed) |
| 97 | + |
| 98 | +If step 1.5 found commits on main not in release/sdk: |
| 99 | + |
| 100 | +```bash |
| 101 | +git pull --no-ff origin main |
| 102 | +``` |
| 103 | + |
| 104 | +If this results in merge conflicts, tell the user to resolve them manually and STOP. Do not attempt to resolve conflicts automatically. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +### Step 4: Bump versions |
| 109 | + |
| 110 | +Edit these 6 files using the Edit tool. For each package.json, change only the `"version"` field. For the constants file, change only the `CONFIG_VERSION` number. |
| 111 | + |
| 112 | +1. Edit `packages/types/package.json`: change `"version": "{CURRENT_VERSION}"` to `"version": "$ARGUMENTS"` |
| 113 | +2. Edit `packages/sdk/package.json`: change `"version": "{CURRENT_VERSION}"` to `"version": "$ARGUMENTS"` |
| 114 | +3. Edit `packages/wallet-sdk-core/package.json`: change `"version": "{CURRENT_VERSION}"` to `"version": "$ARGUMENTS"` |
| 115 | +4. Edit `packages/wallet-sdk-react/package.json`: change `"version": "{CURRENT_VERSION}"` to `"version": "$ARGUMENTS"` |
| 116 | +5. Edit `packages/dapp-kit/package.json`: change `"version": "{CURRENT_VERSION}"` to `"version": "$ARGUMENTS"` |
| 117 | +6. Edit `packages/types/src/constants/index.ts`: change `CONFIG_VERSION = {CURRENT_CONFIG_VERSION}` to `CONFIG_VERSION = {CURRENT_CONFIG_VERSION + 1}` |
| 118 | + |
| 119 | +After all edits, run `git diff` and show the user the changes to verify correctness. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +### Step 5: Commit |
| 124 | + |
| 125 | +Stage only the 6 changed files and create a commit: |
| 126 | + |
| 127 | +```bash |
| 128 | +git add packages/sdk/package.json packages/dapp-kit/package.json packages/types/package.json packages/wallet-sdk-core/package.json packages/wallet-sdk-react/package.json packages/types/src/constants/index.ts |
| 129 | +git commit -m "chore(sdks): bump versions to $ARGUMENTS" |
| 130 | +``` |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +### Step 6: Push |
| 135 | + |
| 136 | +Ask the user using AskUserQuestion: "Ready to push to origin/release/sdk. This will push the version bump commit (and any merge commits from main). Proceed?" |
| 137 | + |
| 138 | +Options: "Push" / "Abort" |
| 139 | + |
| 140 | +If confirmed: |
| 141 | +```bash |
| 142 | +git push -u origin release/sdk |
| 143 | +``` |
| 144 | + |
| 145 | +If the push fails, report the error and STOP. NEVER force push. |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +### Step 7: Create GitHub releases |
| 150 | + |
| 151 | +Ask the user using AskUserQuestion: "Ready to create 5 GitHub releases. Each tag creation triggers an npm publish CI workflow. Proceed?" |
| 152 | + |
| 153 | +Options: "Create releases" / "Abort" |
| 154 | + |
| 155 | +If confirmed, create releases in dependency order. Use `CURRENT_VERSION` (the version BEFORE the bump) for `--notes-start-tag`. If IS_PRERELEASE is true, add `--prerelease` to each command. |
| 156 | + |
| 157 | +```bash |
| 158 | +gh release create "@sodax/types@$ARGUMENTS" \ |
| 159 | + --repo icon-project/sodax-frontend \ |
| 160 | + --target release/sdk \ |
| 161 | + --title "@sodax/types@$ARGUMENTS" \ |
| 162 | + --generate-notes \ |
| 163 | + --notes-start-tag "@sodax/types@{CURRENT_VERSION}" \ |
| 164 | + [--prerelease] |
| 165 | + |
| 166 | +gh release create "@sodax/sdk@$ARGUMENTS" \ |
| 167 | + --repo icon-project/sodax-frontend \ |
| 168 | + --target release/sdk \ |
| 169 | + --title "@sodax/sdk@$ARGUMENTS" \ |
| 170 | + --generate-notes \ |
| 171 | + --notes-start-tag "@sodax/sdk@{CURRENT_VERSION}" \ |
| 172 | + [--prerelease] |
| 173 | + |
| 174 | +gh release create "@sodax/wallet-sdk-core@$ARGUMENTS" \ |
| 175 | + --repo icon-project/sodax-frontend \ |
| 176 | + --target release/sdk \ |
| 177 | + --title "@sodax/wallet-sdk-core@$ARGUMENTS" \ |
| 178 | + --generate-notes \ |
| 179 | + --notes-start-tag "@sodax/wallet-sdk-core@{CURRENT_VERSION}" \ |
| 180 | + [--prerelease] |
| 181 | + |
| 182 | +gh release create "@sodax/wallet-sdk-react@$ARGUMENTS" \ |
| 183 | + --repo icon-project/sodax-frontend \ |
| 184 | + --target release/sdk \ |
| 185 | + --title "@sodax/wallet-sdk-react@$ARGUMENTS" \ |
| 186 | + --generate-notes \ |
| 187 | + --notes-start-tag "@sodax/wallet-sdk-react@{CURRENT_VERSION}" \ |
| 188 | + [--prerelease] |
| 189 | + |
| 190 | +gh release create "@sodax/dapp-kit@$ARGUMENTS" \ |
| 191 | + --repo icon-project/sodax-frontend \ |
| 192 | + --target release/sdk \ |
| 193 | + --title "@sodax/dapp-kit@$ARGUMENTS" \ |
| 194 | + --generate-notes \ |
| 195 | + --notes-start-tag "@sodax/dapp-kit@{CURRENT_VERSION}" \ |
| 196 | + [--prerelease] |
| 197 | +``` |
| 198 | + |
| 199 | +If any release creation fails, report which ones succeeded and which failed. Provide the exact command to retry the failed one(s). Do NOT retry automatically. |
| 200 | + |
| 201 | +--- |
| 202 | + |
| 203 | +### Step 8: Summary |
| 204 | + |
| 205 | +After all releases are created, print: |
| 206 | + |
| 207 | +``` |
| 208 | +Release $ARGUMENTS complete! |
| 209 | +
|
| 210 | +GitHub Releases: |
| 211 | + - https://github.com/icon-project/sodax-frontend/releases/tag/@sodax/types@$ARGUMENTS |
| 212 | + - https://github.com/icon-project/sodax-frontend/releases/tag/@sodax/sdk@$ARGUMENTS |
| 213 | + - https://github.com/icon-project/sodax-frontend/releases/tag/@sodax/wallet-sdk-core@$ARGUMENTS |
| 214 | + - https://github.com/icon-project/sodax-frontend/releases/tag/@sodax/wallet-sdk-react@$ARGUMENTS |
| 215 | + - https://github.com/icon-project/sodax-frontend/releases/tag/@sodax/dapp-kit@$ARGUMENTS |
| 216 | +
|
| 217 | +npm packages (available after CI completes ~3-5 min): |
| 218 | + - https://www.npmjs.com/package/@sodax/types/v/$ARGUMENTS |
| 219 | + - https://www.npmjs.com/package/@sodax/sdk/v/$ARGUMENTS |
| 220 | + - https://www.npmjs.com/package/@sodax/wallet-sdk-core/v/$ARGUMENTS |
| 221 | + - https://www.npmjs.com/package/@sodax/wallet-sdk-react/v/$ARGUMENTS |
| 222 | + - https://www.npmjs.com/package/@sodax/dapp-kit/v/$ARGUMENTS |
| 223 | +
|
| 224 | +CONFIG_VERSION: {CURRENT_CONFIG_VERSION + 1} |
| 225 | +
|
| 226 | +Monitor CI: gh run list --repo icon-project/sodax-frontend --limit 10 |
| 227 | +``` |
| 228 | + |
| 229 | +Then remind the user: "Next step: Share release info (npm links + changelog) in Discord channels per packages/RELEASE_INSTRUCTIONS.md (step 8)." |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +## Error recovery notes |
| 234 | + |
| 235 | +- If the process fails **after committing but before pushing**: the commit is local only and can be reset with `git reset HEAD~1`. |
| 236 | +- If the process fails **after pushing but before creating all releases**: re-run the command — it will detect the version is the same as current and you can skip to release creation. |
| 237 | +- If **some releases are created but others fail**: use the exact retry commands printed in the error output. |
| 238 | +- **NEVER** force push, delete tags, or delete releases. |
0 commit comments