Add @openzeppelin/contracts as alternative package name (#1840)
* Rename package and repository name from docs and scripts
* undo root package rename
* add @openzeppelin/contracts as subpackage with release automation
* synchronize @openzeppelin/contracts version
* remove private field from package.json
* make file patterns absolute
* change wording of a comment
* use a saner version script
(cherry picked from commit b8c8308d77)
This commit is contained in:
committed by
Francisco Giordano
parent
132e442c1f
commit
5fe8f4e93b
12
scripts/prepare-contracts-package.sh
Normal file
12
scripts/prepare-contracts-package.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# cd to the root of the repo
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
# avoids re-compilation during publishing of both packages
|
||||
if [[ ! -v ALREADY_COMPILED ]]; then
|
||||
npm run prepare
|
||||
fi
|
||||
|
||||
cp README.md contracts/
|
||||
cp -Tr build/contracts contracts/build
|
||||
@ -30,18 +30,30 @@ push_release_branch_and_tag() {
|
||||
git push upstream "$(current_release_branch)" "$(current_version)"
|
||||
}
|
||||
|
||||
publish() {
|
||||
dist_tag="$1"
|
||||
|
||||
log "Publishing openzeppelin-solidity on npm"
|
||||
npm publish --tag "$dist_tag" --otp "$(prompt_otp)"
|
||||
|
||||
log "Publishing @openzeppelin/contracts on npm"
|
||||
env ALREADY_COMPILED= \ # avoid re-compiling
|
||||
npm publish contracts --tag "$dist_tag" --otp "$(prompt_otp)"
|
||||
|
||||
if [[ "$dist_tag" == "latest" ]]; then
|
||||
otp="$(prompt_otp)"
|
||||
npm dist-tag rm --otp "$otp" openzeppelin-solidity next
|
||||
npm dist-tag rm --otp "$otp" @openzeppelin/contracts next
|
||||
fi
|
||||
}
|
||||
|
||||
push_and_publish() {
|
||||
dist_tag="$1"
|
||||
|
||||
log "Pushing release branch and tags to upstream"
|
||||
push_release_branch_and_tag
|
||||
|
||||
log "Publishing package on npm"
|
||||
npm publish --tag "$dist_tag" --otp "$(prompt_otp)"
|
||||
|
||||
if [[ "$dist_tag" == "latest" ]]; then
|
||||
npm dist-tag rm --otp "$(prompt_otp)" openzeppelin-solidity next
|
||||
fi
|
||||
publish "$dist_tag"
|
||||
}
|
||||
|
||||
prompt_otp() {
|
||||
|
||||
18
scripts/release/synchronize-versions.js
Executable file
18
scripts/release/synchronize-versions.js
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Synchronizes the versions in ethpm.json and contracts/package.json with the
|
||||
// one in package.json.
|
||||
// This is run automatically when npm version is run.
|
||||
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
|
||||
setVersion('contracts/package.json');
|
||||
setVersion('ethpm.json');
|
||||
|
||||
function setVersion(file) {
|
||||
const json = JSON.parse(fs.readFileSync(file));
|
||||
json.version = process.env.npm_package_version;
|
||||
fs.writeFileSync(file, JSON.stringify(json, null, 2) + '\n');
|
||||
cp.execFileSync('git', ['add', file]);
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Synchronizes ethpm.json version number with package.json.
|
||||
// This is run automatically when npm version is run.
|
||||
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
|
||||
const pkg = require('../../package.json');
|
||||
const ethpm = require('../../ethpm.json');
|
||||
|
||||
ethpm.version = pkg.version;
|
||||
|
||||
fs.writeFileSync('ethpm.json', JSON.stringify(ethpm, null, 2) + '\n');
|
||||
|
||||
cp.execSync('git add ethpm.json');
|
||||
6
scripts/release/version.sh
Executable file
6
scripts/release/version.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
scripts/release/update-changelog-release-date.js
|
||||
scripts/release/synchronize-versions.js
|
||||
Reference in New Issue
Block a user