From cfd5b8748916afc32cdcefe687b454937771d6d9 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sat, 24 Feb 2024 11:51:42 +0100 Subject: [PATCH 1/4] :sparkles: Use explicit version --- cli/npm-package/package.json.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/npm-package/package.json.tmpl b/cli/npm-package/package.json.tmpl index 1854036..fb16ca9 100644 --- a/cli/npm-package/package.json.tmpl +++ b/cli/npm-package/package.json.tmpl @@ -1,7 +1,7 @@ { "name": "@magicblock-labs/${node_pkg}", "description": "Bolt CLI tool (${node_pkg})", - "version": "${node_version}", + "version": "0.0.1", "repository": { "type": "git", "url": "git+https://github.com/magicblock-labs/bolt.git" @@ -23,4 +23,4 @@ "access": "public", "registry": "https://registry.npmjs.org/" } -} \ No newline at end of file +} From 5485af7d26dac9eaeb6d61fb99ccf9f2e4977bf3 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sat, 24 Feb 2024 12:02:14 +0100 Subject: [PATCH 2/4] :sparkles: Silent crate add --- cli/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 364a1a1..2523baa 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -175,7 +175,7 @@ fn init( } else { "yarn run jest --preset ts-jest" } - .to_owned(), + .to_owned(), ); } else { cfg.scripts.insert( @@ -185,7 +185,7 @@ fn init( } else { "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" } - .to_owned(), + .to_owned(), ); } @@ -297,8 +297,8 @@ fn init( .arg(format!("programs-ecs/components/{}", component_name)) .arg("--features") .arg("cpi") - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) .spawn() .map_err(|e| { anyhow::format_err!( @@ -580,4 +580,4 @@ fn set_workspace_dir_or_exit() { }; } } -} +} \ No newline at end of file From 7e6fcc4aae702ba361c5ac205f9a56fccf9ca25d Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sat, 24 Feb 2024 12:02:42 +0100 Subject: [PATCH 3/4] :sparkles: Add versions check --- .github/workflows/publish-bolt-crates.yml | 5 +++ .github/workflows/publish-bolt-sdk.yml | 5 +++ .github/workflows/publish-packages.yml | 5 +++ version-align.sh | 55 +++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100755 version-align.sh diff --git a/.github/workflows/publish-bolt-crates.yml b/.github/workflows/publish-bolt-crates.yml index c49aad9..17c4f1a 100644 --- a/.github/workflows/publish-bolt-crates.yml +++ b/.github/workflows/publish-bolt-crates.yml @@ -148,6 +148,11 @@ jobs: echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json + - name: Check versions are aligned + run: | + # Fails if versions are not aligned + ./scripts/version-align.sh --check + - name: run build run: | export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" diff --git a/.github/workflows/publish-bolt-sdk.yml b/.github/workflows/publish-bolt-sdk.yml index fd20186..077e26f 100644 --- a/.github/workflows/publish-bolt-sdk.yml +++ b/.github/workflows/publish-bolt-sdk.yml @@ -148,6 +148,11 @@ jobs: echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json + - name: Check versions are aligned + run: | + # Fails if versions are not aligned + ./scripts/version-align.sh --check + - name: run build run: | export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index dcfec67..4e14c6c 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -89,6 +89,11 @@ jobs: command: build args: --manifest-path=cli/Cargo.toml --no-default-features --release --locked --target ${{ matrix.build.TARGET }} + - name: Check versions are aligned + run: | + # Fails if versions are not aligned + ./scripts/version-align.sh --check + - name: Build the NPM package shell: bash run: | diff --git a/version-align.sh b/version-align.sh new file mode 100755 index 0000000..9f1b2ad --- /dev/null +++ b/version-align.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +# Step 1: Read the version from Cargo.toml +version=$(grep '^version = ' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/') + +if [ -z "$version" ]; then + echo "Version not found in Cargo.toml" + exit 1 +fi + +echo "Aligning for version: $version" + +# GNU/BSD compat +sedi=(-i'') +case "$(uname)" in + # For macOS, use two parameters + Darwin*) sedi=(-i '') +esac + +# Update the version for all crates in the Cargo.toml workspace.dependencies section +sed "${sedi[@]}" "/\[workspace.dependencies\]/,/\## External crates/s/version = \"=.*\"/version = \"=$version\"/" Cargo.toml + +# Update the version in clients/bolt-sdk/package.json +jq --arg version "$version" '.version = $version' clients/bolt-sdk/package.json > temp.json && mv temp.json clients/bolt-sdk/package.json + +# Update the version in cli/npm-package/package.json.tmpl +jq --arg version "$version" '.version = $version' cli/npm-package/package.json.tmpl > temp.json && mv temp.json cli/npm-package/package.json.tmpl + +# Update the main package version and all optionalDependencies versions in cli/npm-package/package.json +jq --arg version "$version" '(.version = $version) | (.optionalDependencies[] = $version)' cli/npm-package/package.json > temp.json && mv temp.json cli/npm-package/package.json + +# Potential for collisions in Cargo.lock, use cargo update to update it +cargo update --workspace + + +# Check if the any changes have been made to the specified files, if running with --check +if [[ "$1" == "--check" ]]; then + files_to_check=( + "clients/bolt-sdk/package.json" + "cli/npm-package/package.json.tmpl" + "cli/npm-package/package.json" + "Cargo.toml" + ) + + for file in "${files_to_check[@]}"; do + # Check if the file has changed from the previous commit + if git diff --name-only | grep -q "$file"; then + echo "Error: version not aligned for $file. Align the version, commit and try again." + exit 1 + fi + done + exit 0 +fi \ No newline at end of file From 431370e296630ff43a273941bee14166769c555d Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sat, 24 Feb 2024 12:10:24 +0100 Subject: [PATCH 4/4] :recycle: Code Refactor --- cli/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 2523baa..3adec67 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -175,7 +175,7 @@ fn init( } else { "yarn run jest --preset ts-jest" } - .to_owned(), + .to_owned(), ); } else { cfg.scripts.insert( @@ -185,7 +185,7 @@ fn init( } else { "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" } - .to_owned(), + .to_owned(), ); } @@ -580,4 +580,4 @@ fn set_workspace_dir_or_exit() { }; } } -} \ No newline at end of file +}