chore: be on the safe side with publishing release candidate (#10363)

Make sure we never publish any other version that contains `rc`
as part of the version.

References #10334
This commit is contained in:
Andrey Lushnikov 2021-11-16 15:38:14 -08:00 committed by GitHub
parent 6904d6c7e6
commit 32bc83d322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 51 deletions

View file

@ -26,25 +26,34 @@ jobs:
- name: "@next: publish with commit timestamp (triggered manually)" - name: "@next: publish with commit timestamp (triggered manually)"
if: contains(github.ref, 'master') && github.event_name == 'workflow_dispatch' if: contains(github.ref, 'master') && github.event_name == 'workflow_dispatch'
run: | run: |
node utils/build/update_canary_version.js --commit-timestamp node utils/build/update_canary_version.js --alpha --commit-timestamp
utils/publish_all_packages.sh --next utils/publish_all_packages.sh --alpha
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "@next: publish with today's date (triggered automatically)" - name: "@next: publish with today's date (triggered automatically)"
if: contains(github.ref, 'master') && github.event_name != 'workflow_dispatch' if: contains(github.ref, 'master') && github.event_name != 'workflow_dispatch'
run: | run: |
node utils/build/update_canary_version.js --today-date node utils/build/update_canary_version.js --alpha --today-date
utils/publish_all_packages.sh --next utils/publish_all_packages.sh --alpha
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "@beta: publish with commit timestamp (triggered automatically)" - name: "@beta: publish with commit timestamp (triggered automatically)"
if: contains(github.ref, 'release') && github.event_name != 'workflow_dispatch' if: contains(github.ref, 'release') && github.event_name != 'workflow_dispatch'
run: | run: |
node utils/build/update_canary_version.js --commit-timestamp node utils/build/update_canary_version.js --beta --commit-timestamp
utils/publish_all_packages.sh --beta utils/publish_all_packages.sh --beta
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: | - name: build & publish driver
env:
AZ_UPLOAD_FOLDER: driver/next
AZ_ACCOUNT_KEY: ${{ secrets.AZ_ACCOUNT_KEY }}
AZ_ACCOUNT_NAME: ${{ secrets.AZ_ACCOUNT_NAME }}
run: |
utils/build/build-playwright-driver.sh
utils/build/upload-playwright-driver.sh
- name: trigger docker build
run: |
VERSION=$(node -e 'console.log(require("./package.json").version)') VERSION=$(node -e 'console.log(require("./package.json").version)')
if [[ "${VERSION}" != *-* ]]; then if [[ "${VERSION}" != *-* ]]; then
echo "ERROR: canary version must have dash inside, received '${VERSION}' instead" echo "ERROR: canary version must have dash inside, received '${VERSION}' instead"

View file

@ -1,32 +0,0 @@
name: "devrelease:driver"
on:
workflow_dispatch:
schedule:
- cron: "10 0 * * *"
push:
branches:
- release-*
jobs:
publish-canary-driver:
name: "publish playwright driver to CDN"
runs-on: ubuntu-20.04
if: github.repository == 'microsoft/playwright'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@8
- run: npm ci
- run: npm run build
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --commit-timestamp
- run: utils/build/build-playwright-driver.sh
- run: utils/build/upload-playwright-driver.sh
env:
AZ_UPLOAD_FOLDER: driver/next
AZ_ACCOUNT_KEY: ${{ secrets.AZ_ACCOUNT_KEY }}
AZ_ACCOUNT_NAME: ${{ secrets.AZ_ACCOUNT_NAME }}

View file

@ -709,5 +709,4 @@ jobs:
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: npx playwright install-deps - run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --today-date
- run: utils/build/build-playwright-driver.sh - run: utils/build/build-playwright-driver.sh

View file

@ -20,17 +20,28 @@ const path = require('path');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const packageJSON = require('../../package.json'); const packageJSON = require('../../package.json');
if (process.argv[2] === '--today-date') { const baseVersion = packageJSON.version.split('-')[0];
let prefix = '';
if (process.argv[2] === '--alpha') {
prefix = 'alpha';
} else if (process.argv[2] === '--beta') {
prefix = 'beta';
} else {
throw new Error('only --alpha or --beta prefixes are allowed');
}
if (process.argv[3] === '--today-date') {
const date = new Date(); const date = new Date();
const month = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'][date.getMonth()]; const month = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'][date.getMonth()];
const day = date.getDate(); const day = date.getDate();
const year = date.getFullYear(); const year = date.getFullYear();
packageJSON.version = `${packageJSON.version}-alpha-${month}-${day}-${year}`; packageJSON.version = `${baseVersion}-${prefix}-${month}-${day}-${year}`;
} else if (process.argv[2] === '--commit-timestamp') { } else if (process.argv[3] === '--commit-timestamp') {
const timestamp = execSync('git show -s --format=%ct HEAD', { const timestamp = execSync('git show -s --format=%ct HEAD', {
stdio: ['ignore', 'pipe', 'ignore'] stdio: ['ignore', 'pipe', 'ignore']
}).toString('utf8').trim(); }).toString('utf8').trim();
packageJSON.version = `${packageJSON.version}-${timestamp}000`; packageJSON.version = `${baseVersion}-${prefix}-${timestamp}000`;
} else { } else {
throw new Error('This script must be run with either --commit-timestamp or --today-date parameter'); throw new Error('This script must be run with either --commit-timestamp or --today-date parameter');
} }

View file

@ -15,18 +15,19 @@ trap "cleanup; cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname $0)"
if [[ $1 == "--help" ]]; then if [[ $1 == "--help" ]]; then
echo "usage: $(basename $0) [--release|--next|--beta]" echo "usage: $(basename $0) [--release|--release-candidate|--alpha|--beta]"
echo echo
echo "Publishes all packages." echo "Publishes all packages."
echo echo
echo "--release publish @latest version of all packages" echo "--release publish @latest version of all packages"
echo "--next publish @next version of all packages" echo "--release-candidate publish @rc version of all packages"
echo "--alpha publish @next version of all packages"
echo "--beta publish @beta version of all packages" echo "--beta publish @beta version of all packages"
exit 1 exit 1
fi fi
if [[ $# < 1 ]]; then if [[ $# < 1 ]]; then
echo "Please specify either --release, --beta or --next" echo "Please specify either --release, --beta or --alpha or --release-candidate"
exit 1 exit 1
fi fi
@ -68,17 +69,17 @@ elif [[ "$1" == "--release-candidate" ]]; then
exit 1 exit 1
fi fi
NPM_PUBLISH_TAG="rc" NPM_PUBLISH_TAG="rc"
elif [[ "$1" == "--next" ]]; then elif [[ "$1" == "--alpha" ]]; then
# Ensure package version contains dash. # Ensure package version contains alpha and does not contain rc
if [[ "${VERSION}" != *-* ]]; then if [[ "${VERSION}" != *-alpha* || "${VERSION}" == *-rc* ]]; then
echo "ERROR: cannot publish release version with --next flag" echo "ERROR: cannot publish release version with --alpha flag"
exit 1 exit 1
fi fi
NPM_PUBLISH_TAG="next" NPM_PUBLISH_TAG="next"
elif [[ "$1" == "--beta" ]]; then elif [[ "$1" == "--beta" ]]; then
# Ensure package version contains dash. # Ensure package version contains dash.
if [[ "${VERSION}" != *-* ]]; then if [[ "${VERSION}" != *-beta* || "${VERSION}" == *-rc* ]]; then
echo "ERROR: cannot publish release version with --beta flag" echo "ERROR: cannot publish release version with --beta flag"
exit 1 exit 1
fi fi