From aaffdc55b2a13738b7c32de96f487d3eb5b4f8c6 Mon Sep 17 00:00:00 2001 From: Federico Giacon <58218759+fedgiac@users.noreply.github.com> Date: Tue, 2 Jan 2024 09:51:11 +0000 Subject: [PATCH] Update readme release/deploy instruction (#70) Our release/deploy process isn't documented correctly in the readme. The automated contract deployment procedure is outdated, has never been used and we don't want to use it in the future as it requires us to store funds in a dedicated secret key just for the purpose of deploying. All related text/code has been removed. The NPM release process wasn't documented. Documentation has been added. ### Test Plan We tested the NPM release process recently with v1.5.0. You can see the related workflow run [here](https://github.com/cowprotocol/contracts/actions/runs/7384026272). --- .github/workflows/deploy.yml | 33 --------------------- README.md | 18 ++++++++---- src/workflows/deploy.sh | 57 ------------------------------------ 3 files changed, 12 insertions(+), 96 deletions(-) delete mode 100644 .github/workflows/deploy.yml delete mode 100644 src/workflows/deploy.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index f465b0f8..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Deploy CoW Protocol contracts - -on: - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 18.x - - run: yarn --frozen-lockfile - - run: yarn build - - run: bash src/workflows/deploy.sh "automated-contract-deployment-${{github.run_number}}" - env: - ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - INFURA_KEY: ${{ secrets.INFURA_KEY }} - PK: ${{ secrets.PK }} - - uses: actions/github-script@v3 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - # https://octokit.github.io/rest.js/v18#pulls-create - script: | - await github.pulls.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: "Contract deployment", - head: "automated-contract-deployment-${{github.run_number}}", - base: "${{github.event.repository.default_branch}}", - body: "Build artifacts from automated contract deployment", - }) diff --git a/README.md b/README.md index f9d91dc4..303e2729 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,6 @@ yarn bench:trace ## Deployment -Contracts deployment (including contract verification) is run automatically with GitHub Actions. The deployment process is triggered manually. -Maintainers of this repository can deploy a new version of the contract in the "Actions" tab, "Deploy CoW Protocol contracts", "Run workflow". The target branch can be selected before running. -A successful workflow results in a new PR asking to merge the deployment artifacts into the main branch. - -Contracts can also be deployed and verified manually as follows. - ### Deploying Contracts Choose the network and gas price in wei for the deployment. @@ -196,3 +190,15 @@ npx hardhat decode --txhash 0xc12e5bc2ef9c116932301495738d555ea1d658977dacd6c798 ``` Note that you will be expected to have your `INFURA_KEY` exported to your environment variables. + +## Releases + +The content of this repo is published on NPM as [`@cowprotocol/contracts`](https://www.npmjs.com/package/@cowprotocol/contracts). + +Maintainers this repository can manually trigger a new release. The steps are as follows: + +1. Update the package version number in `./package.json` on branch `main`. + +2. On GitHub, visit the "Actions" tab, "Publish package to NPM", "Run workflow" with `main` as the target branch. + +Once the workflow has been executed successfully, a new NPM package version should be available as well as a new git tag named after the released version. diff --git a/src/workflows/deploy.sh b/src/workflows/deploy.sh deleted file mode 100644 index f4c94009..00000000 --- a/src/workflows/deploy.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -set -o nounset -set -o pipefail -set -o errexit - -GIT_BRANCH="${1:-""}" - -fail_if_unset () { - VAR_NAME="$1" - if [[ -z "${!VAR_NAME:-""}" ]]; then - printf '%s not set\n' "$VAR_NAME" >&2 - exit 1 - fi -} -gwei_to_wei () { - GWEI="$1" - printf "%s000000000" "${GWEI}" -} - -fail_if_unset "ETHERSCAN_API_KEY" -fail_if_unset "INFURA_KEY" -fail_if_unset "PK" - -GAS_PRICE_WEI_MAINNET="$( \ - curl --silent "https://safe-relay.gnosis.io/api/v1/gas-station/" \ - | jq -e --raw-output .fast \ -)" -if ! [[ "$GAS_PRICE_WEI_MAINNET" =~ ^[1-9][0-9]{9,11}$ ]]; then - echo "Invalid mainnet gas price $GAS_PRICE_WEI_MAINNET (wei)" >&2 - exit 1 -fi - -yarn deploy --network rinkeby --gasprice "$(gwei_to_wei 1)" -yarn deploy --network xdai --gasprice "$(gwei_to_wei 1)" -yarn deploy --network mainnet --gasprice "$GAS_PRICE_WEI_MAINNET" - -# wait for Etherscan to register the new contracts on the blockchain -sleep 60 - -yarn verify:etherscan --network rinkeby -yarn verify:etherscan --network mainnet -yarn verify:tenderly --network xdai - -if [ -n "$GIT_BRANCH" ]; then - GIT_USERNAME="GitHub Actions" - GIT_USEREMAIL="GitHub-Actions@GPv2-contracts" - if ! git config --get user.name &>/dev/null; then - git config user.name "$GIT_USERNAME" - git config user.email "$GIT_USEREMAIL" - fi - - git checkout -b "$GIT_BRANCH" - git add . - git commit -m "Deploy latest contract version" - git push --set-upstream origin "$GIT_BRANCH" -fi