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

fix: properly publish all packages on travis #1187

Merged
merged 4 commits into from
Mar 3, 2020
Merged
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
51 changes: 4 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,50 +37,7 @@ script:
jobs:
include:
- node_js: '12'
after_success: npm run apply-next-version
deploy:
- provider: npm
src: "."
edge: true
email: aslushnikov@gmail.com
on:
branch: master
tag: next
api_token:
secure: MzswBGmhSf8AR47qvqEfwWLvMx7+UDLXL0CeTXdHi7gRg6XPQjnUf5xtV9+3WEsCrsUFa0rFYNKLQ8M2Qmubc1/UltnVQubF00/ImIW6gMRQn5wyE0CPKb+DPdSj892wh0LwCXzaUr3e7NdDRcOSRlvyIuPwhVZLeua5Z01CcIKQ/DCFguXrrgURB73hrrM77CdcPW3Fjy3SKo2tilBM0LX8KdJFxPqBTNA0CZwUdSGDyvyG6Z2+/RdMTh7appRdydKbvNVfAfNMo0vYPAwb7V+Exmxox2d/XKq0KeZusn20g17rZRndha9NPx/vGQrROz8FjSZh0kyqLfvxYCkh0qa7sj+DHOrxZnXSoFp5mTq7zm25GP7lp+MRzcEx2gGhpwu6j2n6XeFA1EuDtjDneLqGunK1UZA49ooQEfZoQHqtgoYV19VizG0kB3Lv8SAr/8zGZNofOWHaGCEGrof5WIC2HUJNurqXqVU5r/UUOy6eW941W0FNidbDZUvTbcI33dUlvvss7kDs4lHEBT4Hw/6Uusb2RLE69RgvNj83OaJ+F8V8e88ge4weYKhlcftlNS05UTSZiZQySXjiXyzYLZiZLTjO5T4zBITSAIP9mTdgfTYTPqApskzZZ1Yn5h35YcP8nopkO0WtKfAiZRV3/i/n/OdM+w8yYH6XBfQ4Gdk=
- provider: npm
src: "packages/playwright-firefox"
edge: true
email: aslushnikov@gmail.com
on:
branch: master
tag: next
api_token:
secure: MzswBGmhSf8AR47qvqEfwWLvMx7+UDLXL0CeTXdHi7gRg6XPQjnUf5xtV9+3WEsCrsUFa0rFYNKLQ8M2Qmubc1/UltnVQubF00/ImIW6gMRQn5wyE0CPKb+DPdSj892wh0LwCXzaUr3e7NdDRcOSRlvyIuPwhVZLeua5Z01CcIKQ/DCFguXrrgURB73hrrM77CdcPW3Fjy3SKo2tilBM0LX8KdJFxPqBTNA0CZwUdSGDyvyG6Z2+/RdMTh7appRdydKbvNVfAfNMo0vYPAwb7V+Exmxox2d/XKq0KeZusn20g17rZRndha9NPx/vGQrROz8FjSZh0kyqLfvxYCkh0qa7sj+DHOrxZnXSoFp5mTq7zm25GP7lp+MRzcEx2gGhpwu6j2n6XeFA1EuDtjDneLqGunK1UZA49ooQEfZoQHqtgoYV19VizG0kB3Lv8SAr/8zGZNofOWHaGCEGrof5WIC2HUJNurqXqVU5r/UUOy6eW941W0FNidbDZUvTbcI33dUlvvss7kDs4lHEBT4Hw/6Uusb2RLE69RgvNj83OaJ+F8V8e88ge4weYKhlcftlNS05UTSZiZQySXjiXyzYLZiZLTjO5T4zBITSAIP9mTdgfTYTPqApskzZZ1Yn5h35YcP8nopkO0WtKfAiZRV3/i/n/OdM+w8yYH6XBfQ4Gdk=
- provider: npm
src: "packages/playwright-chromium"
edge: true
email: aslushnikov@gmail.com
on:
branch: master
tag: next
api_token:
secure: MzswBGmhSf8AR47qvqEfwWLvMx7+UDLXL0CeTXdHi7gRg6XPQjnUf5xtV9+3WEsCrsUFa0rFYNKLQ8M2Qmubc1/UltnVQubF00/ImIW6gMRQn5wyE0CPKb+DPdSj892wh0LwCXzaUr3e7NdDRcOSRlvyIuPwhVZLeua5Z01CcIKQ/DCFguXrrgURB73hrrM77CdcPW3Fjy3SKo2tilBM0LX8KdJFxPqBTNA0CZwUdSGDyvyG6Z2+/RdMTh7appRdydKbvNVfAfNMo0vYPAwb7V+Exmxox2d/XKq0KeZusn20g17rZRndha9NPx/vGQrROz8FjSZh0kyqLfvxYCkh0qa7sj+DHOrxZnXSoFp5mTq7zm25GP7lp+MRzcEx2gGhpwu6j2n6XeFA1EuDtjDneLqGunK1UZA49ooQEfZoQHqtgoYV19VizG0kB3Lv8SAr/8zGZNofOWHaGCEGrof5WIC2HUJNurqXqVU5r/UUOy6eW941W0FNidbDZUvTbcI33dUlvvss7kDs4lHEBT4Hw/6Uusb2RLE69RgvNj83OaJ+F8V8e88ge4weYKhlcftlNS05UTSZiZQySXjiXyzYLZiZLTjO5T4zBITSAIP9mTdgfTYTPqApskzZZ1Yn5h35YcP8nopkO0WtKfAiZRV3/i/n/OdM+w8yYH6XBfQ4Gdk=
- provider: npm
src: "packages/playwright-webkit"
edge: true
email: aslushnikov@gmail.com
on:
branch: master
tag: next
api_token:
secure: MzswBGmhSf8AR47qvqEfwWLvMx7+UDLXL0CeTXdHi7gRg6XPQjnUf5xtV9+3WEsCrsUFa0rFYNKLQ8M2Qmubc1/UltnVQubF00/ImIW6gMRQn5wyE0CPKb+DPdSj892wh0LwCXzaUr3e7NdDRcOSRlvyIuPwhVZLeua5Z01CcIKQ/DCFguXrrgURB73hrrM77CdcPW3Fjy3SKo2tilBM0LX8KdJFxPqBTNA0CZwUdSGDyvyG6Z2+/RdMTh7appRdydKbvNVfAfNMo0vYPAwb7V+Exmxox2d/XKq0KeZusn20g17rZRndha9NPx/vGQrROz8FjSZh0kyqLfvxYCkh0qa7sj+DHOrxZnXSoFp5mTq7zm25GP7lp+MRzcEx2gGhpwu6j2n6XeFA1EuDtjDneLqGunK1UZA49ooQEfZoQHqtgoYV19VizG0kB3Lv8SAr/8zGZNofOWHaGCEGrof5WIC2HUJNurqXqVU5r/UUOy6eW941W0FNidbDZUvTbcI33dUlvvss7kDs4lHEBT4Hw/6Uusb2RLE69RgvNj83OaJ+F8V8e88ge4weYKhlcftlNS05UTSZiZQySXjiXyzYLZiZLTjO5T4zBITSAIP9mTdgfTYTPqApskzZZ1Yn5h35YcP8nopkO0WtKfAiZRV3/i/n/OdM+w8yYH6XBfQ4Gdk=
- provider: npm
src: "packages/playwright"
edge: true
email: aslushnikov@gmail.com
on:
branch: master
tag: next
api_token:
secure: MzswBGmhSf8AR47qvqEfwWLvMx7+UDLXL0CeTXdHi7gRg6XPQjnUf5xtV9+3WEsCrsUFa0rFYNKLQ8M2Qmubc1/UltnVQubF00/ImIW6gMRQn5wyE0CPKb+DPdSj892wh0LwCXzaUr3e7NdDRcOSRlvyIuPwhVZLeua5Z01CcIKQ/DCFguXrrgURB73hrrM77CdcPW3Fjy3SKo2tilBM0LX8KdJFxPqBTNA0CZwUdSGDyvyG6Z2+/RdMTh7appRdydKbvNVfAfNMo0vYPAwb7V+Exmxox2d/XKq0KeZusn20g17rZRndha9NPx/vGQrROz8FjSZh0kyqLfvxYCkh0qa7sj+DHOrxZnXSoFp5mTq7zm25GP7lp+MRzcEx2gGhpwu6j2n6XeFA1EuDtjDneLqGunK1UZA49ooQEfZoQHqtgoYV19VizG0kB3Lv8SAr/8zGZNofOWHaGCEGrof5WIC2HUJNurqXqVU5r/UUOy6eW941W0FNidbDZUvTbcI33dUlvvss7kDs4lHEBT4Hw/6Uusb2RLE69RgvNj83OaJ+F8V8e88ge4weYKhlcftlNS05UTSZiZQySXjiXyzYLZiZLTjO5T4zBITSAIP9mTdgfTYTPqApskzZZ1Yn5h35YcP8nopkO0WtKfAiZRV3/i/n/OdM+w8yYH6XBfQ4Gdk=

