Skip to content

Commit 7e1d987

Browse files
committed
chore(docs): augment release process with some lockfile rigour
1 parent 7d609ff commit 7e1d987

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

RELEASE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Steps to cut a release:
44

55
1) Update the CHANGELOG.md file
66
2) Copy Cargo.lock file to releases directory with appropriate version name
7+
* **NOTE:** This project does not have a checked in root Cargo.lock. Since intentional (and generally minimal) dependency changes between releases is preferred, copy the last release's Cargo.lock into the root and start from that, updating as required. This is especially true when different individuals perform releases and have a different local lock state.
8+
* The `./scripts/compare-locks.py` command can be used to check the dependency differences between releases. Once you have a new Cargo.lock for your release, run this to compare it with the old release and carefully note the differences, making sure they are intentional. e.g. `./scripts/compare-locks.py releases/Cargo.lock.v19.0.0 releases/Cargo.lock.v19.0.1`.
79
3) Run `cargo release <level> [--execute]` (replace `<level>` with `major`, `minor`, or `patch`; by default, this is a dry run, add `--execute` to perform the release. If you omit options, cargo release will prompt you interactively.)
810

911
Specifics on how @cryptonemo used to do releases (modify as needed):

scripts/compare-locks.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Compare two Cargo.lock files and show version differences.
4+
5+
This script is useful for reviewing changes between releases, particularly
6+
to ensure that dependency updates are minimal and intentional.
7+
8+
Usage:
9+
python3 scripts/compare-locks.py <old-lock> <new-lock>
10+
11+
Example:
12+
python3 scripts/compare-locks.py releases/Cargo.lock.v19.0.0 releases/Cargo.lock.v19.0.1
13+
"""
14+
15+
import sys
16+
import re
17+
from collections import defaultdict
18+
19+
def parse_lock_file(filepath):
20+
"""Parse a Cargo.lock file and return a dict of package -> version."""
21+
packages = defaultdict(list)
22+
current_pkg = None
23+
current_version = None
24+
25+
with open(filepath, 'r') as f:
26+
for line in f:
27+
line = line.strip()
28+
if line == '[[package]]':
29+
if current_pkg and current_version:
30+
packages[current_pkg].append(current_version)
31+
current_pkg = None
32+
current_version = None
33+
elif line.startswith('name = '):
34+
match = re.search(r'name = "([^"]+)"', line)
35+
if match:
36+
current_pkg = match.group(1)
37+
elif line.startswith('version = '):
38+
match = re.search(r'version = "([^"]+)"', line)
39+
if match:
40+
current_version = match.group(1)
41+
42+
# Don't forget the last package
43+
if current_pkg and current_version:
44+
packages[current_pkg].append(current_version)
45+
46+
return packages
47+
48+
def main():
49+
if len(sys.argv) != 3:
50+
print("Usage: python3 scripts/compare-locks.py <old-lock> <new-lock>")
51+
sys.exit(1)
52+
53+
old_file = sys.argv[1]
54+
new_file = sys.argv[2]
55+
56+
try:
57+
old_pkgs = parse_lock_file(old_file)
58+
new_pkgs = parse_lock_file(new_file)
59+
except FileNotFoundError as e:
60+
print(f"Error: {e}")
61+
sys.exit(1)
62+
63+
print(f"Comparing Cargo.lock files")
64+
print(f" Old: {old_file}")
65+
print(f" New: {new_file}")
66+
print("=" * 60)
67+
print()
68+
69+
# Find changes
70+
all_packages = set(old_pkgs.keys()) | set(new_pkgs.keys())
71+
changes = []
72+
workspace_changes = []
73+
external_changes = []
74+
75+
for pkg in sorted(all_packages):
76+
old_versions = sorted(old_pkgs.get(pkg, []))
77+
new_versions = sorted(new_pkgs.get(pkg, []))
78+
79+
if old_versions != new_versions:
80+
# Package changed
81+
if old_versions and new_versions:
82+
# Updated
83+
if len(old_versions) == 1 and len(new_versions) == 1:
84+
change = f"{pkg}: {old_versions[0]}{new_versions[0]}"
85+
else:
86+
# Multiple versions exist
87+
change = f"{pkg}: {old_versions}{new_versions}"
88+
89+
changes.append(change)
90+
91+
# Categorize
92+
if pkg.startswith(('fil-proofs-', 'filecoin-', 'storage-proofs-')) or pkg in ['fr32', 'sha2raw']:
93+
workspace_changes.append(change)
94+
else:
95+
external_changes.append(change)
96+
elif new_versions:
97+
changes.append(f"{pkg}: (new) {new_versions}")
98+
else:
99+
changes.append(f"{pkg}: {old_versions} (removed)")
100+
101+
if changes:
102+
print("All changes:")
103+
for change in changes:
104+
print(f" • {change}")
105+
print()
106+
107+
if workspace_changes:
108+
print(f"Workspace packages ({len(workspace_changes)}):")
109+
for change in workspace_changes:
110+
print(f" • {change}")
111+
print()
112+
113+
if external_changes:
114+
print(f"External dependencies ({len(external_changes)}):")
115+
for change in external_changes:
116+
print(f" • {change}")
117+
else:
118+
print("External dependencies: No changes (workspace-only update)")
119+
else:
120+
print("No changes detected")
121+
122+
print()
123+
print("=" * 60)
124+
print(f"Summary: {len(changes)} package(s) changed")
125+
126+
# Special check for supraseal-c2
127+
if any('supraseal-c2' in change for change in external_changes):
128+
print("✓ This release includes the supraseal-c2 update")
129+
130+
if __name__ == '__main__':
131+
main()

0 commit comments

Comments
 (0)