2019-07-15 10:58:47 +03:00
|
|
|
#!/usr/bin/env bash
|
2019-04-03 13:03:19 +03:00
|
|
|
|
|
|
|
set -e
|
2019-07-09 16:53:27 +03:00
|
|
|
IFS=$'\n'
|
2019-04-03 13:03:19 +03:00
|
|
|
|
2019-10-12 00:02:28 +03:00
|
|
|
# Please use this script in conjunction with the release documentation:
|
|
|
|
# https://mozilla.github.io/ecosystem-platform/docs/fxa-engineering/release-process
|
|
|
|
#
|
2019-04-03 13:03:19 +03:00
|
|
|
# This script will automatically update the changelogs and bump the version
|
|
|
|
# strings for each of the "main" FxA packages in this tree. It assumes some
|
|
|
|
# uniformity in the format of the tags and changelogs, so tagging should
|
|
|
|
# always be done with this script lest that uniformity is broken.
|
|
|
|
#
|
|
|
|
# Note that this script DOES NOT PUSH TO ANY REMOTES. It is expected that a
|
|
|
|
# human will verify the results before doing that step and opening any pull
|
|
|
|
# requests.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# release.sh [patch]
|
|
|
|
#
|
|
|
|
# If no argument is specified, the main train number will be bumped. If the
|
|
|
|
# argument `patch` is specified, the patch number will be bumped. Any other
|
|
|
|
# argument is invalid.
|
|
|
|
#
|
|
|
|
# Steps:
|
|
|
|
#
|
|
|
|
# 1. Check the argument is valid.
|
|
|
|
# 2. Check there are no local changes.
|
|
|
|
# 3. Find the last tag.
|
|
|
|
# 4. Check there have been some commits since the last tag.
|
|
|
|
# 5. Generate the bumped version string.
|
|
|
|
# 6. If current branch is train branch, pull from origin.
|
2020-06-18 04:13:10 +03:00
|
|
|
# 7. Otherwise checkout existing train branch or create fresh one from main.
|
2019-04-03 13:03:19 +03:00
|
|
|
# 8. For each of the "main" packages...
|
2020-02-04 04:47:59 +03:00
|
|
|
# 8.4. If package.json exists, update the version string in package.json.
|
|
|
|
# 8.5. If package-lock.json exists, update the version string in package-lock.json.
|
|
|
|
# 8.6. If npm-shrinkwrap.json exists, update the version string in npm-shrinkwrap.json.
|
2019-04-24 10:13:34 +03:00
|
|
|
# 9. Update the AUTHORS file
|
|
|
|
# 10. Commit changes.
|
|
|
|
# 11. Create a tag.
|
2020-03-03 03:16:56 +03:00
|
|
|
# 12. Tell the user what we did.
|
2019-04-03 13:03:19 +03:00
|
|
|
|
2019-04-17 14:47:21 +03:00
|
|
|
SCRIPT_DIR=`dirname "$0"`/_scripts
|
2019-05-30 12:58:19 +03:00
|
|
|
CURRENT_BRANCH=`git branch --no-color | grep '^\*' | cut -d ' ' -f 2`
|
2020-02-04 18:57:02 +03:00
|
|
|
FXA_REPO="https://github.com/mozilla/fxa"
|
2019-04-03 13:03:19 +03:00
|
|
|
|
|
|
|
abort() {
|
|
|
|
git checkout "$CURRENT_BRANCH" > /dev/null 2>&1
|
|
|
|
echo "Release aborted: $1."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# 1. Check the argument is valid.
|
|
|
|
case "$1" in
|
|
|
|
"")
|
|
|
|
BUILD_TYPE="Train"
|
|
|
|
;;
|
|
|
|
"patch")
|
|
|
|
BUILD_TYPE="Patch"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
abort "Invalid argument \"$1\""
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# 2. Check there are no local changes.
|
|
|
|
STATUS=`git status --porcelain`
|
|
|
|
if [ "$STATUS" != "" ]; then
|
|
|
|
abort "You have uncommited changes"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 3. Find the last tag.
|
2019-05-28 20:18:00 +03:00
|
|
|
if [ "$BUILD_TYPE" = "Train" ]; then
|
2020-04-06 22:46:43 +03:00
|
|
|
# Last tag is the last recently created tag when starting a train
|
|
|
|
# HACK: filter out any tags with hyphens - these are feature branch releases
|
|
|
|
LAST_TAG=`git tag -l --sort=version:refname | grep -v '-' | tail -1`
|
2019-05-28 20:18:00 +03:00
|
|
|
else
|
2021-09-21 19:31:47 +03:00
|
|
|
if [ $CURRENT_BRANCH = "main" ]; then
|
|
|
|
abort "You're trying to create a patch release on main. Please check out the latest train branch."
|
|
|
|
fi
|
|
|
|
|
2020-04-06 22:46:43 +03:00
|
|
|
# Current tag is last tag, when we're on a train branch for a patch
|
2019-05-28 21:29:08 +03:00
|
|
|
LAST_TAG=`git describe --tags --first-parent --abbrev=0`
|
2019-05-28 20:18:00 +03:00
|
|
|
fi
|
2019-04-03 13:03:19 +03:00
|
|
|
|
|
|
|
# 4. Check there have been some commits since the last tag.
|
|
|
|
COMMITS=`git log $LAST_TAG..HEAD --pretty=oneline --abbrev-commit`
|
|
|
|
if [ "$COMMITS" = "" ]; then
|
|
|
|
abort "I see no work"
|
|
|
|
fi
|
|
|
|
|
|
|
|
MAJOR=`echo "$LAST_TAG" | cut -d '.' -f 1 | cut -d 'v' -f 2`
|
|
|
|
TRAIN=`echo "$LAST_TAG" | cut -d '.' -f 2`
|
|
|
|
PATCH=`echo "$LAST_TAG" | cut -d '.' -f 3 | cut -d '-' -f 1`
|
|
|
|
|
|
|
|
LAST_VERSION="$MAJOR.$TRAIN.$PATCH"
|
|
|
|
SED_FRIENDLY_LAST_VERSION="$MAJOR\\.$TRAIN\\.$PATCH"
|
|
|
|
|
|
|
|
# 5. Generate the bumped version string.
|
|
|
|
case "$BUILD_TYPE" in
|
|
|
|
"Train")
|
|
|
|
TRAIN=`expr $TRAIN + 1`
|
|
|
|
PATCH=0
|
|
|
|
;;
|
|
|
|
"Patch")
|
|
|
|
PATCH=`expr $PATCH + 1`
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
NEW_VERSION="$MAJOR.$TRAIN.$PATCH"
|
|
|
|
NEW_TAG="v$NEW_VERSION"
|
|
|
|
|
|
|
|
# 6. If current branch is train branch, pull from origin.
|
|
|
|
TRAIN_BRANCH="train-$TRAIN"
|
|
|
|
if [ "$CURRENT_BRANCH" = "$TRAIN_BRANCH" ]; then
|
|
|
|
git pull origin "$TRAIN_BRANCH" > /dev/null 2>&1 || true
|
|
|
|
else
|
2020-06-18 04:13:10 +03:00
|
|
|
# 7. Otherwise checkout existing train branch or create fresh one from main.
|
2019-05-30 12:58:19 +03:00
|
|
|
TRAIN_BRANCH_EXISTS=`git branch --no-color | awk '{$1=$1};1' | grep "^$TRAIN_BRANCH\$"` || true
|
2019-04-03 13:03:19 +03:00
|
|
|
|
|
|
|
if [ "$TRAIN_BRANCH_EXISTS" = "" ]; then
|
|
|
|
git fetch origin $TRAIN_BRANCH > /dev/null 2>&1 || true
|
|
|
|
|
|
|
|
REMOTE_BRANCH="origin/$TRAIN_BRANCH"
|
2019-05-30 12:58:19 +03:00
|
|
|
REMOTE_BRANCH_EXISTS=`git branch --no-color -r | awk '{$1=$1};1' | grep "^$REMOTE_BRANCH\$"` || true
|
2019-04-03 13:03:19 +03:00
|
|
|
|
|
|
|
if [ "$REMOTE_BRANCH_EXISTS" = "" ]; then
|
2020-06-18 04:13:10 +03:00
|
|
|
echo "Warning: $TRAIN_BRANCH branch not found on local or remote, creating one from main."
|
|
|
|
git checkout main > /dev/null 2>&1
|
|
|
|
git pull origin main > /dev/null 2>&1
|
2019-04-03 13:03:19 +03:00
|
|
|
git checkout -b "$TRAIN_BRANCH" > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
git checkout --track -b "$TRAIN_BRANCH" "$REMOTE_BRANCH" > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git checkout "$TRAIN_BRANCH" > /dev/null 2>&1
|
|
|
|
git pull origin "$TRAIN_BRANCH" > /dev/null 2>&1 || true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 8. For each of the "main" packages...
|
|
|
|
bump() {
|
2020-02-04 04:47:59 +03:00
|
|
|
# 8.4. If package.json exists, update the version string in package.json.
|
2019-04-03 13:03:19 +03:00
|
|
|
if [ -f "$1/package.json" ]; then
|
|
|
|
sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_VERSION/$NEW_VERSION/g" "$1/package.json"
|
|
|
|
rm "$1/package.json.release.bak"
|
|
|
|
fi
|
|
|
|
|
2020-02-04 04:47:59 +03:00
|
|
|
# 8.5. If package-lock.json exists, update the version string in package-lock.json.
|
2019-04-03 13:03:19 +03:00
|
|
|
if [ -f "$1/package-lock.json" ]; then
|
|
|
|
sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_VERSION/$NEW_VERSION/g" "$1/package-lock.json"
|
|
|
|
rm "$1/package-lock.json.release.bak"
|
|
|
|
fi
|
|
|
|
|
2020-02-04 04:47:59 +03:00
|
|
|
# 8.6. If npm-shrinkwrap.json exists, update the version string in npm-shrinkwrap.json.
|
2019-04-03 13:03:19 +03:00
|
|
|
if [ -f "$1/npm-shrinkwrap.json" ]; then
|
|
|
|
sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_VERSION/$NEW_VERSION/g" "$1/npm-shrinkwrap.json"
|
|
|
|
rm "$1/npm-shrinkwrap.json.release.bak"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-30 00:29:22 +03:00
|
|
|
TARGETS="packages/fxa-auth-server
|
2020-02-22 03:57:15 +03:00
|
|
|
packages/fxa-admin-server
|
2020-02-27 02:10:14 +03:00
|
|
|
packages/fxa-admin-panel
|
2019-04-03 13:03:19 +03:00
|
|
|
packages/fxa-content-server
|
|
|
|
packages/fxa-customs-server
|
2019-04-12 18:18:39 +03:00
|
|
|
packages/fxa-event-broker
|
2019-08-16 08:45:53 +03:00
|
|
|
packages/fxa-geodb
|
2020-07-29 17:20:20 +03:00
|
|
|
packages/fxa-graphql-api
|
2019-07-11 13:13:30 +03:00
|
|
|
packages/fxa-payments-server
|
2019-07-23 16:11:04 +03:00
|
|
|
packages/fxa-profile-server
|
2020-07-29 17:20:20 +03:00
|
|
|
packages/fxa-react
|
2020-04-17 03:07:41 +03:00
|
|
|
packages/fxa-settings
|
2019-08-16 08:45:53 +03:00
|
|
|
packages/fxa-shared
|
2019-07-23 16:11:04 +03:00
|
|
|
packages/fxa-support-panel"
|
2019-04-03 13:03:19 +03:00
|
|
|
|
2019-06-24 08:39:54 +03:00
|
|
|
for TARGET in $TARGETS; do
|
2019-04-03 13:03:19 +03:00
|
|
|
bump "$TARGET"
|
2019-06-24 08:39:54 +03:00
|
|
|
done
|
2019-04-03 13:03:19 +03:00
|
|
|
|
2019-04-24 10:13:34 +03:00
|
|
|
# 9. Update the AUTHORS file
|
2019-04-25 16:42:44 +03:00
|
|
|
npm run authors > /dev/null
|
2019-04-24 10:13:34 +03:00
|
|
|
|
|
|
|
# 10. Commit changes.
|
2019-04-15 21:52:06 +03:00
|
|
|
git commit -a -m "Release $NEW_VERSION"
|
|
|
|
|
2019-04-24 10:13:34 +03:00
|
|
|
# 11. Create a tag.
|
2019-04-03 13:03:19 +03:00
|
|
|
git tag -a "$NEW_TAG" -m "$BUILD_TYPE release $NEW_VERSION"
|
|
|
|
|
|
|
|
|
2019-04-17 14:47:21 +03:00
|
|
|
if [ -f "$SCRIPT_DIR/create-deploy-bug.url" ]; then
|
2019-05-14 14:52:45 +03:00
|
|
|
DEPLOY_BUG_URL=`cat "$SCRIPT_DIR/create-deploy-bug.url" | sed "s/TRAIN_NUMBER/$TRAIN/"`
|
2019-04-17 14:47:21 +03:00
|
|
|
fi
|
|
|
|
|
2019-04-03 13:03:19 +03:00
|
|
|
|
2020-03-03 03:16:56 +03:00
|
|
|
# 12. Tell the user what we did.
|
2019-04-03 13:03:19 +03:00
|
|
|
echo
|
|
|
|
echo "Success! The release has been tagged locally but it hasn't been pushed."
|
|
|
|
echo "Before pushing, you should check that the changes appear to be sane."
|
|
|
|
echo "At the very least, eyeball the diffs and git log."
|
|
|
|
echo "If you're feeling particularly vigilant, you may want to run some of the tests and linters too."
|
|
|
|
echo
|
2020-03-03 03:16:56 +03:00
|
|
|
echo "Branch:"
|
2019-04-03 13:03:19 +03:00
|
|
|
echo
|
|
|
|
echo " $TRAIN_BRANCH"
|
|
|
|
echo
|
2020-03-03 03:16:56 +03:00
|
|
|
echo "Tag:"
|
2019-04-03 13:03:19 +03:00
|
|
|
echo
|
|
|
|
echo " $NEW_TAG"
|
|
|
|
echo
|
|
|
|
echo "When you're ready to push, paste the following lines into your terminal:"
|
|
|
|
echo
|
|
|
|
echo "git push origin $TRAIN_BRANCH"
|
|
|
|
echo "git push origin $NEW_TAG"
|
|
|
|
echo
|
2020-06-18 04:13:10 +03:00
|
|
|
echo "After that, you must open pull a request to merge the changes back to main:"
|
2019-04-03 13:03:19 +03:00
|
|
|
echo
|
|
|
|
echo " https://github.com/mozilla/fxa/compare/$TRAIN_BRANCH?expand=1"
|
|
|
|
echo
|
2020-04-03 01:05:03 +03:00
|
|
|
echo "Ask for review on the pull requests from @fxa-devs"
|
2019-10-12 00:02:28 +03:00
|
|
|
echo
|
2019-04-17 09:51:24 +03:00
|
|
|
|
2019-04-17 14:47:21 +03:00
|
|
|
if [ "$BUILD_TYPE" = "Train" ]; then
|
2020-03-06 00:57:35 +03:00
|
|
|
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2021-05-27 00:54:20 +03:00
|
|
|
TWO_WEEKS_AGO=$(date -v -14d +%Y-%m-%d)
|
2020-03-06 00:57:35 +03:00
|
|
|
else
|
2021-05-27 00:54:20 +03:00
|
|
|
TWO_WEEKS_AGO=$(date +%Y-%m-%d -d "14 days ago")
|
2020-03-06 00:57:35 +03:00
|
|
|
fi
|
|
|
|
|
2020-03-03 03:16:56 +03:00
|
|
|
echo "If there's no deploy bug for $TRAIN_BRANCH yet, you should create one using this URL (you'll need to update the title of the bug in Bugzilla):"
|
2019-04-17 14:47:21 +03:00
|
|
|
echo
|
2020-06-18 04:13:10 +03:00
|
|
|
echo " https://github.com/mozilla/fxa-private/blob/main/_scripts/create-deploy-bug.url"
|
2019-04-17 14:47:21 +03:00
|
|
|
echo
|
|
|
|
echo "Make sure you copy notes from the deploy doc:"
|
|
|
|
echo
|
|
|
|
echo " https://docs.google.com/document/d/1lc5T1ZvQZlhXY6j1l_VMeQT9rs1mN7yYIcHbRPR2IbQ"
|
|
|
|
echo
|
2019-10-12 00:02:28 +03:00
|
|
|
echo "And copy and paste the rest of this output into the bug:"
|
2019-04-17 14:47:21 +03:00
|
|
|
echo
|
2021-05-27 00:54:20 +03:00
|
|
|
echo "### Marked needs:qa (FxA)"
|
2019-08-20 18:32:34 +03:00
|
|
|
echo
|
2021-05-27 00:54:20 +03:00
|
|
|
echo "* https://github.com/mozilla/fxa/issues?utf8=%E2%9C%93&q=label%3Aneeds%3Aqa+is%3Aclosed+updated%3A%3E$TWO_WEEKS_AGO"
|
|
|
|
echo
|
|
|
|
echo "### Marked qa+ (SubPlat)"
|
|
|
|
echo
|
|
|
|
echo "* https://github.com/mozilla/fxa/issues?utf8=%E2%9C%93&q=label%3Aqa%2B+is%3Aclosed+updated%3A%3E$TWO_WEEKS_AGO"
|
2019-04-17 14:47:21 +03:00
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo "Don't forget to leave a comment in the deploy bug."
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2019-04-30 17:08:38 +03:00
|
|
|
echo "### Tags"
|
2019-08-20 18:32:34 +03:00
|
|
|
echo
|
2019-04-30 17:08:38 +03:00
|
|
|
echo "* https://github.com/mozilla/fxa/releases/tag/$NEW_TAG"
|
2019-04-17 14:47:21 +03:00
|
|
|
echo
|
|
|
|
|
2022-07-08 20:10:47 +03:00
|
|
|
echo "### Changelog"
|
|
|
|
echo
|
|
|
|
echo "* https://github.com/mozilla/fxa/releases"
|
|
|
|
echo
|