Skip to content

Commit 31f7ae3

Browse files
authored
fix: make the 0.1.0 release publishable (#16)
1 parent 20fa68a commit 31f7ae3

9 files changed

Lines changed: 24 additions & 83 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ All notable changes to this project will be documented in this file.
4040

4141
### Bug fixes
4242

43+
* Package and verify the unpublished main and derive crates together so a new release does not require its derive version to exist on crates.io first.
4344
* Preserve qualified Serde function paths such as `<T as Trait>::function` as parseable Rust token streams.
4445
* Match Serde's fixed-array coverage and bounds: lengths above 32 no longer claim shape support, while zero-length arrays no longer require their unobserved element type to implement a shape trait, including inside derived generic containers.
4546
* Match Serde's deserialization bounds for tree and hash collections so a shape implementation is exposed only when the corresponding collection can actually deserialize.
@@ -52,6 +53,7 @@ All notable changes to this project will be documented in this file.
5253

5354
### Improvements
5455

56+
* Clarify that shape derives and `serde_shape` attributes provide reflection metadata without implementing or changing Serde's runtime traits.
5557
* Point README and crate-level installation examples at the upcoming `0.1.0` release.
5658
* State the graph-local `ShapeId` ownership contract accurately instead of claiming that lookups can detect an in-bounds id copied from another graph.
5759
* Add `definition_for` to both graph types so walkers can resolve a `ShapeRef::Definition` without repeating a match and id lookup.

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ rust-version = "1.85.0"
3333

3434
[workspace.dependencies]
3535
# workspace dependencies
36-
serde-shape = { version = "0.0.1", path = "serde-shape" }
37-
serde-shape-derive = { version = "=0.0.1", path = "serde-shape-derive" }
36+
serde-shape = { version = "0.1.0", path = "serde-shape" }
37+
serde-shape-derive = { version = "=0.1.0", path = "serde-shape-derive" }
3838

3939
# crates.io dependencies
4040
clap = { version = "4.6.1" }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Enable `std` when your reflected types use shapes provided only by the Rust stan
3636
serde-shape = { version = "0.1.0", features = ["derive", "std"] }
3737
```
3838

39+
The shape derives are independent of Serde's `Serialize` and `Deserialize` derives: they neither implement nor require those traits. Derive both sets when a type must also perform actual serialization or deserialization. Likewise, `serde_shape` attributes describe reflection metadata only and do not change Serde's runtime behavior.
40+
3941
## Motivation
4042

4143
Use `serde-shape` when Serde already defines the contract you care about, but you also need to inspect that contract as data.

serde-shape-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "serde-shape-derive"
17-
version = "0.0.1"
17+
version = "0.1.0"
1818

1919
categories = ["development-tools", "encoding"]
2020
description = "Procedural macro implementation for the serde-shape crate."

serde-shape/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "serde-shape"
17-
version = "0.0.1"
17+
version = "0.1.0"
1818

1919
categories = ["development-tools", "encoding"]
2020
description = "Build inspectable graphs of Serde serialization and deserialization shapes."

serde-shape/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
//! ```
4242
//!
4343
//! The crate is `no_std` by default and requires `alloc`.
44+
//! The shape derives are independent of Serde's `Serialize` and `Deserialize` derives: they
45+
//! neither implement nor require those traits. Derive both sets when a type must also perform
46+
//! actual serialization or deserialization. `serde_shape` attributes affect reflection metadata
47+
//! only; they do not change Serde's runtime behavior.
4448
//!
4549
//! # Quick start
4650
//!

xtask/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ release = false
2626

2727
[dependencies]
2828
clap = { workspace = true, features = ["derive"] }
29-
serde_json = { workspace = true }
3029
which = { workspace = true }
3130

3231
[lints]

xtask/src/main.rs

Lines changed: 10 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::fs;
1615
use std::path::Path;
1716
use std::process::Command as StdCommand;
1817

@@ -73,16 +72,7 @@ struct CommandPackage {
7372

7473
impl CommandPackage {
7574
fn run(self) {
76-
let main_version = package_version("serde-shape");
77-
let derive_version = package_version("serde-shape-derive");
78-
79-
run_command(make_package_cmd("serde-shape-derive", self.locked));
80-
81-
// Cargo would otherwise verify main against an already-published derive crate with the
82-
// same version. Unpack the archive and patch the two packaged crates together instead.
83-
run_command(make_package_archive_cmd("serde-shape", self.locked));
84-
unpack_package_archive("serde-shape", &main_version);
85-
run_command(make_verify_main_package_cmd(&main_version, &derive_version));
75+
run_command(make_package_cmd(self.locked));
8676
}
8777
}
8878

@@ -182,77 +172,22 @@ fn make_build_cmd(locked: bool) -> StdCommand {
182172
cmd
183173
}
184174

185-
fn make_package_cmd(package: &str, locked: bool) -> StdCommand {
175+
fn make_package_cmd(locked: bool) -> StdCommand {
186176
let mut cmd = find_command("cargo");
187-
cmd.args(["package", "--package", package, "--all-features"]);
177+
cmd.args([
178+
"package",
179+
"--package",
180+
"serde-shape-derive",
181+
"--package",
182+
"serde-shape",
183+
"--all-features",
184+
]);
188185
if locked {
189186
cmd.arg("--locked");
190187
}
191188
cmd
192189
}
193190

194-
fn make_package_archive_cmd(package: &str, locked: bool) -> StdCommand {
195-
let mut cmd = make_package_cmd(package, locked);
196-
cmd.arg("--no-verify");
197-
cmd
198-
}
199-
200-
fn unpack_package_archive(package: &str, version: &str) {
201-
let package_root = workspace_dir().join("target/package");
202-
let package_dir = package_root.join(format!("{package}-{version}"));
203-
if package_dir.exists() {
204-
fs::remove_dir_all(&package_dir).expect("failed to remove stale package directory");
205-
}
206-
207-
let mut cmd = find_command("tar");
208-
cmd.arg("-xzf")
209-
.arg(package_root.join(format!("{package}-{version}.crate")))
210-
.arg("-C")
211-
.arg(package_root);
212-
run_command(cmd);
213-
}
214-
215-
fn make_verify_main_package_cmd(main_version: &str, derive_version: &str) -> StdCommand {
216-
let package_dir = workspace_dir()
217-
.join("target/package")
218-
.join(format!("serde-shape-{main_version}"));
219-
let derive_dir = workspace_dir()
220-
.join("target/package")
221-
.join(format!("serde-shape-derive-{derive_version}"));
222-
let derive_dir = serde_json::to_string(&derive_dir.to_string_lossy()).unwrap();
223-
let patch = format!("patch.crates-io.serde-shape-derive.path={derive_dir}");
224-
225-
let mut cmd = find_command("cargo");
226-
cmd.args(["check", "--manifest-path"])
227-
.arg(package_dir.join("Cargo.toml"))
228-
.args(["--all-features", "--config", &patch]);
229-
cmd
230-
}
231-
232-
fn package_version(package: &str) -> String {
233-
let mut cmd = find_command("cargo");
234-
cmd.args(["metadata", "--no-deps", "--format-version", "1"]);
235-
let output = cmd.output().expect("failed to read workspace metadata");
236-
assert!(
237-
output.status.success(),
238-
"cargo metadata failed: {}",
239-
String::from_utf8_lossy(&output.stderr)
240-
);
241-
242-
let metadata: serde_json::Value =
243-
serde_json::from_slice(&output.stdout).expect("cargo metadata should be valid JSON");
244-
metadata["packages"]
245-
.as_array()
246-
.and_then(|packages| {
247-
packages
248-
.iter()
249-
.find(|candidate| candidate["name"] == package)
250-
})
251-
.and_then(|package| package["version"].as_str())
252-
.unwrap_or_else(|| panic!("package {package} not found in cargo metadata"))
253-
.to_owned()
254-
}
255-
256191
fn make_test_cmd(no_capture: bool, package: &str, features: &[&str]) -> StdCommand {
257192
let mut cmd = find_command("cargo");
258193
cmd.args(["test", "-p", package, "--no-default-features"]);

0 commit comments

Comments
 (0)