Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: stop publish smoke from check git clean #8058

Open
wants to merge 10 commits into
base: latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ const getPublishes = async ({ force }) => {
}

const main = async (opts) => {
const { isLocal, smokePublish, packDestination } = opts
const isPack = !!packDestination
const publishes = await getPublishes({ force: isPack })
const { test, otp, dryRun, smokePublish, packDestination } = opts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructing ALL flags here is really helpful to know what can be passed into this script


const hasPackDest = !!packDestination
const publishes = await getPublishes({ force: smokePublish })

if (!publishes.length) {
throw new Error(
Expand All @@ -88,13 +89,15 @@ const main = async (opts) => {
table.push([publish.name, publish.version, publish.tag])
}

const preformOperations = hasPackDest ? ['publish', 'pack'] : ['publish']

const confirmMessage = [
`Ready to ${isPack ? 'pack' : 'publish'} the following packages:`,
`Ready to ${preformOperations.join(',')} the following packages:`,
table.toString(),
isPack ? null : 'Ok to proceed? ',
smokePublish ? null : 'Ok to proceed? ',
].filter(Boolean).join('\n')

if (isPack) {
if (smokePublish) {
log.info(confirmMessage)
} else {
const confirm = await read({ prompt: confirmMessage, default: 'y' })
Expand All @@ -109,38 +112,43 @@ const main = async (opts) => {
await npm('rm', '--global', '--force', 'npm')
await npm('link', '--force', '--ignore-scripts')

if (opts.test) {
if (test) {
await npm('run', 'lint-all', '--ignore-scripts')
await npm('run', 'postlint', '--ignore-scripts')
await npm('run', 'test-all', '--ignore-scripts')
}

await npm('prune', '--omit=dev', '--no-save', '--no-audit', '--no-fund')
await npm('install', '-w', 'docs', '--ignore-scripts', '--no-audit', '--no-fund')
if (isLocal && smokePublish) {

if (smokePublish) {
log.info(`Skipping git dirty check due to local smoke publish test being run`)
} else {
await git.dirty()
}

let count = -1
for (const publish of publishes) {
log.info(`Publishing ${publish.name}@${publish.version} to ${publish.tag} ${count++}/${publishes.length}`)
const workspace = publish.workspace && `--workspace=${publish.name}`
const publishPkg = (...args) => npm('publish', workspace, `--tag=${publish.tag}`, ...args)

await npm('version', 'prerelease', workspace, '--preid=smoke')
if (isPack) {
if (hasPackDest) {
await npm(
'pack',
workspace,
opts.packDestination && `--pack-destination=${opts.packDestination}`
packDestination && `--pack-destination=${packDestination}`
)
if (smokePublish) {
await publishPkg('--dry-run')
}
}

if (smokePublish) {
// when we have a smoke test run we'd want to bump the version or else npm will throw an error even with dry-run
await npm('version', 'prerelease', workspace, '--preid=smoke', '--ignore-scripts', '--no-git-tag-version')
await publishPkg('--dry-run', '--ignore-scripts')
} else {
await publishPkg(
opts.dryRun && '--dry-run',
opts.otp && `--otp=${opts.otp === 'op' ? await op() : opts.otp}`
dryRun && '--dry-run',
otp && `--otp=${otp === 'op' ? await op() : otp}`
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/smoke-publish-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fi
# were publishing it to the registry. The only difference is in the
# publish.js script which will only pack and not publish
node . version $NPM_VERSION --ignore-scripts --git-tag-version="$IS_CI"
node scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true --is-local="$IS_LOCAL"
node scripts/publish.js --pack-destination=$RUNNER_TEMP --smoke-publish=true
NPM_TARBALL="$RUNNER_TEMP/npm-$NPM_VERSION.tgz"
node . install --global $NPM_TARBALL

Expand Down
Loading