Skip to content

Commit

Permalink
feat(deployments): Auto-publish deployments to npm [SIM-236] (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored Apr 18, 2022
1 parent 8cbd468 commit 4a9babd
Show file tree
Hide file tree
Showing 11 changed files with 2,425 additions and 72 deletions.
24 changes: 21 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2.1

default_docker_image: &default_docker_image
docker:
- image: circleci/node:12.21.0
- image: circleci/node:14.18

commands:
setup_job:
Expand Down Expand Up @@ -38,6 +38,14 @@ commands:
- run:
name: Hardhat Test
command: yarn test
publish:
steps:
- run:
name: setup
command: ./scripts/prepublish.sh
- run:
name: release
command: yarn semantic-release --debug

jobs:
checkout_and_compile:
Expand All @@ -53,10 +61,10 @@ jobs:
command: cp .env.default .env
- run:
name: Test npm token
command: echo "//registry.npmjs.org/:_authToken=$NPM_READ_TOKEN"
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN"
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_READ_TOKEN" > ~/set-v2-strategies-deployments/.npmrc
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/set-v2-strategies-deployments/.npmrc
- run:
name: Fetch Dependencies
command: yarn install
Expand Down Expand Up @@ -145,6 +153,13 @@ jobs:
- setup_job
- test

release:
<<: *default_docker_image
working_directory: ~/set-v2-strategies-deployments
steps:
- setup_job
- publish

workflows:
version: 2
build-and-test:
Expand Down Expand Up @@ -180,3 +195,6 @@ workflows:
- optimism_deployment:
requires:
- checkout_and_compile
- release:
requires:
- checkout_and_compile
1 change: 1 addition & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
titleOnly: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
/.coverage_cache
/.coverage_contracts

/deployments
github.README.md
github.package.json

### Node ###

# Logs
Expand Down
21 changes: 21 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"branches": [
{ "name": "master" }
],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "feat", "scope":"ethereum/deployments/outputs/1-production.json", "release": "minor"},
{"type": "feat", "scope":"ethereum/deployments/outputs/1-staging.json", "release": "minor"},
{"type": "feat", "scope":"optimism/deployments/outputs/10-production.json", "release": "minor"},
{"type": "feat", "scope":"optimism/deployments/outputs/10-staging.json", "release": "minor"},
{"type": "feat", "scope":"polygon/deployments/outputs/137-production.json", "release": "minor"},
{"type": "feat", "scope":"polygon/deployments/outputs/137-staging.json", "release": "minor"}
]
}],
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ similar to that used in [deployUtils#addIntegrationToRegistry][28].
[31]: https://github.com/SetProtocol/set-v2-strategies-deployments/blob/master/deployments/utils/deployUtils.ts
[32]: https://github.com/SetProtocol/set-v2-strategies-deployments/blob/master/deployments/utils/dependencies.ts

## Semantic Release

This repository uses [semantic-release][201] to automatically publish in CI on merge to master. We
only publish metadata about staging and production deployments and releases are only necessary
when there are changes to the `network/deployments/outputs` production or staging files.

Use the following naming convention in your PR descriptions

+ chore: no release: `chore(scripts): description`
+ example: `chore(scripts): DelegatedBaseManager Optimism deploy scripts`
+ feature release (e.g 1.1.0 -> 1.2.0): `feat(deploy): description`
+ example: `feat(deploy): Deploy DelegatedBaseManager to Optimism production`

## Chain resources

#### Ethereum
Expand Down Expand Up @@ -219,3 +232,4 @@ New deployment files at:
```

[200]: https://www.alchemy.com/
[201]: https://semantic-release.gitbook.io/semantic-release/v/beta/
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
{
"name": "set-v2-strategies-deployments",
"name": "@setprotocol/set-v2-strategies-deployments",
"version": "0.0.1",
"description": "",
"main": "dist",
"types": "dist/types",
"description": "Contract addresses for all SetProtocol Strategies (V2) staging and production deployments",
"files": [
"artifacts",
"dist",
"contracts",
"utils",
"scripts",
"tasks",
"typechain",
"tsconfig.json"
"deployments"
],
"scripts": {
"build": "./scripts/build.sh",
Expand All @@ -23,13 +14,16 @@
"lint-ts": "eslint -c .eslintrc.js --ext .ts",
"lint-json": "./scripts/jsonlint.sh",
"precommit": "lint-staged",
"prepare": "yarn build",
"postinstall": "yarn build",
"prepublishOnly": "./scripts/prepublish.sh",
"postpublish": "./scripts/postpublish.sh",
"transpile": "tsc",
"transpile:ethereum": "cd ethereum && yarn transpile",
"transpile:polygon": "cd polygon && yarn transpile",
"transpile:arbitrum": "cd arbitrum && yarn transpile",
"transpile:optimism": "cd optimism && yarn transpile",
"transpile:avalanche": "cd avalanche && yarn transpile"
"transpile:avalanche": "cd avalanche && yarn transpile",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -77,6 +71,7 @@
"jsonlint": "^1.6.3",
"lint-staged": "^10.2.11",
"lodash": "^4.17.4",
"semantic-release": "^19.0.2",
"solc": "^0.6.10",
"solhint": "^3.1.0",
"ts-generator": "^0.1.1",
Expand Down
37 changes: 37 additions & 0 deletions publish/npm.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# set-v2-strategies-deployments

This repository contains contract addresses for all [set-v2-strategies][1] staging and production deployments.

SetProtocolV2 Strategies currently deploys to three networks:
+ Ethereum
+ Optimism
+ Polygon

## Install

```
yarn add @setprotocol/set-v2-strategies-deployments
```

## Usage

The package consists of `.json` files located and usable as below:

```
deployments/<network_name>/production.json
deployments/<network_name>/staging.json
```

```js
> const production = require("@setprotocol/set-v2-strategies-deployments/deployments/ethereum/production");
> production.addresses
{
"ManagerCore": "0x7a397B3ed39E84C6181e47309CE940574290f4e7",
"DelegatedManagerFactory": "0x5132044c71b98315bDD5D8E6900bcf93EB2EbeC0",
"IssuanceExtension": "0x05C5c57E5E75FC8EaD83FE06ebe4aCc471Fb2948",
...
}
```


[1]: https://github.com/SetProtocol/set-v2-strategies
22 changes: 22 additions & 0 deletions publish/npm.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@setprotocol/set-v2-strategies-deployments",
"version": "0.0.1",
"description": "Contract addresses for all SetProtocol Strategies (V2) staging and production deployments",
"files": [
"deployments"
],
"scripts": {
"postpublish": "./scripts/postpublish.sh",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
"url": "git+https://github.com/SetProtocol/set-v2-strategies-deployments.git"
},
"author": "felix2feng",
"license": "MIT",
"homepage": "https://github.com/SetProtocol/set-v2-strategies-deployments",
"devDependencies": {
"semantic-release": "^19.0.2"
}
}
9 changes: 9 additions & 0 deletions scripts/postpublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -o errexit

cp github.README.md README.md
rm github.README.md

cp github.package.json package.json
rm github.package.json
28 changes: 28 additions & 0 deletions scripts/prepublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -o errexit

rm -rf deployments

# Create publication folder
mkdir deployments
mkdir deployments/ethereum
mkdir deployments/optimism
mkdir deployments/polygon

# Copy publishable assets to publication folder
cp ethereum/deployments/outputs/1-production.json deployments/ethereum/production.json
cp ethereum/deployments/outputs/1-staging.json deployments/ethereum/staging.json

cp optimism/deployments/outputs/10-production.json deployments/optimism/production.json
cp optimism/deployments/outputs/10-staging.json deployments/optimism/staging.json

cp polygon/deployments/outputs/137-production.json deployments/polygon/production.json
cp polygon/deployments/outputs/137-staging.json deployments/polygon/staging.json

# Copy npm README version to README (this will be reversed in the postpublish hook)
cp README.md github.README.md
cp publish/npm.README.md README.md

cp package.json github.package.json
cp publish/npm.package.json package.json
Loading

0 comments on commit 4a9babd

Please sign in to comment.