Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions .scripts/publish-libs.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
#!/bin/bash

# -------------------------------------------------------------------------------------------------
# This script publishes a crate to crates.io.
#
# Usage:
# ./publish-libs.sh pubky-testnet # Publish pubky-testnet
# ./publish-libs.sh pubky # Publish pubky + npm package
# This script publishes all the crates of the workspace to crates.io.
# -------------------------------------------------------------------------------------------------

set -e # fail the script if any command fails
set -u # fail the script if any variable is not set
set -o pipefail # fail the script if any pipe command fails

# Check arguments
if [ $# -ne 1 ]; then
echo "Error: Crate name required."
echo "Usage: $0 <crate>"
echo ""
echo "Examples:"
echo " $0 pubky-testnet # Publish pubky-testnet"
echo " $0 pubky # Publish pubky + npm package"
# Check if cargo-set-version is installed
if ! cargo --list | grep -q "workspaces"; then
echo "Error: cargo-workspaces is not installed but required."
echo "Please install it first by running:"
echo " cargo install cargo-workspaces"
exit 1
fi

CRATE=$1

# Publish the crate
echo "Publishing $CRATE..."
cargo publish -p "$CRATE"
# Publish all the crates of the workspace to crates.io.
# ws does this in the correct order on how crates are depended on each other.
echo "Publishing all the crates of the workspace to crates.io..."
cargo ws publish --no-git-commit --publish-as-is

# Publish npm package if pubky
if [ "$CRATE" = "pubky" ]; then
echo "Publishing the npm package to npmjs.com..."
(cd pubky-sdk/bindings/js/pkg && npm ci && npm run build && npm publish)
fi
# Publish the npm package to npmjs.com.
echo "Publishing the npm package to npmjs.com..."
(cd pubky-sdk/bindings/js/pkg && npm ci && npm run build && npm publish)

echo "Done"
echo "Done"
69 changes: 27 additions & 42 deletions .scripts/set-version.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/bin/bash

# -------------------------------------------------------------------------------------------------
# This script sets the version of a workspace crate.
#
# Usage:
# ./set-version.sh 0.7.0 pubky-testnet # Set pubky-testnet to 0.7.0
# ./set-version.sh 0.7.0 pubky # Set pubky + npm package
# This script sets the version of all members of the workspace.
# It also updates the inner member dependency versions.
# -------------------------------------------------------------------------------------------------

set -e # fail the script if any command fails
set -u # fail the script if any variable is not set
set -o pipefail # fail the script if any pipe command fails

# Check if the version and crate are provided
if [ $# -ne 2 ]; then
echo "Error: Version and crate name required."
echo "Usage: $0 <version> <crate>"
echo ""
echo "Examples:"
echo " $0 0.7.0 pubky-testnet # Set pubky-testnet to 0.7.0"
echo " $0 0.7.0 pubky # Set pubky + npm package"
# Check if cargo-set-version is installed
if ! cargo --list | grep -q "set-version"; then
echo "Error: cargo-set-version is not installed but required."
echo "Please install it first by running:"
echo " cargo install cargo-set-version"
exit 1
fi


# Check if the version is provided
NEW_VERSION=$1
CRATE=$2
if [ -z "$NEW_VERSION" ]; then
echo "Error: New version not specified."
echo "Usage: $0 <new_version>"
exit 1
fi

# Rough semver format validation
SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z.-]+))?(\+([0-9A-Za-z.-]+))?$"
Expand All @@ -34,38 +34,23 @@ if [[ ! "$NEW_VERSION" =~ $SEMVER_REGEX ]]; then
fi

# Ask for confirmation to update the version
read -p "Are you sure you want to set the version to $NEW_VERSION for $CRATE? (y/N) " -n 1 -r
read -p "Are you sure you want to set the version to $NEW_VERSION? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Version change cancelled."
exit 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Version change cancelled."
exit 1
fi

