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