Sync rust-toolchain version to current and crate Config.toml's
@@ -155,3 +155,26 @@ namespace :release do
end
end
end
+
+namespace :pkg do
+ desc 'Sync the root rust-toolchain version to all crates'
+ task :'rust_version:sync' do
+ rust_version = File.open('rust-toolchain').read.chomp
+ regexp = /^rust-version = "(.*)"$/
+ next_rust_version = "rust-version = \"#{rust_version}\""
+
+ failures = Dir.glob("#{__dir__}/{,*/}Cargo.toml").map do |file|
+ contents = File.open(file).read
+
+ if (existing_version = contents.match(regexp))
+ File.write(file, contents.gsub(regexp, next_rust_version)) if existing_version != rust_version
+ next
+ end
+
+ puts "Failed to update #{file}, ensure there is a rust-version specified" if Rake.verbose
+ file
+ end.compact
+
+ raise 'Failed to update some rust-versions' if failures.any?
+ end
+end
