Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.

feat: make a wrapper script for Lerna that autodetects the right remote #638

Merged
merged 1 commit into from
Sep 2, 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
9 changes: 1 addition & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Note that the `link-js-toolkit` will move all JS Toolkit dependencies in the QA

The release policy is to always release all packages in the monorepo, whether they have been modified or not.

To release a new version run `yarn release` in the `master` branch of the upstream repo (not your fork). This is necessary since lerna adds tags and pushes commits directly to the upstream repo.
To release a new version run `yarn release` in the `master` branch. The script will attempt to locate the appropriate Git remote corresponding to [the "liferay" organization on GitHub](https://github.com/liferay), and fall back to Lerna's default, the `origin` remote as a last resort.

Make sure the local "master" branch is up-to-date:

Expand Down Expand Up @@ -123,13 +123,6 @@ Release a new version
$ yarn release ⏎
```

**NOTE:** Lerna will push to your Git `origin` remote; if that happens to be _your_ fork and not the official [liferay/liferay-js-toolkit](https://github.com/liferay/liferay-js-toolkit), then you will need to push the changes upstream manually. For example, if the authoritative remote is named `upstream` in your local repo:

```sh
git push upstream master --follow-tags --dry-run ⏎
git push upstream master --follow-tags ⏎
```

Copy the relevant section from the changelog to the corresponding entry on the [releases page](https://github.com/liferay/liferay-js-toolkit/releases).

After the release, you may want to confirm that the packages are correctly listed in the NPM registry.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"lint": "eslint \"packages/*/src/*.js\" \"packages/*/src/**/*.js\"",
"lint:fix": "eslint --fix \"packages/*/src/*.js\" \"packages/*/src/**/*.js\"",
"qa": "node scripts/qa/index.js",
"release": "lerna publish --force-publish='*' --exact",
"release-canary": "lerna publish --force-publish='*' --exact -c",
"release": "scripts/publish.sh --force-publish='*' --exact",
"release-canary": "scripts/publish.sh --force-publish='*' --exact -c",
"test": "jest --runInBand",
"watch": "node scripts/watch"
},
Expand Down
28 changes: 28 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# © 2017 Liferay, Inc. <https://liferay.com>
#
# SPDX-License-Identifier: LGPL-3.0-or-later

##
# Wrapper for `lerna publish` that attempts to detect the appropriate remote to
# use and passes `--git-remote` accordingly.
#

REMOTE=$(git remote -v | grep 'github.com[:/]liferay/' | grep '(push)' | sort -k2 | head -1 | cut -f1)

if [ -n "$REMOTE" ]; then
yarn run lerna "$@" --git-remote="$REMOTE"
else
echo 'warning: could not locate a "liferay" remote'

read -p 'Proceed using "origin" remote? ' -n 1 -r
echo

if [[ $REPLY =~ ^[Yy]$ ]]; then
yarn run lerna "$@"
else
echo Aborted.
exit 1
fi
fi