Skip to content

Commit a3de42b

Browse files
Kazoplclaudiudinu98
andcommitted
chore: prepare v0.1.0 release
- Bump versions to 0.1.0 - Update package metadata - Add publishing documentation - Final cleanup and formatting Co-authored-by: Claudiu Dinu <claudiudinu1711@gmail.com>
1 parent 936f52b commit a3de42b

2 files changed

Lines changed: 639 additions & 0 deletions

File tree

docs/PUBLISHING.md

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
# Publishing Guide
2+
3+
This guide explains how to publish all MPC Agent Wallet SDK packages to their registries.
4+
5+
## Package Overview
6+
7+
| Package | Registry | Name | Security |
8+
|---------|----------|------|----------|
9+
| Rust Core | crates.io | `mpc-wallet-core` | Token-based |
10+
| Rust Relay | crates.io | `mpc-wallet-relay` | Token-based |
11+
| WASM Bindings | npm | `@mpc-wallet/wasm` | Provenance attestation |
12+
| TypeScript SDK | npm | `@mpc-wallet/sdk` | Provenance attestation |
13+
| Python SDK | PyPI | `mpc-wallet` | Trusted Publishing (OIDC) |
14+
15+
## Rust 2024 Edition
16+
17+
This project uses Rust 2024 edition (stable since Feb 2025 with Rust 1.85.0). Notable features:
18+
- Let chains in `if` and `while` statements
19+
- Better async/await patterns
20+
- Better pattern matching
21+
22+
Make sure you have Rust 1.85+ installed:
23+
```bash
24+
rustup update stable
25+
rustc --version # Should be 1.85.0 or later
26+
```
27+
28+
---
29+
30+
## Trusted Publishing
31+
32+
Trusted Publishing removes the need for long-lived API tokens. It uses OpenID Connect (OIDC) to issue short-lived tokens during CI/CD.
33+
34+
### Why use it
35+
- No API tokens to manage or store in GitHub Secrets
36+
- Short-lived tokens are harder to exploit
37+
- Clear audit trail of who published what
38+
39+
### Registry Support
40+
41+
| Registry | Trusted Publishing | Status |
42+
|----------|-------------------|--------|
43+
| PyPI | Full support | Recommended |
44+
| npm | Provenance attestation | Supported |
45+
| crates.io | Coming July 2025+ | Use token for now |
46+
47+
---
48+
49+
## Automated Publishing with GitHub Actions
50+
51+
### Setup Trusted Publishing for PyPI
52+
53+
1. Go to PyPI, then Your project, then Settings, then Publishing
54+
55+
2. Add a trusted publisher:
56+
- Owner: `Kazopl`
57+
- Repository: `mpc-agent-wallet`
58+
- Workflow: `release.yml`
59+
- Environment: `pypi`
60+
61+
3. Create GitHub environment:
62+
- Go to Repository Settings, then Environments
63+
- Create environment named `pypi`
64+
- Add protection rules if needed
65+
66+
4. No secrets needed. The workflow uses OIDC.
67+
68+
### Required GitHub Secrets
69+
70+
For registries that don't support OIDC yet:
71+
72+
| Secret | Registry | Where to get it |
73+
|--------|----------|-----------------|
74+
| `CARGO_REGISTRY_TOKEN` | crates.io | https://crates.io/settings/tokens |
75+
| `NPM_TOKEN` | npm | https://www.npmjs.com/settings/tokens (Automation type) |
76+
77+
### Trigger a Release
78+
79+
```bash
80+
# 1. Update version numbers
81+
# 2. Update CHANGELOG.md
82+
83+
# 3. Create and push tag
84+
git tag v0.1.0
85+
git push origin v0.1.0
86+
87+
# 4. Create GitHub Release from the tag
88+
# The workflow runs automatically
89+
```
90+
91+
### Manual Trigger (Dry Run)
92+
93+
Go to Actions, then Release, then Run workflow, then enable "Dry run"
94+
95+
---
96+
97+
## Manual Publishing
98+
99+
### Prerequisites
100+
101+
```bash
102+
# Rust 1.85+ for edition 2024
103+
rustup update stable
104+
105+
# crates.io authentication
106+
cargo login
107+
108+
# npm authentication
109+
npm login
110+
111+
# wasm-pack
112+
cargo install wasm-pack --locked
113+
114+
# Python build tools
115+
pip install build twine
116+
```
117+
118+
### Using the Publish Script
119+
120+
```bash
121+
# Dry run to verify without publishing
122+
./scripts/publish.sh --dry-run
123+
124+
# Publish all packages
125+
./scripts/publish.sh
126+
127+
# Publish specific package
128+
./scripts/publish.sh --package core
129+
./scripts/publish.sh --package relay
130+
./scripts/publish.sh --package wasm
131+
./scripts/publish.sh --package sdk
132+
./scripts/publish.sh --package python
133+
134+
# Skip tests
135+
./scripts/publish.sh --skip-tests --dry-run
136+
```
137+
138+
### Manual Step-by-Step
139+
140+
#### 1. Rust Core (mpc-wallet-core)
141+
142+
```bash
143+
cd crates/mpc-wallet-core
144+
145+
# Verify build
146+
cargo build --release
147+
148+
# Dry run
149+
cargo publish --dry-run
150+
151+
# Publish
152+
cargo publish
153+
```
154+
155+
Wait 45 seconds for the crates.io index to update.
156+
157+
#### 2. Rust Relay (mpc-wallet-relay)
158+
159+
```bash
160+
cd crates/mpc-wallet-relay
161+
162+
# Publish (depends on mpc-wallet-core)
163+
cargo publish
164+
```
165+
166+
#### 3. WASM Bindings (@mpc-wallet/wasm)
167+
168+
```bash
169+
cd crates/mpc-wallet-wasm
170+
171+
# Build WASM
172+
wasm-pack build --target web --scope mpc-wallet
173+
174+
cd pkg
175+
176+
# Publish with provenance
177+
npm publish --access public --provenance
178+
```
179+
180+
#### 4. TypeScript SDK (@mpc-wallet/sdk)
181+
182+
```bash
183+
cd packages/mpc-wallet-sdk
184+
185+
npm ci
186+
npm run build
187+
npm publish --access public --provenance
188+
```
189+
190+
#### 5. Python SDK (mpc-wallet)
191+
192+
**Option A: Trusted Publishing (CI only)**
193+
```yaml
194+
# In GitHub Actions with id-token: write permission
195+
- uses: pypa/gh-action-pypi-publish@release/v1
196+
```
197+
198+
**Option B: Token-based (local)**
199+
```bash
200+
cd packages/mpc-wallet-python
201+
python -m build
202+
203+
# Using API token
204+
export TWINE_USERNAME=__token__
205+
export TWINE_PASSWORD=pypi-your-token
206+
twine upload dist/*
207+
```
208+
209+
---
210+
211+
## Version Management
212+
213+
Update versions in all packages:
214+
215+
```bash
216+
# Cargo.toml (workspace)
217+
[workspace.package]
218+
version = "0.2.0"
219+
220+
# packages/mpc-wallet-sdk/package.json
221+
npm version 0.2.0 --no-git-tag-version
222+
223+
# packages/mpc-wallet-python/pyproject.toml
224+
version = "0.2.0"
225+
```
226+
227+
---
228+
229+
## Publishing Order
230+
231+
Packages must be published in this order due to dependencies:
232+
233+
```
234+
mpc-wallet-core <- No dependencies
235+
|
236+
+---+---+
237+
| |
238+
v v
239+
relay wasm <- Both depend on core
240+
|
241+
v
242+
sdk <- Depends on wasm
243+
244+
Python (parallel) <- Independent
245+
```
246+
247+
---
248+
249+
## Pre-publish Checklist
250+
251+
- [ ] All tests pass (`cargo test`, `npm test`, `pytest`)
252+
- [ ] No linting errors (`cargo clippy`, `npm run lint`, `ruff check`)
253+
- [ ] Rust version is 1.85+ for edition 2024
254+
- [ ] Documentation is up to date
255+
- [ ] CHANGELOG.md is updated
256+
- [ ] Version numbers are consistent
257+
- [ ] No uncommitted changes
258+
- [ ] CI is passing on main branch
259+
260+
---
261+
262+
## Troubleshooting
263+
264+
### Rust: "edition 2024 not supported"
265+
```bash
266+
rustup update stable
267+
rustc --version # Should be 1.85.0+
268+
```
269+
270+
### crates.io: "crate version already exists"
271+
Version already published. Bump the version number.
272+
273+
### npm: "E403 Forbidden"
274+
- Check `npm whoami`
275+
- Use `--access public` for scoped packages
276+
- Verify npm token permissions
277+
278+
### PyPI: "Invalid or non-existent authentication"
279+
- For Trusted Publishing: Check OIDC configuration on PyPI
280+
- For token auth: Verify `TWINE_USERNAME=__token__`
281+
282+
### WASM: Build fails
283+
```bash
284+
rustup target add wasm32-unknown-unknown
285+
cargo install wasm-pack --locked --force
286+
```
287+
288+
---
289+
290+
## Post-publish Verification
291+
292+
```bash
293+
# Rust
294+
cargo search mpc-wallet-core
295+
296+
# npm
297+
npm view @mpc-wallet/sdk
298+
npm view @mpc-wallet/wasm
299+
300+
# PyPI
301+
pip index versions mpc-wallet
302+
```
303+
304+
---
305+
306+
## Security
307+
308+
1. Use Trusted Publishing where available (PyPI)
309+
2. Enable npm provenance with `--provenance` flag
310+
3. Use GitHub environments with protection rules
311+
4. Never commit tokens to the repository
312+
5. Rotate tokens periodically for crates.io and npm
313+
6. Enable 2FA on all registry accounts
314+
315+
---
316+
317+
## CI/CD Workflow Reference
318+
319+
The release workflow (`.github/workflows/release.yml`) handles:
320+
321+
```yaml
322+
# Triggered on GitHub Release
323+
on:
324+
release:
325+
types: [published]
326+
327+
# Jobs run in order:
328+
# 1. publish-rust -> crates.io (core then relay)
329+
# 2. publish-wasm -> npm (depends on rust)
330+
# 3. publish-typescript -> npm (depends on wasm)
331+
# 4. publish-python -> PyPI (parallel, uses OIDC)
332+
# 5. release-notes -> Updates GitHub release
333+
```
334+
335+
Key permissions:
336+
```yaml
337+
permissions:
338+
contents: read
339+
id-token: write # Required for OIDC/Trusted Publishing
340+
```

0 commit comments

Comments
 (0)