From 748b8236187d529535ddaa6cad326f8022110f93 Mon Sep 17 00:00:00 2001 From: Greg Nazario Date: Thu, 12 May 2022 12:56:55 -0700 Subject: [PATCH] [aptos-cli] Add build script for CLI release and bump CLI version Closes: #946 --- Cargo.lock | 2 +- crates/aptos/Cargo.toml | 2 +- scripts/cli/build_cli_release.sh | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 scripts/cli/build_cli_release.sh diff --git a/Cargo.lock b/Cargo.lock index f947b51b405ea..723286e0c207d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "aptos" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "aptos-config", diff --git a/crates/aptos/Cargo.toml b/crates/aptos/Cargo.toml index 774458236abcf..a7ca19150983d 100644 --- a/crates/aptos/Cargo.toml +++ b/crates/aptos/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aptos" -version = "0.1.0" +version = "0.1.1" authors = ["Aptos Labs "] description = "Aptos tool for management of nodes and interacting with the blockchain" repository = "https://github.com/aptos-labs/aptos-core" diff --git a/scripts/cli/build_cli_release.sh b/scripts/cli/build_cli_release.sh new file mode 100755 index 0000000000000..6fe997dc63fbb --- /dev/null +++ b/scripts/cli/build_cli_release.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (c) Aptos +# SPDX-License-Identifier: Apache-2.0 + +########################################### +# Build and package a release for the CLI # +# # +########################################### + +# Note: This must be run from the root of the aptos-core repository +NAME='aptos-cli' +CRATE_NAME='aptos' +CARGO_PATH="crates/$CRATE_NAME/Cargo.toml" + +# Grab system information +ARCH=`uname -m` +OS=`uname -s` +VERSION=`cat "$CARGO_PATH" | grep "^\w*version =" | sed 's/^.*=[ ]*"//g' | sed 's/".*$//g'` + +if [ "$OS" == "Darwin" ]; then + # Rename Darwin to MacOSX so it's less confusing + OS="MacOSX" +elif [ "$OS" == "Linux" ]; then + # Get linux flavor + OS=`cat /etc/os-release | grep '^NAME=' | sed 's/^.*=//g' | sed 's/"//g'` +fi + +echo "Building release $VERSION of $NAME for $OS-$ARCH" +cargo build -p $CRATE_NAME --release + +EXIT_CODE=$? +if [ "$EXIT_CODE" != "0" ]; then + echo "Build failed with exit code $EXIT_CODE" + exit $EXIT_CODE +fi + +cd target/release/ + +# Compress the CLI +ZIP_NAME="$NAME-$VERSION-$OS-$ARCH.zip" + +echo "Zipping release: $ZIP_NAME" +zip $ZIP_NAME $CRATE_NAME +mv $ZIP_NAME ../.. + +# TODO: Add installation instructions?