# Map crate name to directory (pubky crate lives in pubky-sdk dir)
CRATE_DIR="$CRATE"
if [ "$CRATE" = "pubky" ]; then
CRATE_DIR="pubky-sdk"
fi
# Update the pubky-sdk package.json
echo "Updating pubky-sdk package.json version to $NEW_VERSION..."
(cd pubky-sdk/bindings/js/pkg && npm version --no-git-tag-version --allow-same-version "$NEW_VERSION")

# Find the crate's Cargo.toml
MANIFEST_PATH="$CRATE_DIR/Cargo.toml"
if [ ! -f "$MANIFEST_PATH" ]; then
echo "Error: Could not find $MANIFEST_PATH"
exit 1
fi
# Set the version of all rust members of the workspace
# cargo set-version also updates the inner member dependency versions.
echo "Setting the version of all rust members of the workspace to $NEW_VERSION..."
cargo set-version $NEW_VERSION

# Set version for the crate (update first version = "x.x.x" line in [package] section)
echo "Setting $CRATE to $NEW_VERSION..."
# Use portable sed -i syntax (BSD/macOS requires '' argument, GNU/Linux does not)
case "$OSTYPE" in
darwin*) sed -i '' 's/^version = ".*"$/version = "'"$NEW_VERSION"'"/' "$MANIFEST_PATH" ;;
*) sed -i 's/^version = ".*"$/version = "'"$NEW_VERSION"'"/' "$MANIFEST_PATH" ;;
esac

# Update npm package if pubky
if [ "$CRATE" = "pubky" ]; then
echo "Updating npm package version to $NEW_VERSION..."
(cd pubky-sdk/bindings/js/pkg && npm version --no-git-tag-version --allow-same-version "$NEW_VERSION")
fi

echo "Done"
echo Done
54 changes: 37 additions & 17 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,46 @@
- Assign a reviewer. Every PR needs to be reviewed at least once. More reviews are possible on request.
5. Always squash the PR when merging. One commit == one feature/fix.

## Versioning

## Releasing a crate
### Unified Version Policy

1. Bump the crate version: `./.scripts/set-version.sh $VERSION crate-name`
- Example: `./.scripts/set-version.sh 0.7.0 pubky-testnet`
2. **If the crate depends on other workspace crates that changed, update those dependency versions in `Cargo.toml`.**
3. Update the `CHANGELOG.md` with the new version
4. Create and merge a PR with the version bump titled: `chore: crate-name vx.x.x`.
5. Publish the crate: `./.scripts/publish-libs.sh crate-name`
- Example: `./.scripts/publish-libs.sh pubky-testnet`
The following crates are released together on the same version schedule:

**Note:** Dependencies must be published before dependents. For example, if `pubky-homeserver` needs a new version of `pubky-common`, publish `pubky-common` first, then update the version in `pubky-homeserver/Cargo.toml`, then publish `pubky-homeserver`.
- `pubky-sdk`
- `pubky-homeserver`
- `pubky-testnet`
- `pubky-common`

### Releasing pubky-homeserver
**All four crates always share the same version number.** When any of these crates is released, all are released together with the same version.

`pubky-homeserver` is the only crate that needs a GitHub release with binary artifacts (other crates are libraries consumed via crates.io/npm).
This policy exists for **clarity and compatibility guarantees**:

