deploy.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. #
  3. # This script deploys changes to given networks. Usage:
  4. # $ ./deploy.sh <version:vX.Y.Z|latest> <network_a> <network_a> <...>
  5. #
  6. # You need to set the PK environment variable to your private key.
  7. #
  8. # Example: Deploying to some testnet networks
  9. # $ ./deploy.sh latest bnb_testnet fantom_testnet mumbai
  10. #
  11. # Example: Deploying to some mainnet networks
  12. # $ ./deploy.sh v1.4.5 ethereum bnb avalanche
  13. set -euo pipefail
  14. echo "=========== Preparing contracts ==========="
  15. PK=$PK
  16. version="$1"
  17. shift
  18. if [ "$version" = "latest" ]; then
  19. echo "Deploying latest version"
  20. stdoutputdir="$(pwd)/out"
  21. else
  22. # make sure version has format of vX.Y.Z
  23. if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  24. echo "Version must be in format vX.Y.Z"
  25. echo "Usage: $0 <version> <network_a> <network_b> ..."
  26. exit 1
  27. fi
  28. echo "Deploying version $version"
  29. tmpdir=$(mktemp -d)
  30. wget https://github.com/pyth-network/pyth-crosschain/releases/download/pyth-evm-contract-$version/contracts-stdoutput.zip -O $tmpdir/contracts-stdoutput.zip
  31. unzip -q -o $tmpdir/contracts-stdoutput.zip -d $tmpdir
  32. stdoutputdir="$tmpdir"
  33. fi
  34. echo "=========== Building dependencies ==========="
  35. # This command also compiles the contracts if latest version is used
  36. pnpm turbo build --filter @pythnetwork/pyth-evm-contract
  37. echo "=========== Deploying the contracts ==========="
  38. pnpm --filter=@pythnetwork/contract-manager exec tsx scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir $stdoutputdir --private-key $PK --chain "$@"
  39. echo "=========== Cleaning up ==========="
  40. if [ -n "${tmpdir:-}" ]; then
  41. rm -rf $tmpdir
  42. fi
  43. if [ "$version" != "latest" ]; then
  44. echo "Verify the contracts by using the std-input artifacts of the contracts in https://github.com/pyth-network/pyth-crosschain/releases/tag/pyth-evm-contract-$version"
  45. fi