Skip to content

Commit

Permalink
Add some useful scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Nov 10, 2021
1 parent 0d090bb commit 79b2936
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"

# these are imported by other packages
ALL_PACKAGES="cw721"

# these are imported by other contracts
BASE_CONTRACTS="cw721-base"
ALL_CONTRACTS="cw721-metadata-onchain"

SLEEP_TIME=30

for pack in $ALL_PACKAGES; do
(
cd "packages/$pack"
echo "Publishing $pack"
cargo publish
)
done

# wait for these to be processed on crates.io
echo "Waiting for publishing all packages"
sleep $SLEEP_TIME

for cont in $BASE_CONTRACTS; do
(
cd "contracts/$cont"
echo "Publishing $cont"
cargo publish
)
done

# wait for these to be processed on crates.io
echo "Waiting for publishing base packages"
sleep $SLEEP_TIME

for cont in $ALL_CONTRACTS; do
(
cd "contracts/$cont"
echo "Publishing $cont"
cargo publish
)
done

echo "Everything is published!"
54 changes: 54 additions & 0 deletions scripts/set_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"

function print_usage() {
echo "Usage: $0 NEW_VERSION"
echo ""
echo "e.g. $0 0.8.0"
}

if [ "$#" -ne 1 ]; then
print_usage
exit 1
fi

# Check repo
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
if [[ "$(realpath "$SCRIPT_DIR/..")" != "$(pwd)" ]]; then
echo "Script must be called from the repo root"
exit 2
fi

# Ensure repo is not dirty
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 3
fi

NEW="$1"
OLD=$(sed -n -e 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/p' packages/cw721/Cargo.toml)
echo "Updating old version $OLD to new version $NEW ..."

FILES_MODIFIED=()

for package_dir in packages/*/; do
CARGO_TOML="$package_dir/Cargo.toml"
sed -i -e "s/version[[:space:]]*=[[:space:]]*\"$OLD\"/version = \"$NEW\"/" "$CARGO_TOML"
FILES_MODIFIED+=("$CARGO_TOML")
done

for contract_dir in contracts/*/; do
CARGO_TOML="$contract_dir/Cargo.toml"
sed -i -e "s/version[[:space:]]*=[[:space:]]*\"$OLD\"/version = \"$NEW\"/" "$CARGO_TOML"
FILES_MODIFIED+=("$CARGO_TOML")
done

cargo build
FILES_MODIFIED+=("Cargo.lock")

echo "Staging ${FILES_MODIFIED[*]} ..."
git add "${FILES_MODIFIED[@]}"
git commit -m "Set version: $NEW"

0 comments on commit 79b2936

Please sign in to comment.