From cad9560d034cf5adf21a44da6db0cd59bed72331 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Thu, 2 Oct 2014 10:09:45 -0700 Subject: [PATCH] chore(release): create script to undo a release for given number --- scripts/angular.js/untag-release.sh | 40 ++++++++++++++++++ scripts/bower/unpublish.sh | 54 +++++++++++++++++++++++++ scripts/code.angularjs.org/unpublish.sh | 45 +++++++++++++++++++++ scripts/jenkins/undo-release.sh | 41 +++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100755 scripts/angular.js/untag-release.sh create mode 100755 scripts/bower/unpublish.sh create mode 100755 scripts/code.angularjs.org/unpublish.sh create mode 100755 scripts/jenkins/undo-release.sh diff --git a/scripts/angular.js/untag-release.sh b/scripts/angular.js/untag-release.sh new file mode 100755 index 000000000000..98f2040a22c4 --- /dev/null +++ b/scripts/angular.js/untag-release.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Untags a release. + +echo "###################################" +echo "## Untag angular.js for a release #" +echo "###################################" + +ARG_DEFS=( + "--action=(prepare|publish)" + # the version number of the release. + # e.g. 1.2.12 or 1.2.12-rc.1 + "--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)" +) + +function init { + TMP_DIR=$(resolveDir ../../tmp) + TAG_NAME="v$VERSION_NUMBER" +} + +function prepare() { + : +} + +function publish() { + # push the tag deletion to github + tags=`git ls-remote --tags git@github.com:angular/angular.js` + if [[ $tags =~ "refs/tags/v$VERSION_NUMBER^" ]]; then + echo "-- Creating dummy git repo for angular.js with origin remote" + mkdir $TMP_DIR/empty-angular.js + cd $TMP_DIR/empty-angular.js + git init + git remote add origin git@github.com:angular/angular.js.git + git push origin ":$TAG_NAME" + else + echo "-- Tag v$VERSION_NUMBER does not exist on remote. Moving on" + fi +} + +source $(dirname $0)/../utils.inc diff --git a/scripts/bower/unpublish.sh b/scripts/bower/unpublish.sh new file mode 100755 index 000000000000..60a1b79ddfce --- /dev/null +++ b/scripts/bower/unpublish.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Script for removing tags from the Angular bower repos + +echo "#################################" +echo "#### Untag bower ################" +echo "#################################" + +ARG_DEFS=( + "--action=(prepare|publish)" + "--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)" +) + +function init { + TMP_DIR=$(resolveDir ../../tmp) + REPOS=( + angular + angular-animate + angular-cookies + angular-i18n + angular-loader + angular-mocks + angular-route + angular-resource + angular-sanitize + angular-scenario + angular-touch + ) +} + +function prepare { + : +} + +function publish { + for repo in "${REPOS[@]}" + do + tags=`git ls-remote --tags git@github.com:angular/bower-$repo` + if [[ $tags =~ "refs/tags/v$VERSION_NUMBER" ]]; then + echo "-- Creating dummy git repo for bower-$repo with origin remote" + mkdir $TMP_DIR/bower-$repo + cd $TMP_DIR/bower-$repo + git init + git remote add origin git@github.com:angular/bower-$repo.git + git push origin :v$VERSION_NUMBER + echo "-- Deleting v$VERSION_NUMBER tag from bower-$repo" + cd $SCRIPT_DIR + else + echo "-- No remote tag matching v$VERSION_NUMBER exists on bower-$repo" + fi + done +} + +source $(dirname $0)/../utils.inc diff --git a/scripts/code.angularjs.org/unpublish.sh b/scripts/code.angularjs.org/unpublish.sh new file mode 100755 index 000000000000..26652a3f9e41 --- /dev/null +++ b/scripts/code.angularjs.org/unpublish.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Script for removing specified release dir from code.angularjs.org. + +echo "################################################" +echo "## Remove a version from code.angular.js.org ###" +echo "################################################" + +ARG_DEFS=( + "--action=(prepare|publish)" + "--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)" +) + +function init { + TMP_DIR=$(resolveDir ../../tmp) + REPO_DIR=$TMP_DIR/code.angularjs.org + echo "code tmp $TMP_DIR" +} + +function prepare { + echo "-- Cloning code.angularjs.org" + git clone git@github.com:angular/code.angularjs.org.git $REPO_DIR + + # + # Remove the files from the repo + # + echo "-- Removing $VERSION_NUMBER from code.angularjs.org" + cd $REPO_DIR + if [ -d "$VERSION_NUMBER" ]; then + git rm -r $VERSION_NUMBER + echo "-- Committing removal to code.angularjs.org" + git commit -m "removing v$VERSION_NUMBER" + else + echo "-- Version: $VERSION_NUMBER does not exist in code.angularjs.org!" + fi +} + +function publish { + cd $REPO_DIR + + echo "-- Pushing code.angularjs.org to github" + git push origin master +} + +source $(dirname $0)/../utils.inc diff --git a/scripts/jenkins/undo-release.sh b/scripts/jenkins/undo-release.sh new file mode 100755 index 000000000000..9813b0157ab4 --- /dev/null +++ b/scripts/jenkins/undo-release.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +echo "#################################" +echo "#### undo a release ############" +echo "#################################" + +ARG_DEFS=( + # require the git dryrun flag so the script can't be run without + # thinking about this! + "--git-push-dryrun=(true|false)" + # the version number of the release. + # e.g. 1.2.12 or 1.2.12-rc.1 + "--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)" +) + +function init { + if [[ ! $VERBOSE ]]; then + VERBOSE=false + fi + VERBOSE_ARG="--verbose=$VERBOSE" +} + +function phase { + ACTION_ARG="--action=$1" + VERSION_NUMBER_ARG="--version-number=$VERSION_NUMBER" + ../angular.js/untag-release.sh $ACTION_ARG $VERBOSE_ARG\ + --version-number=$VERSION_NUMBER + + # ../code.angularjs.org/unpublish.sh $ACTION_ARG $VERSION_NUMBER_ARG $VERBOSE_ARG + ../bower/unpublish.sh $ACTION_ARG $VERSION_NUMBER_ARG $VERBOSE_ARG +} + +function run { + # First prepare all scripts (build, commit, tag, ...), + # so we are sure everything is all right + phase prepare + # only then publish to github + phase publish +} + +source $(dirname $0)/../utils.inc