after_success:
- node utils/apply_next_version.js
- ./utils/publish_all_packages.sh --tip-of-tree
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"clean": "rimraf lib",
"build": "node utils/runWebpack.js --mode='development' && tsc -p .",
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
"apply-next-version": "node utils/apply_next_version.js",
"version": "node utils/sync_package_versions.js && npm run doc"
},
"author": {
Expand Down
16 changes: 0 additions & 16 deletions utils/apply_next_version.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
const path = require('path');
const fs = require('fs');
const execSync = require('child_process').execSync;

// Compare current HEAD to upstream master SHA.
// If they are not equal - refuse to publish since
// we're not tip-of-tree.
const upstream_sha = execSync(`git ls-remote https://github.com/Microsoft/playwright --tags master | cut -f1`).toString('utf8');
const current_sha = execSync(`git rev-parse HEAD`).toString('utf8');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this check moved to publish_all_packages.sh

if (upstream_sha.trim() !== current_sha.trim()) {
console.log('REFUSING TO PUBLISH: this is not tip-of-tree!');
process.exit(1);
return;
}


const package = require('../package.json');
let version = package.version;
const dashIndex = version.indexOf('-');
Expand Down
92 changes: 92 additions & 0 deletions utils/publish_all_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
set -e
set +x

trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"

if [[ $1 == "--help" ]]; then
echo "usage: $(basename $0) [--release|--tip-of-tree]"
echo
echo "Publishes all packages."
echo
echo "--release publish @latest version of all packages"
echo "--tip-of-tree publish @next version of all packages"
exit 1
fi

if [[ $# < 1 ]]; then
echo "Please specify either --release or --tip-of-tree"
exit 1
fi

if [[ $(git rev-parse --abbrev-ref HEAD) != "master" ]]; then
echo "ERROR: Cannot publish from branch other then 'master'"
exit 1
fi

if ! command -v npm >/dev/null; then
echo "ERROR: NPM is not found"
exit 1
fi

if [[ (-n $CI) && (-n $NPM_AUTH_TOKEN) && (! -f $HOME/.npmrc) ]]; then
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > $HOME/.npmrc
fi

if ! npm whoami >/dev/null 2>&1; then
echo "ERROR: NPM failed to log in"
exit 1
fi

UPSTREAM_SHA=$(git ls-remote https://github.com/microsoft/playwright --tags master | cut -f1)
CURRENT_SHA=$(git rev-parse HEAD)

if [[ "${UPSTREAM_SHA}" != "${CURRENT_SHA}" ]]; then
echo "REFUSING TO PUBLISH: this is not tip-of-tree"
exit 1
fi

cd ..

if [[ $1 == "--release" ]]; then
if [[ -n $CI ]]; then
echo "Found \$CI env - cannot publish real release from CI"
exit 1
fi
if [[ -n $(git status -s) ]]; then
echo "ERROR: git status is dirty; some uncommitted changes or untracked files"
exit 1
fi
VERSION=$(node -e 'console.log(require("./package.json").version)')
echo -n "Publish Playwright v${VERSION} (y/N)? "
read ANSWER
if [[ "$ANSWER" != "y" ]]; then
echo "Bailing out."
exit 1
fi

npm run clean
npm publish .
npm publish packages/playwright-firefox
npm publish packages/playwright-webkit
npm publish packages/playwright-chromium
npm publish packages/playwright
echo "Done."
elif [[ $1 == "--tip-of-tree" ]]; then
if [[ -z $CI ]]; then
echo "Did not find \$CI env - cannot publish tip-of-tree release not from CI"
exit 1
fi
npm run clean
npm publish . --tag="next"
npm publish packages/playwright-firefox --tag="next"
npm publish packages/playwright-webkit --tag="next"
npm publish packages/playwright-chromium --tag="next"
npm publish packages/playwright --tag="next"
echo "Done."
else
echo "unknown argument - '$1'"
exit 1
fi