MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / bump_version

Function bump_version

ci/publish.rs:186–269  ·  view source on GitHub ↗
(krate: &Crate, crates: &[Crate], patch: bool)

Source from the content-addressed store, hash-verified

184}
185
186fn bump_version(krate: &Crate, crates: &[Crate], patch: bool) {
187 let contents = fs::read_to_string(&krate.manifest).unwrap();
188 let next_version = |krate: &Crate| -> String {
189 if CRATES_TO_PUBLISH.contains(&&krate.name[..]) {
190 bump(
191 &krate.version,
192 if patch {
193 BumpKind::Patch
194 } else {
195 BumpKind::Major
196 },
197 )
198 } else {
199 krate.version.clone()
200 }
201 };
202
203 let mut new_manifest = String::new();
204 let mut is_deps = false;
205 let mut is_workspace = false;
206 for line in contents.lines() {
207 let mut rewritten = false;
208 if !is_deps && line.starts_with("version =") {
209 if CRATES_TO_PUBLISH.contains(&&krate.name[..]) {
210 println!(
211 "bump `{}` {} => {}",
212 krate.name,
213 krate.version,
214 next_version(krate),
215 );
216 let new_line = if is_workspace {
217 let ws_version = krate.workspace_version.as_ref().unwrap();
218 let next_version = bump(
219 ws_version,
220 if patch {
221 BumpKind::Patch
222 } else {
223 BumpKind::Major
224 },
225 );
226 line.replace(ws_version, &next_version)
227 } else {
228 line.replace(&krate.version, &next_version(krate))
229 };
230 new_manifest.push_str(&new_line);
231 rewritten = true;
232 }
233 }
234
235 if line.starts_with("[") {
236 is_deps = line.contains("dependencies");
237 is_workspace = line.contains("workspace");
238 }
239
240 for other in crates {
241 // If `other` isn't a published crate then it's not going to get a
242 // bumped version so we don't need to update anything in the
243 // manifest.

Callers 1

mainFunction · 0.85

Calls 1

bumpFunction · 0.85

Tested by

no test coverage detected