Skip to content

Commit 364cca0

Browse files
committed
ci: configure to publish crate and npm package
1 parent 757ce9f commit 364cca0

3 files changed

Lines changed: 265 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ license = "MIT"
1212
edition = "2024"
1313
rust-version = "1.89"
1414
links = "tauri-plugin-sqlite"
15+
repository = "https://github.com/silvermine/tauri-plugin-sqlite"
16+
homepage = "https://github.com/silvermine/tauri-plugin-sqlite"
17+
documentation = "https://docs.rs/tauri-plugin-sqlite"
18+
keywords = ["tauri", "plugin", "sqlite", "database"]
19+
categories = ["database", "gui"]
20+
readme = "README.md"
21+
include = [
22+
"/src",
23+
"/permissions",
24+
"/build.rs",
25+
"/Cargo.toml",
26+
"/LICENSE",
27+
"/README.md"
28+
]
1529

1630
[dependencies]
1731
tauri = "2.9.3"

PUBLISHING.md

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# Publishing Guide
2+
3+
This guide explains how to publish the `tauri-plugin-sqlite` to both crates.io (Rust) and npm (JavaScript/TypeScript).
4+
5+
## Overview
6+
7+
This Tauri plugin has two primary artifacts that need to be published:
8+
9+
1. **Rust crate** (`tauri-plugin-sqlite`) - Published to [crates.io](https://crates.io)
10+
2. **NPM package** (`@silvermine/tauri-plugin-sqlite`) - Published to [npmjs.com](https://www.npmjs.com)
11+
12+
## Prerequisites
13+
14+
### For Rust (crates.io)
15+
16+
- A [crates.io](https://crates.io) account
17+
- Authentication token configured: `cargo login <your-token>`
18+
- Write permissions to the `tauri-plugin-sqlite` crate (for updates)
19+
20+
### For NPM
21+
22+
- An [npm](https://www.npmjs.com) account
23+
- Authentication configured: `npm login` or `npm adduser`
24+
- Member of the `@silvermine` organization (or owner)
25+
- Write permissions to the `@silvermine/tauri-plugin-sqlite` package (for updates)
26+
27+
## Pre-Publishing Checklist
28+
29+
Before publishing, ensure:
30+
31+
- [ ] All tests pass: `cargo test`
32+
- [ ] Code passes linting: `npm run standards`
33+
- [ ] JavaScript is built: `npm run build`
34+
- [ ] Version numbers are updated in both `Cargo.toml` and `package.json`
35+
- [ ] CHANGELOG is updated with release notes
36+
- [ ] README is up to date
37+
- [ ] All changes are committed to git
38+
39+
## Publishing Steps
40+
41+
### 1. Update Version Numbers
42+
43+
Update the version in both files to match (e.g., `0.2.0`):
44+
45+
#### Cargo.toml
46+
```toml
47+
[package]
48+
version = "0.2.0"
49+
```
50+
51+
#### package.json
52+
```json
53+
{
54+
"version": "0.2.0"
55+
}
56+
```
57+
58+
### 2. Build JavaScript Artifacts
59+
60+
```bash
61+
npm run build
62+
```
63+
64+
This creates the distribution files in `dist-js/`:
65+
- `index.js` (ESM)
66+
- `index.cjs` (CommonJS)
67+
- `index.d.ts` (TypeScript declarations)
68+
69+
And the IIFE bundle:
70+
- `api-iife.js`
71+
72+
### 3. Verify Package Contents
73+
74+
#### Rust Package
75+
76+
```bash
77+
cargo package --list --allow-dirty
78+
```
79+
80+
This should include:
81+
- `src/` - Rust source code
82+
- `permissions/` - Tauri permission definitions
83+
- `build.rs` - Build script
84+
- `Cargo.toml` - Package manifest
85+
- `LICENSE` - MIT license
86+
- `README.md` - Documentation
87+
88+
#### NPM Package
89+
90+
```bash
91+
npm pack --dry-run
92+
```
93+
94+
This should include:
95+
- `dist-js/` - Built JavaScript files
96+
- `permissions/` - Tauri permission definitions
97+
- `LICENSE` - MIT license
98+
- `README.md` - Documentation
99+
- `package.json` - Package manifest
100+
101+
### 4. Test the Packages Locally
102+
103+
#### Test Rust Package
104+
105+
```bash
106+
# Create a test package (doesn't publish)
107+
cargo package --allow-dirty
108+
109+
# The package will be in target/package/tauri-plugin-sqlite-X.Y.Z.crate
110+
# You can test it in another project with:
111+
# cargo add --path /path/to/target/package/tauri-plugin-sqlite-X.Y.Z
112+
```
113+
114+
#### Test NPM Package
115+
116+
```bash
117+
# Create a tarball
118+
npm pack
119+
120+
# This creates: silvermine-tauri-plugin-sqlite-X.Y.Z.tgz
121+
# You can test it in another project with:
122+
# npm install /path/to/silvermine-tauri-plugin-sqlite-X.Y.Z.tgz
123+
```
124+
125+
### 5. Publish to crates.io
126+
127+
```bash
128+
# Publish the Rust crate
129+
cargo publish
130+
```
131+
132+
If you need to do a dry run first:
133+
134+
```bash
135+
cargo publish --dry-run
136+
```
137+
138+
### 6. Publish to npm
139+
140+
```bash
141+
# Publish the NPM package
142+
npm publish --access public
143+
```
144+
145+
**Note**: The `--access public` flag is required for scoped packages (@silvermine).
146+
147+
If you need to do a dry run first:
148+
149+
```bash
150+
npm publish --dry-run
151+
```
152+
153+
### 7. Create a Git Tag
154+
155+
```bash
156+
git tag -a v0.2.0 -m "Release version 0.2.0"
157+
git push origin v0.2.0
158+
```
159+
160+
### 8. Create a GitHub Release
161+
162+
1. Go to the [Releases page](https://github.com/silvermine/tauri-plugin-sqlite/releases)
163+
2. Click "Draft a new release"
164+
3. Select the tag you just created
165+
4. Add release notes (copy from CHANGELOG)
166+
5. Publish the release
167+
168+
## Post-Publishing Verification
169+
170+
After publishing, verify the packages are available:
171+
172+
### Crates.io
173+
174+
Visit: https://crates.io/crates/tauri-plugin-sqlite
175+
176+
Or test installation in a new project:
177+
```bash
178+
cargo add tauri-plugin-sqlite
179+
```
180+
181+
### NPM
182+
183+
Visit: https://www.npmjs.com/package/@silvermine/tauri-plugin-sqlite
184+
185+
Or test installation in a new project:
186+
```bash
187+
npm install @silvermine/tauri-plugin-sqlite
188+
```
189+
190+
## Troubleshooting
191+
192+
### "crate already exists" Error
193+
194+
If you see this error from `cargo publish`, the version you're trying to publish already exists. You cannot overwrite a published version on crates.io. You need to increment the version number.
195+
196+
### "cannot publish package with no version" Error
197+
198+
Make sure the version is set in both `Cargo.toml` and `package.json`.
199+
200+
### "You do not have permission to publish" Error
201+
202+
For crates.io:
203+
- You need to be added as an owner: `cargo owner --add <username> tauri-plugin-sqlite`
204+
205+
For npm:
206+
- You need to be a member of the `@silvermine` organization
207+
- Contact the organization admin
208+
209+
### Package Size Too Large
210+
211+
If you get warnings about package size:
212+
213+
For Rust: Check the `include` field in `Cargo.toml` to ensure you're not including unnecessary files.
214+
215+
For npm: Check the `files` field in `package.json`.
216+
217+
## Version Compatibility
218+
219+
When publishing, consider version compatibility:
220+
221+
- **Rust crate**: Follow [Semantic Versioning](https://semver.org/)
222+
- **NPM package**: Also follows Semantic Versioning
223+
- Keep both versions in sync (same version number)
224+
225+
## Dependencies
226+
227+
Both packages have dependencies that should be kept up to date:
228+
229+
### Rust Dependencies
230+
- `tauri` - Should match the Tauri version your plugin supports
231+
- `sqlx` - Database library version
232+
233+
### NPM Dependencies
234+
- `@tauri-apps/api` - Must be a peer dependency (not bundled)
235+
236+
## Additional Resources
237+
238+
- [Cargo Publishing Guide](https://doc.rust-lang.org/cargo/reference/publishing.html)
239+
- [NPM Publishing Guide](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry)
240+
- [Tauri Plugin Documentation](https://tauri.app/develop/plugins/)

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
"type": "git",
3333
"url": "https://github.com/silvermine/tauri-plugin-sqlite.git"
3434
},
35+
"keywords": [
36+
"tauri",
37+
"plugin",
38+
"sqlite",
39+
"database",
40+
"tauri-plugin"
41+
],
42+
"homepage": "https://github.com/silvermine/tauri-plugin-sqlite#readme",
43+
"bugs": {
44+
"url": "https://github.com/silvermine/tauri-plugin-sqlite/issues"
45+
},
3546
"devDependencies": {
3647
"@rollup/plugin-node-resolve": "16.0.3",
3748
"@rollup/plugin-terser": "0.4.4",

0 commit comments

Comments
 (0)