From 471d8f6ff9e658607af664924dffb45a49ff6329 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 25 Oct 2018 12:26:57 -0700 Subject: [PATCH] Fix up the version references to all other internal crates --- Cargo.toml | 6 ++-- ci/buildkite-snap.yml | 3 ++ ci/buildkite.yml | 3 -- ci/publish-crate.sh | 16 ++++++++-- programs/bpf/noop_rust/Cargo.toml | 4 +-- scripts/increment-cargo-version.sh | 48 +++++++++++++++++++----------- 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b66cc59b8..421f4eae4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,9 +109,9 @@ sys-info = "0.5.6" tokio = "0.1" tokio-codec = "0.1" untrusted = "0.6.2" -solana-noop = { path = "programs/native/noop" } -solana-bpfloader = { path = "programs/native/bpf_loader" } -solana-lualoader = { path = "programs/native/lua_loader" } +solana-noop = { path = "programs/native/noop", version = "0.10.0" } +solana-bpfloader = { path = "programs/native/bpf_loader", version = "0.10.0" } +solana-lualoader = { path = "programs/native/lua_loader", version = "0.10.0" } [[bench]] name = "bank" diff --git a/ci/buildkite-snap.yml b/ci/buildkite-snap.yml index 92d75a0b6..81999b53c 100644 --- a/ci/buildkite-snap.yml +++ b/ci/buildkite-snap.yml @@ -5,3 +5,6 @@ steps: - command: "ci/docker-solana/build.sh" timeout_in_minutes: 20 name: "docker-solana" + - command: "ci/publish-crate.sh" + timeout_in_minutes: 20 + name: "publish crate [public]" diff --git a/ci/buildkite.yml b/ci/buildkite.yml index 1782669bd..779d11c9a 100644 --- a/ci/buildkite.yml +++ b/ci/buildkite.yml @@ -36,9 +36,6 @@ steps: timeout_in_minutes: 20 name: "snap [public]" - wait - - command: "ci/publish-crate.sh" - timeout_in_minutes: 20 - name: "publish crate [public]" - trigger: "solana-snap" branches: "!pull/*" async: true diff --git a/ci/publish-crate.sh b/ci/publish-crate.sh index 3dd0832c2..17fb3fd5e 100755 --- a/ci/publish-crate.sh +++ b/ci/publish-crate.sh @@ -12,8 +12,18 @@ if [[ -z "$CRATES_IO_TOKEN" ]]; then exit 1 fi -# TODO: Ensure the published version matches the contents of BUILDKITE_TAG -ci/docker-run.sh rust \ - bash -exc "cargo package; cargo publish --token $CRATES_IO_TOKEN" +maybePublish="echo Publish skipped" +if [[ -n $CI ]]; then + maybePublish="cargo publish --token $CRATES_IO_TOKEN" +fi + +# shellcheck disable=2044 # Disable 'For loops over find output are fragile...' +for Cargo_toml in {common,programs/native/{bpf_loader,lua_loader,noop}}/Cargo.toml; do + # TODO: Ensure the published version matches the contents of BUILDKITE_TAG + ( + set -x + ci/docker-run.sh rust bash -exc "cd $(dirname "$Cargo_toml"); cargo package; $maybePublish" + ) +done exit 0 diff --git a/programs/bpf/noop_rust/Cargo.toml b/programs/bpf/noop_rust/Cargo.toml index 39e045547..55928aa76 100644 --- a/programs/bpf/noop_rust/Cargo.toml +++ b/programs/bpf/noop_rust/Cargo.toml @@ -7,5 +7,5 @@ repository = "https://github.com/solana-labs/solana" license = "Apache-2.0" [dependencies] -rbpf = { git = "https://github.com/qmonnet/rbpf", rev="bc41ec47d9b51751585f6ddcde1d1eb1afe2be69" } -solana = { path = "../../.." } +rbpf = "0.1.0" +solana-sdk = { path = "../../../common", version = "0.10.0" } diff --git a/scripts/increment-cargo-version.sh b/scripts/increment-cargo-version.sh index 1b7019317..dae455b1a 100755 --- a/scripts/increment-cargo-version.sh +++ b/scripts/increment-cargo-version.sh @@ -14,28 +14,40 @@ here="$(dirname "$0")" cd "$here"/.. source ci/semver_bash/semver.sh -readCargoVersion() { - declare Cargo_toml="$1" +readCargoVariable() { + declare variable="$1" + declare Cargo_toml="$2" - while read -r version equals semver _; do - if [[ $version = version && $equals = = ]]; then - echo "${semver//\"/}" + while read -r name equals value _; do + if [[ $name = "$variable" && $equals = = ]]; then + echo "${value//\"/}" return fi done < <(cat "$Cargo_toml") - echo "Unable to locate version in $Cargo_toml" 1>&2 + echo "Unable to locate $variable in $Cargo_toml" 1>&2 } +# shellcheck disable=2044 # Disable 'For loops over find output are fragile...' +Cargo_tomls="$(find . -name Cargo.toml)" + +# Collect the name of all the internal crates +crates=() +for Cargo_toml in $Cargo_tomls; do + crates+=("$(readCargoVariable name "$Cargo_toml")") +done + +# Read the current version MAJOR=0 MINOR=0 PATCH=0 SPECIAL="" -semverParseInto "$(readCargoVersion ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL +semverParseInto "$(readCargoVariable version ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL [[ -n $MAJOR ]] || usage currentVersion="$MAJOR.$MINOR.$PATCH$SPECIAL" SPECIAL="" +# Figure out what to increment case ${1:-minor} in patch) PATCH=$((PATCH + 1)) @@ -57,21 +69,23 @@ esac newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL" -# shellcheck disable=2044 # Disable 'For loops over find output are fragile...' -for Cargo_toml in $(find . -name Cargo.toml); do - # Bump crate version +# Update all the Cargo.toml files +for Cargo_toml in $Cargo_tomls; do + # Set new crate version ( set -x sed -i "$Cargo_toml" -e "s/^version = \"[^\"]*\"$/version = \"$newVersion\"/" ) - # Fix up the internal references to the solana_sdk crate - ( - set -x - sed -i "$Cargo_toml" -e " - s/^solana-sdk.*\(\"[^\"]*common\"\).*\$/solana-sdk = \{ path = \1, version = \"$newVersion\" \}/ - " - ) + # Fix up the version references to other internal crates + for crate in "${crates[@]}"; do + ( + set -x + sed -i "$Cargo_toml" -e " + s/^$crate = .*path = \"\([^\"]*\)\".*\$/$crate = \{ path = \"\1\", version = \"$newVersion\" \}/ + " + ) + done done echo "$currentVersion -> $newVersion"