fix substrate-node-template generation (#2050)

# Description

This PR updates the node-template-release generation binary as well as
the `node-template-release.sh` file so that we can automatically push
updates to the [substrate-node-template
repository](https://github.com/substrate-developer-hub/substrate-node-template).
I assume this part was not updated after the substrate project has been
moved into the polkadot-sdk mono repo.

# Adjustments
- extend the `node-template-release.sh` to support the substrate
child-folder
- update the `SUBSTRATE_GIT_URL`
- fix the Cargo.toml filter (so that it does not include any
non-relevant .toml files)
- set the workspace-edition to 2021

# Note
In order to auto-generate the artifacts [this
line](https://github.com/paritytech/polkadot-sdk/blob/master/.gitlab/pipeline/build.yml#L320C15-L320C15)
needs to be included in the build.yml script again. Since I do not have
access to the (probably) internal gitlab environment I hope that someone
with actual access can introduce that change.
I also do not know how the auto-publish feature works so that would be
another thing to add later on.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Daniel Moos
2023-11-01 20:41:28 +01:00
committed by GitHub
parent 9987bbb1d2
commit 49c0f33bae
2 changed files with 15 additions and 7 deletions
@@ -32,7 +32,7 @@ use tar;
use tempfile;
use toml_edit::{self, value, Array, Item, Table};
const SUBSTRATE_GIT_URL: &str = "https://github.com/paritytech/substrate.git";
const SUBSTRATE_GIT_URL: &str = "https://github.com/paritytech/polkadot-sdk.git";
type CargoToml = toml_edit::Document;
@@ -63,7 +63,7 @@ fn copy_node_template(node_template: &Path, dest_path: &Path) {
/// Find all `Cargo.toml` files in the given path.
fn find_cargo_tomls(path: &PathBuf) -> Vec<PathBuf> {
let path = format!("{}/**/*.toml", path.display());
let path = format!("{}/**/Cargo.toml", path.display());
let glob = glob::glob(&path).expect("Generates globbing pattern");
@@ -196,7 +196,6 @@ fn update_root_cargo_toml(
) {
let mut workspace = Table::new();
workspace.insert("members", value(Array::from_iter(members.iter())));
let mut workspace_dependencies = Table::new();
deps.values()
.flatten()
@@ -212,6 +211,10 @@ fn update_root_cargo_toml(
workspace_dependencies[name]["rev"] = value(commit_id);
});
let mut package = Table::new();
package.insert("edition", value("2021"));
workspace.insert("package", Item::Table(package));
workspace.insert("dependencies", Item::Table(workspace_dependencies));
cargo_toml.insert("workspace", Item::Table(workspace));
@@ -428,9 +431,12 @@ frame-system = { workspace = true }
let expected_toml = r#"[workspace]
members = ["node", "pallets/template", "runtime"]
[workspace.package]
edition = "2021"
[workspace.dependencies]
frame-system = { version = "4.0.0-dev", default-features = true, git = "https://github.com/paritytech/substrate.git", rev = "commit_id" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", rev = "commit_id" }
frame-system = { version = "4.0.0-dev", default-features = true, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "commit_id" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", rev = "commit_id" }
[profile]