-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(publishing): Auto publish repository to npm in CI [SIM-123] (#203)
- Loading branch information
Showing
13 changed files
with
2,615 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
coverage.json | ||
coverage/ | ||
.env | ||
.releaserc.json | ||
|
||
/.coverage_cache | ||
/.coverage_contracts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
|
||
rm -f coverage.json | ||
rm -rf .coverage_cache | ||
rm -rf .coverage_contracts | ||
rm -rf cache | ||
rm -rf coverage | ||
rm -rf typechain | ||
rm -rf artifacts | ||
rm -rf dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Run in the `prepublishOnly npm hook`. We publish a specially built version | ||
# of the repo to the @hardhat tag which includes hardcoded gas values in the hardhat | ||
# artifact abis and deposits type definitions alongside the js files in the dist. | ||
# This build is necessary for Perp fixtures to run correctly at set-v2-strategies | ||
set -o errexit | ||
|
||
echo "Running prepublishOnly npm hook" | ||
echo "PUBLISH_HARDHAT = $PUBLISH_HARDHAT" | ||
|
||
# This hook is skipped when publishing in CI because semantic-release is discarding TS products of | ||
# npm lifecycle hooks. In CI we re-write the tsconfig on the fly to generate the correct outputs. | ||
if [[ -v CI ]]; then | ||
exit 0 | ||
elif [[ -v PUBLISH_HARDHAT ]]; then | ||
yarn build:npm:hardhat | ||
else | ||
yarn build:npm:latest | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
|
||
# Auto-publishes a specially built release to the @hardhat tag using version schema `x.x.x-hardhat.1` | ||
# which can be installed with `yarn add @setprotocol/set-protocol-v2@hardhat` | ||
# See scripts/prepublish_only.sh for details about this build. | ||
# | ||
# The `release_default...` branch config here is necessary to trick the semantic-release tool into publishing | ||
# latest and hardhat builds from `master`. These are handled by separate jobs in CI (see circleci/config.yml) | ||
echo '{ | ||
"branches": [ | ||
{ "name": "release_default_do_not_delete" }, | ||
{ "name": "master", "channel": "hardhat", "prerelease": "hhat"} | ||
] | ||
}' > .releaserc.json | ||
|
||
# `semantic-release` discards any dist changes generated by npm lifecycle hooks so we need to copy the custom | ||
# config into the default config to produce correct build. This change *IS NOT* committed to the repo and | ||
# this script does not update the package.json version. | ||
cp tsconfig.hardhat.json tsconfig.json | ||
|
||
npx semantic-release --debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
|
||
# Auto-publishes `latest` from master, updates package version on github | ||
# Version format is `x.x.x` and installs with `yarn add @setprotocol/set-protocol-v2` | ||
# `package.json` version field is updated and pushed to Github | ||
echo '{ | ||
"branches": [ | ||
{ "name": "master" } | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/npm", | ||
"@semantic-release/git" | ||
] | ||
}' > .releaserc.json | ||
|
||
# Regenerate artifacts to strip out hardcoded gas values in artifact ABIs | ||
yarn build:npm:latest | ||
|
||
npx semantic-release --debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
titleOnly: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"strictPropertyInitialization": false, | ||
"outDir": "./dist", | ||
"resolveJsonModule": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
"baseUrl": ".", | ||
"moduleResolution": "node", | ||
"paths": { | ||
"@utils/*": ["utils/*"], | ||
"@typechain/*": ["typechain/*"] | ||
} | ||
}, | ||
"include": [ | ||
"./utils/**/*.ts", | ||
"./deploy/**/*.ts", | ||
"./typechain/**/*.ts", | ||
"./tasks/**/*.ts" | ||
], | ||
"files": [ | ||
"hardhat.config.ts", | ||
] | ||
} |
Oops, something went wrong.