Skip to content

Commit 89d06fd

Browse files
committed
fix: publish rust loro-protocol 0.3.0
1 parent edf4065 commit 89d06fd

12 files changed

Lines changed: 65 additions & 6 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
publish:
3030
needs: release
31-
if: ${{ needs.release.outputs.releases_created }}
31+
if: ${{ needs.release.outputs.releases_created == 'true' || github.event_name == 'workflow_dispatch' }}
3232
runs-on: ubuntu-latest
3333
permissions:
3434
contents: read
@@ -85,3 +85,34 @@ jobs:
8585
# Publish only the unpublished ones in topo order
8686
echo "Publishing: $filters"
8787
pnpm -r $filters publish --access public --no-git-checks
88+
89+
- name: Setup Rust
90+
uses: dtolnay/rust-toolchain@stable
91+
92+
- name: Test Rust loro-protocol crate
93+
working-directory: rust
94+
run: cargo test -p loro-protocol
95+
96+
- name: Publish Rust loro-protocol crate to crates.io
97+
working-directory: rust/loro-protocol
98+
env:
99+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
100+
run: |
101+
set -euo pipefail
102+
name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
103+
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
104+
105+
if curl -fsSL \
106+
-H "User-Agent: loro-dev/protocol release workflow" \
107+
"https://crates.io/api/v1/crates/$name/$version" > /dev/null; then
108+
echo "Already published: $name@$version"
109+
exit 0
110+
fi
111+
112+
if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
113+
echo "CARGO_REGISTRY_TOKEN is required to publish $name@$version"
114+
exit 1
115+
fi
116+
117+
echo "Publishing: $name@$version"
118+
cargo publish

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"packages/loro-adaptors": "0.6.1",
33
"packages/loro-protocol": "0.3.0",
4-
"packages/loro-websocket": "0.6.2"
4+
"packages/loro-websocket": "0.6.2",
5+
"rust/loro-protocol": "0.3.0"
56
}

release-please-config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"packages/loro-protocol": {
1010
"release-type": "node"
1111
},
12+
"rust/loro-protocol": {
13+
"release-type": "rust",
14+
"package-name": "loro-protocol"
15+
},
1216
"packages/loro-websocket": {
1317
"release-type": "node"
1418
},

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/loro-protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "loro-protocol"
3-
version = "0.1.0"
3+
version = "0.3.0"
44
edition = "2021"
55
description = "Rust implementation of the Loro Syncing Protocol encoder/decoder"
66
license = "MIT"

rust/loro-protocol/src/protocol.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub enum CrdtType {
2222
YjsAwareness,
2323
/// "%ELO" (End-to-End Encrypted Loro)
2424
Elo,
25+
/// "%FLO"
26+
Flock,
2527
}
2628

2729
impl CrdtType {
@@ -33,6 +35,7 @@ impl CrdtType {
3335
CrdtType::Yjs => *b"%YJS",
3436
CrdtType::YjsAwareness => *b"%YAW",
3537
CrdtType::Elo => *b"%ELO",
38+
CrdtType::Flock => *b"%FLO",
3639
}
3740
}
3841

@@ -44,6 +47,7 @@ impl CrdtType {
4447
b"%YJS" => Some(CrdtType::Yjs),
4548
b"%YAW" => Some(CrdtType::YjsAwareness),
4649
b"%ELO" => Some(CrdtType::Elo),
50+
b"%FLO" => Some(CrdtType::Flock),
4751
_ => None,
4852
}
4953
}

rust/loro-protocol/tests/js_snapshots.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ fn snapshot_join_request() {
2323
assert_eq!(hex, "0x254c4f5209726f6f6d2d3132333400030a141e0328323c");
2424
}
2525

26+
#[test]
27+
fn snapshot_flock_join_request() {
28+
let msg = ProtocolMessage::JoinRequest {
29+
crdt: CrdtType::Flock,
30+
room_id: "room-1234".to_string(),
31+
auth: vec![10, 20, 30],
32+
version: vec![40, 50, 60],
33+
};
34+
let encoded = encode(&msg).unwrap();
35+
assert_eq!(
36+
to_hex(&encoded),
37+
"0x25464c4f09726f6f6d2d3132333400030a141e0328323c"
38+
);
39+
assert_eq!(decode(&encoded).unwrap(), msg);
40+
}
41+
2642
#[test]
2743
fn snapshot_join_response_read() {
2844
// exports[`encoding snapshots > JoinResponseOk read 1`]

rust/loro-websocket-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ name = "loro_websocket_client"
1414
path = "src/lib.rs"
1515

1616
[dependencies]
17-
loro-protocol = { version = "0.1.0", path = "../loro-protocol" }
17+
loro-protocol = { version = "0.3.0", path = "../loro-protocol" }
1818
tokio = { version = "1", features = ["rt", "macros", "net", "time", "sync"] }
1919
tokio-tungstenite = "0.27"
2020
futures-util = { version = "0.3", default-features = false, features = ["sink"] }

rust/loro-websocket-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ impl Hash for RoomKey {
630630
CrdtType::Yjs => 3,
631631
CrdtType::YjsAwareness => 4,
632632
CrdtType::Elo => 5,
633+
CrdtType::Flock => 6,
633634
};
634635
tag.hash(state);
635636
self.room.hash(state);

rust/loro-websocket-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ name = "loro_websocket_server"
1414
path = "src/lib.rs"
1515

1616
[dependencies]
17-
loro-protocol = { version = "0.1.0", path = "../loro-protocol" }
17+
loro-protocol = { version = "0.3.0", path = "../loro-protocol" }
1818
tokio = { version = "1", features = ["rt", "macros", "net", "sync", "time"] }
1919
tokio-tungstenite = "0.27"
2020
futures-util = { version = "0.3", default-features = false, features = ["sink"] }

0 commit comments

Comments
 (0)