From 4b090862ad87046707955d5c3612f3b9a212261b Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Sat, 16 Mar 2024 13:03:35 -0700 Subject: [PATCH] Get set-up for simple deployments --- .github/workflows/deploy-release.yml | 55 +++++++++++++++++++ .../{deploy.yml => deploy-wallet-connect.yml} | 2 +- .../{release.yml => prepare-release.yml} | 6 +- script/deploy-release.sh | 21 ++++++- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy-release.yml rename .github/workflows/{deploy.yml => deploy-wallet-connect.yml} (95%) rename .github/workflows/{release.yml => prepare-release.yml} (77%) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml new file mode 100644 index 0000000..5fcffa3 --- /dev/null +++ b/.github/workflows/deploy-release.yml @@ -0,0 +1,55 @@ +name: Deploy Release + +on: + push: + workflow_dispatch: + inputs: + release: + name: release + description: Release tag (e.g. v0.0.1) + + network: + name: network + options: + - mainnet + - sepolia + - base + - base_sepolia + +env: + FOUNDRY_PROFILE: ci + +permissions: + contents: write + +jobs: + check: + strategy: + fail-fast: true + + name: Foundry project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Deploy Release + run: | + export RPC_URL=$(echo $deployer_config | jq ".$network.rpc_url") + export DEPLOYER_PK=$(echo $deployer_config | jq ".$network.deployer_pk") + script/deploy-release.sh + env: + deployer_config: ${{ secrets.deployer_config }} + network: ${{ inputs.network }} + + - uses: ncipollo/release-action@v1 + with: + artifacts: "release/Sleuth.json,release/Sleuth.sol,release/contracts.json,release/sleuth@*" + bodyFile: "release/RELEASE.md" + allowUpdates: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy-wallet-connect.yml similarity index 95% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy-wallet-connect.yml index ed9c251..9185cd4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy-wallet-connect.yml @@ -1,4 +1,4 @@ -name: Deploy Sleuth [Mainnet] +name: Deploy Sleuth [Mainnet - WalletConnect] on: workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/prepare-release.yml similarity index 77% rename from .github/workflows/release.yml rename to .github/workflows/prepare-release.yml index 1ab2e33..44f27c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/prepare-release.yml @@ -34,10 +34,12 @@ jobs: - name: Prepare Release run: | + export RPC_URL=$(echo $deployer_config | jq ".$network.rpc_url") + export CODE_JAR=$(echo $deployer_config | jq ".$network.code_jar") script/prepare-release.sh env: - CODE_JAR: ${{ vars.CODE_JAR }} - RPC_URL: ${{ vars.SEPOLIA_RPC_URL }} + deployer_config: ${{ secrets.deployer_config }} + network: sepolia - uses: ncipollo/release-action@v1 with: diff --git a/script/deploy-release.sh b/script/deploy-release.sh index 67df9c4..4bf96ff 100755 --- a/script/deploy-release.sh +++ b/script/deploy-release.sh @@ -9,6 +9,24 @@ if [ -z "$tag" ]; then exit 1 fi +opts="" + +if [ -n "$DEPLOYER_PK" ]; then + opts="$opts --private-key $DEPLOYER_PK --broadcast" +fi + +if [ -n "$ETHERSCAN_API_KEY" ]; then + opts="$opts --verify --etherscan-api-key \"$ETHERSCAN_API_KEY\"" +fi + +cleanup() { + rv=$? + rm -rf .release-tmp + exit $rv +} + +trap "cleanup" EXIT + rm -rf .release-tmp mkdir .release-tmp @@ -30,7 +48,6 @@ export CODE_JAR="$(cat ./.release-tmp/contracts.json | jq -r '.codeJar')" forge script \ --rpc-url="$RPC_URL" \ + $opts \ script/Sleuth.s.sol:Deploy \ $@ - -# TODO: Verify