Skip to content

Commit 4a9babd

Browse files
authored
feat(deployments): Auto-publish deployments to npm [SIM-236] (#35)
1 parent 8cbd468 commit 4a9babd

File tree

11 files changed

+2425
-72
lines changed

11 files changed

+2425
-72
lines changed

.circleci/config.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 2.1
44

55
default_docker_image: &default_docker_image
66
docker:
7-
- image: circleci/node:12.21.0
7+
- image: circleci/node:14.18
88

99
commands:
1010
setup_job:
@@ -38,6 +38,14 @@ commands:
3838
- run:
3939
name: Hardhat Test
4040
command: yarn test
41+
publish:
42+
steps:
43+
- run:
44+
name: setup
45+
command: ./scripts/prepublish.sh
46+
- run:
47+
name: release
48+
command: yarn semantic-release --debug
4149

4250
jobs:
4351
checkout_and_compile:
@@ -53,10 +61,10 @@ jobs:
5361
command: cp .env.default .env
5462
- run:
5563
name: Test npm token
56-
command: echo "//registry.npmjs.org/:_authToken=$NPM_READ_TOKEN"
64+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN"
5765
- run:
5866
name: Authenticate with registry
59-
command: echo "//registry.npmjs.org/:_authToken=$NPM_READ_TOKEN" > ~/set-v2-strategies-deployments/.npmrc
67+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/set-v2-strategies-deployments/.npmrc
6068
- run:
6169
name: Fetch Dependencies
6270
command: yarn install
@@ -145,6 +153,13 @@ jobs:
145153
- setup_job
146154
- test
147155

156+
release:
157+
<<: *default_docker_image
158+
working_directory: ~/set-v2-strategies-deployments
159+
steps:
160+
- setup_job
161+
- publish
162+
148163
workflows:
149164
version: 2
150165
build-and-test:
@@ -180,3 +195,6 @@ workflows:
180195
- optimism_deployment:
181196
requires:
182197
- checkout_and_compile
198+
- release:
199+
requires:
200+
- checkout_and_compile

.github/semantic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
titleOnly: true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
/.coverage_cache
1818
/.coverage_contracts
1919

20+
/deployments
21+
github.README.md
22+
github.package.json
23+
2024
### Node ###
2125

2226
# Logs

.releaserc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"branches": [
3+
{ "name": "master" }
4+
],
5+
"plugins": [
6+
["@semantic-release/commit-analyzer", {
7+
"preset": "angular",
8+
"releaseRules": [
9+
{"type": "feat", "scope":"ethereum/deployments/outputs/1-production.json", "release": "minor"},
10+
{"type": "feat", "scope":"ethereum/deployments/outputs/1-staging.json", "release": "minor"},
11+
{"type": "feat", "scope":"optimism/deployments/outputs/10-production.json", "release": "minor"},
12+
{"type": "feat", "scope":"optimism/deployments/outputs/10-staging.json", "release": "minor"},
13+
{"type": "feat", "scope":"polygon/deployments/outputs/137-production.json", "release": "minor"},
14+
{"type": "feat", "scope":"polygon/deployments/outputs/137-staging.json", "release": "minor"}
15+
]
16+
}],
17+
"@semantic-release/release-notes-generator",
18+
"@semantic-release/npm",
19+
"@semantic-release/github"
20+
]
21+
}

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ similar to that used in [deployUtils#addIntegrationToRegistry][28].
139139
[31]: https://github.com/SetProtocol/set-v2-strategies-deployments/blob/master/deployments/utils/deployUtils.ts
140140
[32]: https://github.com/SetProtocol/set-v2-strategies-deployments/blob/master/deployments/utils/dependencies.ts
141141

142+
## Semantic Release
143+
144+
This repository uses [semantic-release][201] to automatically publish in CI on merge to master. We
145+
only publish metadata about staging and production deployments and releases are only necessary
146+
when there are changes to the `network/deployments/outputs` production or staging files.
147+
148+
Use the following naming convention in your PR descriptions
149+
150+
+ chore: no release: `chore(scripts): description`
151+
+ example: `chore(scripts): DelegatedBaseManager Optimism deploy scripts`
152+
+ feature release (e.g 1.1.0 -> 1.2.0): `feat(deploy): description`
153+
+ example: `feat(deploy): Deploy DelegatedBaseManager to Optimism production`
154+
142155
## Chain resources
143156

144157
#### Ethereum
@@ -219,3 +232,4 @@ New deployment files at:
219232
```
220233

221234
[200]: https://www.alchemy.com/
235+
[201]: https://semantic-release.gitbook.io/semantic-release/v/beta/

package.json

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
{
2-
"name": "set-v2-strategies-deployments",
2+
"name": "@setprotocol/set-v2-strategies-deployments",
33
"version": "0.0.1",
4-
"description": "",
5-
"main": "dist",
6-
"types": "dist/types",
4+
"description": "Contract addresses for all SetProtocol Strategies (V2) staging and production deployments",
75
"files": [
8-
"artifacts",
9-
"dist",
10-
"contracts",
11-
"utils",
12-
"scripts",
13-
"tasks",
14-
"typechain",
15-
"tsconfig.json"
6+
"deployments"
167
],
178
"scripts": {
189
"build": "./scripts/build.sh",
@@ -23,13 +14,16 @@
2314
"lint-ts": "eslint -c .eslintrc.js --ext .ts",
2415
"lint-json": "./scripts/jsonlint.sh",
2516
"precommit": "lint-staged",
26-
"prepare": "yarn build",
17+
"postinstall": "yarn build",
18+
"prepublishOnly": "./scripts/prepublish.sh",
19+
"postpublish": "./scripts/postpublish.sh",
2720
"transpile": "tsc",
2821
"transpile:ethereum": "cd ethereum && yarn transpile",
2922
"transpile:polygon": "cd polygon && yarn transpile",
3023
"transpile:arbitrum": "cd arbitrum && yarn transpile",
3124
"transpile:optimism": "cd optimism && yarn transpile",
32-
"transpile:avalanche": "cd avalanche && yarn transpile"
25+
"transpile:avalanche": "cd avalanche && yarn transpile",
26+
"semantic-release": "semantic-release"
3327
},
3428
"repository": {
3529
"type": "git",
@@ -77,6 +71,7 @@
7771
"jsonlint": "^1.6.3",
7872
"lint-staged": "^10.2.11",
7973
"lodash": "^4.17.4",
74+
"semantic-release": "^19.0.2",
8075
"solc": "^0.6.10",
8176
"solhint": "^3.1.0",
8277
"ts-generator": "^0.1.1",

publish/npm.README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# set-v2-strategies-deployments
2+
3+
This repository contains contract addresses for all [set-v2-strategies][1] staging and production deployments.
4+
5+
SetProtocolV2 Strategies currently deploys to three networks:
6+
+ Ethereum
7+
+ Optimism
8+
+ Polygon
9+
10+
## Install
11+
12+
```
13+
yarn add @setprotocol/set-v2-strategies-deployments
14+
```
15+
16+
## Usage
17+
18+
The package consists of `.json` files located and usable as below:
19+
20+
```
21+
deployments/<network_name>/production.json
22+
deployments/<network_name>/staging.json
23+
```
24+
25+
```js
26+
> const production = require("@setprotocol/set-v2-strategies-deployments/deployments/ethereum/production");
27+
> production.addresses
28+
{
29+
"ManagerCore": "0x7a397B3ed39E84C6181e47309CE940574290f4e7",
30+
"DelegatedManagerFactory": "0x5132044c71b98315bDD5D8E6900bcf93EB2EbeC0",
31+
"IssuanceExtension": "0x05C5c57E5E75FC8EaD83FE06ebe4aCc471Fb2948",
32+
...
33+
}
34+
```
35+
36+
37+
[1]: https://github.com/SetProtocol/set-v2-strategies

publish/npm.package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@setprotocol/set-v2-strategies-deployments",
3+
"version": "0.0.1",
4+
"description": "Contract addresses for all SetProtocol Strategies (V2) staging and production deployments",
5+
"files": [
6+
"deployments"
7+
],
8+
"scripts": {
9+
"postpublish": "./scripts/postpublish.sh",
10+
"semantic-release": "semantic-release"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/SetProtocol/set-v2-strategies-deployments.git"
15+
},
16+
"author": "felix2feng",
17+
"license": "MIT",
18+
"homepage": "https://github.com/SetProtocol/set-v2-strategies-deployments",
19+
"devDependencies": {
20+
"semantic-release": "^19.0.2"
21+
}
22+
}

scripts/postpublish.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
cp github.README.md README.md
6+
rm github.README.md
7+
8+
cp github.package.json package.json
9+
rm github.package.json

scripts/prepublish.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
rm -rf deployments
6+
7+
# Create publication folder
8+
mkdir deployments
9+
mkdir deployments/ethereum
10+
mkdir deployments/optimism
11+
mkdir deployments/polygon
12+
13+
# Copy publishable assets to publication folder
14+
cp ethereum/deployments/outputs/1-production.json deployments/ethereum/production.json
15+
cp ethereum/deployments/outputs/1-staging.json deployments/ethereum/staging.json
16+
17+
cp optimism/deployments/outputs/10-production.json deployments/optimism/production.json
18+
cp optimism/deployments/outputs/10-staging.json deployments/optimism/staging.json
19+
20+
cp polygon/deployments/outputs/137-production.json deployments/polygon/production.json
21+
cp polygon/deployments/outputs/137-staging.json deployments/polygon/staging.json
22+
23+
# Copy npm README version to README (this will be reversed in the postpublish hook)
24+
cp README.md github.README.md
25+
cp publish/npm.README.md README.md
26+
27+
cp package.json github.package.json
28+
cp publish/npm.package.json package.json

0 commit comments

Comments
 (0)