After publishing to crates.io, create a [new Github release](https://github.com/pubky/pubky-core/releases/new):
- Tag: `vx.x.x`
- Title: `vx.x.x`
- Description: Changelog for this release.
- Upload artifacts from the [build-artifacts.yml workflow](./.github/workflows/build-artifacts.yml).
You can find them in [Github Actions](https://github.com/pubky/pubky-core/actions?query=branch%3Amain) for the main commit.
1. **Compatibility assurance**: When `pubky-sdk` and `pubky-homeserver` share the same version (e.g., both at `0.6.0`), users know they are compatible and jointly tested. There's no guesswork about which SDK version works with which homeserver.

2. **Testing clarity**: As a developer, your production code uses `pubky::Client` and your tests use `pubky_testnet::Testnet`. When both are at `0.7.0`, you know your tests exercise the exact same client behavior you'll get in production.

### What If Only One Crate Needs Changes?

If a change affects only one crate (e.g., a testnet-only feature), we still release all crates together:

- **Minor changes**: Wait to bundle with other changes, or release all crates with the patch bump.
- **Urgent changes**: Consider a pre-release version like `0.6.1-rc.1` if you absolutely cannot wait. This signals "this is not a full release" while keeping versions aligned.

**Do not** release crates independently. The short-term convenience is not worth the long-term confusion it causes for users trying to match compatible versions.

### Release Process

1. Merge all PRs in the main branch that you want to include in the next version.
2. Update versions of all crates and npm package with `./.scripts/set-version.sh $NEW_SEMVER_VERSION`.
3. Create a PR with the title: `chore: vx.x.x`.
4. Let the PR review and squash + merge.
5. Publish crates and npm package.
- Checkout the `main` branch with the new version merged.
- Run `./.scripts/publish-libs.sh`.
6. Create a [new Github release](https://github.com/pubky/pubky-core/releases/new).
- Tag: `vx.x.x`
- Title: `vx.x.x`
- Description: Changelog for the current version.
- Upload the different artifacts created by the [build-artifacts.yml workflow](./.github/workflows/build-artifacts.yml).
You can find them in [Github Actions](https://github.com/pubky/pubky-core/actions?query=branch%3Amain) for the new main commit.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ anyhow.workspace = true
base64 = "0.22.1"
clap = { version = "4.5.48", features = ["derive"] }
pubky = { path = "../../pubky-sdk", version = "0.6.0" }
pubky-testnet = { path = "../../pubky-testnet", version = "0.7.2" }
pubky-testnet = { path = "../../pubky-testnet", version = "0.6.0" }
pubky-common = { path = "../../pubky-common", version = "0.6.0" }
reqwest.workspace = true
rpassword = "7.4.0"
Expand Down
44 changes: 0 additions & 44 deletions pubky-testnet/CHANGELOG.md

This file was deleted.

20 changes: 10 additions & 10 deletions pubky-testnet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pubky-testnet"
description = "A local test network for Pubky Core development."
version = "0.7.2"
version = "0.6.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -13,11 +13,11 @@ keywords = ["pkarr", "pubky", "testnet", "testing"]
categories = ["web-programming", "authentication", "cryptography"]

[dependencies]
anyhow = "1.0.101"
pkarr-relay = "0.11.4"
tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "signal"] }
tracing-subscriber = "0.3.22"
url = "2.5.8"
anyhow.workspace = true
pkarr-relay = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tracing-subscriber.workspace = true
url.workspace = true

pubky = { path = "../pubky-sdk", version = "0.6.0", features = ["json"] }
pubky-common = { path = "../pubky-common", version = "0.6.0" }
Expand All @@ -27,10 +27,10 @@ pubky-homeserver = { path = "../pubky-homeserver", version = "0.6.0", default-fe
pubky_test_utils = { path = "../test_utils/pubky_test", version = "0.1.0" }
http-relay = { path = "../http-relay", version = "0.5.1" }
tempfile = "3.19.1"
tracing = "0.1.44"
pkarr = { version = "5.0.3", default-features = false, features = ["relays"] }
mainline = "6.1.1"
clap = "4.5.58"
tracing.workspace = true
pkarr = { workspace = true }
mainline = { workspace = true }
clap.workspace = true
dirs = "6.0.0"
once_cell = "1.21.3"
postgresql_embedded = { version = "0.20", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion pubky-testnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For testing without a separate Postgres installation, enable the `embedded-postg

```toml
[dev-dependencies]
pubky-testnet = { version = "0.7", features = ["embedded-postgres"] }
pubky-testnet = { version = "0.6", features = ["embedded-postgres"] }
```

```rust,no_run
Expand Down
Loading