diff options
author | Fabio Berger <me@fabioberger.com> | 2019-01-17 22:59:00 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2019-01-17 22:59:00 +0800 |
commit | 293e93729176b06f7e3cf78c798f48ddf360e311 (patch) | |
tree | e47909d281ae7da6b7c9e6af76757373ad485705 /packages/monorepo-scripts/src/publish.ts | |
parent | fe2f97dabd1511918051161c882c57bcc1d41ac2 (diff) | |
parent | 0b23aaca2619b888dd4e15774d5c543f79f4588d (diff) | |
download | dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar.gz dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar.bz2 dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar.lz dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar.xz dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.tar.zst dexon-sol-tools-293e93729176b06f7e3cf78c798f48ddf360e311.zip |
Merge branch 'development' into fix/dev-tools-pages/finalTouches
* development: (22 commits)
Fix linter
Update packages/sol-tracing-utils/src/trace_collection_subprovider.ts
Update packages/sol-tracing-utils/CHANGELOG.json
Update packages/sol-tracing-utils/CHANGELOG.json
Add PR numbers
Fix/simplify handling of revert trace snippets
Fix a bug when TraceCollectionSubprovider was hanging on the fake Geth snapshot transaction
Fix a bug when a custom Geth tracer didn't return stack entries for DELEGATECALL
Revert devnet mining period from 1 to 0
update team info, add brent
Publish
Updated CHANGELOGS
Add commented-out pre-publish checks
Add additional check to make sure user was added to our DockerHub org
Update test for required amountAvailableToFill
Add actual error message thrown
Flag order-watcher as having a Docker image to publish
Add publish to DockerHub step to publish flow
Flesh out postpublish configs in packageJSON type
Add pre-publish check to ensure publisher is logged in to docker cmdline
...
Diffstat (limited to 'packages/monorepo-scripts/src/publish.ts')
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index e0602a74f..105d87dcd 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -1,11 +1,12 @@ #!/usr/bin/env node +import { logUtils } from '@0x/utils'; import * as promisify from 'es6-promisify'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); -import { exec as execAsync } from 'promisify-child-process'; +import { exec as execAsync, spawn as spawnAsync } from 'promisify-child-process'; import * as prompt from 'prompt'; import semver = require('semver'); import semverSort = require('semver-sort'); @@ -79,12 +80,16 @@ async function confirmAsync(message: string): Promise<void> { }); utils.log(`Calling 'lerna publish'...`); await lernaPublishAsync(packageToNextVersion); - if (!configs.IS_LOCAL_PUBLISH) { + + const isDryRun = configs.IS_LOCAL_PUBLISH; + if (!isDryRun) { + // Publish docker images to DockerHub + await publishImagesToDockerHubAsync(allPackagesToPublish); + const isStaging = false; const shouldUploadDocs = true; await generateAndUploadDocJsonsAsync(packagesWithDocs, isStaging, shouldUploadDocs); } - const isDryRun = configs.IS_LOCAL_PUBLISH; const releaseNotes = await publishReleaseNotesAsync(updatedPublicPackages, isDryRun); utils.log('Published release notes'); @@ -95,11 +100,45 @@ async function confirmAsync(message: string): Promise<void> { utils.log("Publish successful, but couldn't auto-alert discord (", e.message, '), Please alert manually.'); } } + process.exit(0); })().catch(err => { utils.log(err); process.exit(1); }); +async function publishImagesToDockerHubAsync(allUpdatedPackages: Package[]): Promise<void> { + for (const pkg of allUpdatedPackages) { + const packageJSON = pkg.packageJson; + const shouldPublishDockerImage = + !_.isUndefined(packageJSON.config) && + !_.isUndefined(packageJSON.config.postpublish) && + !_.isUndefined(packageJSON.config.postpublish.dockerHubRepo); + if (!shouldPublishDockerImage) { + continue; + } + const dockerHubRepo = _.get(packageJSON, 'config.postpublish.dockerHubRepo'); + const pkgName = pkg.packageJson.name; + const packageDirName = _.startsWith(pkgName, '@0x/') ? pkgName.split('/')[1] : pkgName; + + // Build the Docker image + logUtils.log(`Building '${dockerHubRepo}' docker image...`); + await spawnAsync('docker', ['build', '-t', dockerHubRepo, '.'], { + cwd: `${constants.monorepoRootPath}/packages/${packageDirName}`, + }); + + // Tag the docker image with the latest version + const version = pkg.packageJson.version; + logUtils.log(`Tagging '${dockerHubRepo}' docker image with version ${version}...`); + await execAsync(`docker tag ${dockerHubRepo} ${configs.DOCKER_HUB_ORG}/${dockerHubRepo}:${version}`); + await execAsync(`docker tag ${dockerHubRepo} ${configs.DOCKER_HUB_ORG}/${dockerHubRepo}:latest`); + + // Publish to DockerHub + logUtils.log(`Pushing '${dockerHubRepo}' docker image to DockerHub...`); + await execAsync(`docker push ${configs.DOCKER_HUB_ORG}/${dockerHubRepo}:${version}`); + await execAsync(`docker push ${configs.DOCKER_HUB_ORG}/${dockerHubRepo}:latest`); + } +} + function getPackagesWithDocs(allUpdatedPackages: Package[]): Package[] { const rootPackageJsonPath = `${constants.monorepoRootPath}/package.json`; const rootPackageJson = JSON.parse(fs.readFileSync(rootPackageJsonPath).toString()); |