Skip to content

Commit ac8a30c

Browse files
authored
devops: start releasing from Github Actions (#1890)
This patch: - removes releasing from Travis CI - sets up a new GH Action that releases @next version from tip-of-tree Once this GH Action proves to be working, we'll setup a `publish_release.yml` workflow that will be triggered only by **release** github events and that will publish released version with `LATEST` tag. NOTE: this workflow does not actually run publishing - we're doing `--dry-run` for now to see how it works in `//utils/publish_all_packages.sh`.
1 parent 80a7fcd commit ac8a30c

File tree

3 files changed

+55
-48
lines changed

3 files changed

+55
-48
lines changed

.github/workflows/publish_canary.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "canary"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
CI: true
10+
11+
jobs:
12+
publish-canary:
13+
name: "publish"
14+
runs-on: ubuntu-18.04
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: 10
20+
registry-url: 'https://registry.npmjs.org'
21+
- uses: microsoft/playwright-github-action@v1
22+
- run: npm ci
23+
- run: node utils/update_version.js --next
24+
- run: utils/publish_all_packages.sh --tip-of-tree
25+
env:
26+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27+

.travis.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,3 @@ jobs:
4040
include:
4141
- node_js: '12'
4242

43-
before_deploy:
44-
- node utils/update_version.js --next
45-
46-
deploy:
47-
skip_cleanup: true
48-
provider: script
49-
script: utils/publish_all_packages.sh --tip-of-tree
50-
on:
51-
branch: master

utils/publish_all_packages.sh

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,52 @@ if ! command -v npm >/dev/null; then
2525
exit 1
2626
fi
2727

28-
if [[ (-n $CI) && (-n $NPM_AUTH_TOKEN) ]]; then
29-
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > $HOME/.npmrc
30-
fi
31-
3228
if ! npm whoami >/dev/null 2>&1; then
33-
echo "ERROR: NPM failed to log in"
34-
exit 1
35-
fi
36-
37-
UPSTREAM_SHA=$(git ls-remote https://github.com/microsoft/playwright --tags master | cut -f1)
38-
CURRENT_SHA=$(git rev-parse HEAD)
39-
40-
if [[ "${UPSTREAM_SHA}" != "${CURRENT_SHA}" ]]; then
41-
echo "REFUSING TO PUBLISH: this is not tip-of-tree"
29+
echo "ERROR: NPM is not logged in."
4230
exit 1
4331
fi
4432

4533
cd ..
4634

35+
NPM_PUBLISH_TAG="next"
36+
VERSION=$(node -e 'console.log(require("./package.json").version)')
37+
4738
if [[ $1 == "--release" ]]; then
48-
if [[ -n $CI ]]; then
49-
echo "Found \$CI env - cannot publish real release from CI"
50-
exit 1
51-
fi
5239
if [[ -n $(git status -s) ]]; then
5340
echo "ERROR: git status is dirty; some uncommitted changes or untracked files"
5441
exit 1
5542
fi
56-
VERSION=$(node -e 'console.log(require("./package.json").version)')
57-
echo -n "Publish Playwright v${VERSION} (y/N)? "
58-
read ANSWER
59-
if [[ "$ANSWER" != "y" ]]; then
60-
echo "Bailing out."
43+
# Ensure package version does not contain dash.
44+
if [[ "${VERSION}" == *-* ]]; then
45+
echo "ERROR: cannot publish pre-release version with --release flag"
6146
exit 1
6247
fi
63-
64-
npm run clean
65-
npm publish .
66-
npm publish packages/playwright-firefox
67-
npm publish packages/playwright-webkit
68-
npm publish packages/playwright-chromium
69-
npm publish packages/playwright
70-
echo "Done."
48+
NPM_PUBLISH_TAG="latest"
7149
elif [[ $1 == "--tip-of-tree" ]]; then
72-
if [[ -z $CI ]]; then
73-
echo "Did not find \$CI env - cannot publish tip-of-tree release not from CI"
50+
# Ensure package version contains dash.
51+
if [[ "${VERSION}" != *-* ]]; then
52+
echo "ERROR: cannot publish release version with --tip-of-tree flag"
7453
exit 1
7554
fi
76-
npm run clean
77-
npm publish . --tag="next"
78-
npm publish packages/playwright-firefox --tag="next"
79-
npm publish packages/playwright-webkit --tag="next"
80-
npm publish packages/playwright-chromium --tag="next"
81-
npm publish packages/playwright --tag="next"
82-
echo "Done."
55+
56+
# Ensure this is actually tip-of-tree.
57+
UPSTREAM_SHA=$(git ls-remote https://github.com/microsoft/playwright --tags master | cut -f1)
58+
CURRENT_SHA=$(git rev-parse HEAD)
59+
if [[ "${UPSTREAM_SHA}" != "${CURRENT_SHA}" ]]; then
60+
echo "REFUSING TO PUBLISH: this is not tip-of-tree"
61+
exit 1
62+
fi
63+
NPM_PUBLISH_TAG="next"
8364
else
8465
echo "unknown argument - '$1'"
8566
exit 1
8667
fi
8768

69+
npm run clean
70+
npm publish . --tag="${NPM_PUBLISH_TAG}" --dry-run
71+
npm publish packages/playwright-firefox --tag="${NPM_PUBLISH_TAG}" --dry-run
72+
npm publish packages/playwright-webkit --tag="${NPM_PUBLISH_TAG}" --dry-run
73+
npm publish packages/playwright-chromium --tag="${NPM_PUBLISH_TAG}" --dry-run
74+
npm publish packages/playwright --tag="${NPM_PUBLISH_TAG}" --dry-run
75+
76+
echo "Done."

0 commit comments

Comments
 (0)