diff --git a/.scripts/publish-libs.sh b/.scripts/publish-libs.sh index 8b216a303..a586bf55d 100755 --- a/.scripts/publish-libs.sh +++ b/.scripts/publish-libs.sh @@ -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 " - 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" \ No newline at end of file diff --git a/.scripts/set-version.sh b/.scripts/set-version.sh index f72176f14..c41373d29 100755 --- a/.scripts/set-version.sh +++ b/.scripts/set-version.sh @@ -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 " - 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 " + exit 1 +fi # Rough semver format validation SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z.-]+))?(\+([0-9A-Za-z.-]+))?$" @@ -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 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3f9bb3fc0..d02803e6c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -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. diff --git a/Cargo.lock b/Cargo.lock index 9bc133cf9..54b3ee9e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4099,7 +4099,7 @@ dependencies = [ [[package]] name = "pubky-testnet" -version = "0.7.2" +version = "0.6.0" dependencies = [ "anyhow", "clap", diff --git a/examples/rust/Cargo.toml b/examples/rust/Cargo.toml index aa97b8e71..2767fe423 100644 --- a/examples/rust/Cargo.toml +++ b/examples/rust/Cargo.toml @@ -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" diff --git a/pubky-testnet/CHANGELOG.md b/pubky-testnet/CHANGELOG.md deleted file mode 100644 index 8befcc66e..000000000 --- a/pubky-testnet/CHANGELOG.md +++ /dev/null @@ -1,44 +0,0 @@ -# Changelog - -All notable changes to the `pubky-testnet` crate will be documented in this file. - -## [0.7.2] - 2026-03-01 - -### Changed - -- Set explicit versions for all workspace dependencies in `Cargo.toml` for better reproducibility when publishing - -## [0.7.1] - 2026-02-27 - -### Changed - -- Set explicit versions for internal pubky dependencies in `Cargo.toml` - -## [0.7.0] - 2026-02-26 - -### Added - -- Embedded Postgres support via `embedded-postgres` feature flag, allowing tests to run without an external Postgres instance -- Unique data directories per embedded Postgres instance to prevent conflicts in parallel test runs - -### Changed - -- Bumped `pkarr`, `mainline`, and `pkarr-relay` dependencies - -### Fixed - -- README instructions for running local cargo tests -- macOS test compatibility - -## [0.6.0] - 2026-01-13 - -### Features - -- **Builder pattern** for `EphemeralTestnet` configuration, enabling custom keypairs, configs, and HTTP relay settings -- **Random keypair generation** option for ephemeral testnets -- **Configurable relay host** for Docker environments -- **Static testnet configuration** support -- Postgres database backend support (replacing LMDB) -- Flexible files backend (Google Bucket, local filesystem, in-memory) -- Optional admin server -- Docker support with configurable ports diff --git a/pubky-testnet/Cargo.toml b/pubky-testnet/Cargo.toml index 1074f2e4e..e495c554c 100644 --- a/pubky-testnet/Cargo.toml +++ b/pubky-testnet/Cargo.toml @@ -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 @@ -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" } @@ -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 } diff --git a/pubky-testnet/README.md b/pubky-testnet/README.md index d8e0fbb3b..a085dc3f1 100644 --- a/pubky-testnet/README.md +++ b/pubky-testnet/README.md @@ -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