You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@senssoft.apache.org by le...@apache.org on 2018/03/12 15:58:49 UTC
[35/40] incubator-senssoft git commit: Added production release
scripts
Added production release scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/commit/29a4109b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/tree/29a4109b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft/diff/29a4109b
Branch: refs/heads/asf-site
Commit: 29a4109b736ceee0a10c1a2b7b0db2dc413419d0
Parents: 2b93e9b
Author: msbeard <ms...@apache.org>
Authored: Fri Jan 26 18:26:02 2018 -0500
Committer: msbeard <ms...@apache.org>
Committed: Fri Jan 26 18:26:02 2018 -0500
----------------------------------------------------------------------
.gitignore | 2 +
release/README.md | 30 ++++
release/clone-and-configure-repos.sh | 115 ++++++++++++++
release/common.sh | 71 +++++++++
release/make-release-artifacts.sh | 250 ++++++++++++++++++++++++++++++
5 files changed, 468 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/29a4109b/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c1edf37..4709039 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+release/incubator-*
+release/apache-*
.sass-cache
.jekyll-metadata
secret.py
http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/29a4109b/release/README.md
----------------------------------------------------------------------
diff --git a/release/README.md b/release/README.md
new file mode 100644
index 0000000..f233d97
--- /dev/null
+++ b/release/README.md
@@ -0,0 +1,30 @@
+Release Scripts and Helpers
+===========================
+
+This folder contains a number of items that will assist in the production of SensSoft releases.
+
+Release scripts - make-release-artifacts.sh
+-------------------------------------------
+`make-release-artifacts.sh` will produce the release artifacts with appropriate signatures. It is recommended to use
+this script rather than "rolling your own" or using a manual process, as this script codifies several Apache
+requirements about the release artifacts.
+
+These scripts are fully documented in **[Release Process](https://cwiki.apache.org/confluence/display/SENSSOFT/UserALE.js+Release+Management+Procedure)** page on Confluence.
+
+Quickstart
+----------
+1. Configure environment/prepare for release.
+ ```bash
+ ./clone-and-configure-repos.sh useralejs
+ ```
+ Ensure $APACHE_DIST_SVN_DIR is set in your environment.
+
+1. Change working directory to incubator-senssoft-useralejs.
+ ```bash
+ cd incubator-senssoft-userale.js
+ ```
+
+1. Release.
+ ```bash
+ ../make-release-artifacts.sh -r 1
+ ```
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/29a4109b/release/clone-and-configure-repos.sh
----------------------------------------------------------------------
diff --git a/release/clone-and-configure-repos.sh b/release/clone-and-configure-repos.sh
new file mode 100755
index 0000000..0fbfe14
--- /dev/null
+++ b/release/clone-and-configure-repos.sh
@@ -0,0 +1,115 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# set -e
+# set -x
+
+# Print out usage documentation.
+help_usage() {
+ echo "clone-and-configure-repos."
+ echo "A simple utility to configure SENSSOFT repostories and prepare them for release."
+ echo ""
+ echo "Usage: $ clone-and-configure-repos.sh COMMAND"
+ echo ""
+ help_commands
+ echo "e.g."
+ echo "$ $0 useralejs"
+}
+
+# Print out commands.
+help_commands() {
+ echo "The commands are:"
+ echo " useralejs Prepare for userale release"
+ echo " distill Prepare for distill release"
+ echo " tap Prepare for tap release"
+ echo " check Check environment for release"
+ echo ""
+}
+
+# Do the basics
+# git clone -o apache-git https://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs
+# cd incubator-senssoft-useralejs
+
+# git submodule init
+# git submodule update --remote --merge --recursive
+
+# .gitmodules sets the submodules up from GitHub. Replace the origin with Apache canonical
+# git submodule foreach 'git remote add apache-git https://git-wip-us.apache.org/repos/asf/${name}'
+# git submodule foreach 'git fetch apache-git'
+# git submodule foreach 'git checkout master'
+# git submodule foreach 'git branch --set-upstream-to apache-git/master master'
+# git submodule foreach 'git reset --hard apache-git/master'
+# git submodule foreach 'git remote remove origin'
+
+# Final check we are up to date
+# git pull
+# git submodule update --remote --merge --recursive
+
+# If no arguments were provided, display the usage.
+if [[ "$#" == "0" ]]; then
+ help_usage
+ exit 1
+fi
+
+# Check for a command argument.
+COMMAND=$1
+if [[ -z $COMMAND ]] || \
+ [[ $COMMAND != "check" && \
+ $COMMAND != "useralejs" && \
+ $COMMAND != "distill" && \
+ $COMMAND != "tap" ]]; then \
+ echo "Error: Specify a command."
+ echo ""
+ help_commands
+ exit 1
+fi
+
+# Prepare for UserALE deployment
+if [[ $COMMAND == "useralejs" ]]; then
+ # Do the basics
+ git clone -o apache-git https://git-wip-us.apache.org/repos/asf/incubator-senssoft-$COMMAND
+ cd incubator-senssoft-$COMMAND
+
+ # And also the location for publishing RC artifacts
+ svn --non-interactive co --depth=immediates https://dist.apache.org/repos/dist/release/incubator/senssoft ~/tmp/apache-dist-release-incubator-senssoft-$COMMAND
+ svn --non-interactive co --depth=immediates https://dist.apache.org/repos/dist/dev/incubator/senssoft ~/tmp/apache-dist-dev-incubator-senssoft-$COMMAND
+ echo "export APACHE_DIST_SVN_DIR=$HOME/tmp/apache-dist-dev-incubator-senssoft-$COMMAND" >> ~/.bash_profile
+ exit 0
+fi
+
+# Prepare for Distill deployment
+if [[ $COMMAND == "distill" ]]; then
+ echo "Error: Unsupported distill build."
+ exit 1
+fi
+
+# Prepare for Tap deployment
+if [[ $COMMAND == "tap" ]]; then
+ echo "Error: Unsupported tap build."
+ exit 1
+fi
+
+# Run production build process checks.
+if [[ $COMMAND == "check" ]]; then
+ echo "Error: Unsupported check build."
+ exit 1
+fi
+
+exit 0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/29a4109b/release/common.sh
----------------------------------------------------------------------
diff --git a/release/common.sh b/release/common.sh
new file mode 100644
index 0000000..14fad13
--- /dev/null
+++ b/release/common.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+###############################################################################
+fail() {
+ echo >&2 "$@"
+ exit 1
+}
+
+###############################################################################
+confirm() {
+ # call with a prompt string or use a default
+ if [ "${batch_confirm_y}" == "true" ] ; then
+ true
+ else
+ read -r -p "${1:-Are you sure? [y/N]} " response
+ case $response in
+ [yY][eE][sS]|[yY])
+ true
+ ;;
+ *)
+ false
+ ;;
+ esac
+ fi
+}
+
+###############################################################################
+detect_version() {
+ if [ \! -z "${current_version}" ]; then
+ return
+ fi
+
+ UNAMESTR=`uname`
+ if [[ "$UNAMESTR" == 'Linux' ]]; then
+ SED_EXTENDED='-r'
+ elif [[ "$UNAMESTR" == 'Darwin' ]]; then
+ SED_EXTENDED='-E'
+ fi;
+
+ current_version=`grep -m 1 "\"version\"" package.json | sed ${SED_EXTENDED} 's/^ *//;s/.*: *"//;s/",?//'`
+
+ if [ ! "$current_version" ]; then
+ echo "Error: Cannot find \"version\" in package.json" >&2;
+ exit 1;
+ else
+ echo $current_version ;
+ fi;
+}
+
+###############################################################################
+assert_in_project_root() {
+ [ -d .git ] || fail Must run in userale project root directory
+}
http://git-wip-us.apache.org/repos/asf/incubator-senssoft/blob/29a4109b/release/make-release-artifacts.sh
----------------------------------------------------------------------
diff --git a/release/make-release-artifacts.sh b/release/make-release-artifacts.sh
new file mode 100755
index 0000000..fc16a91
--- /dev/null
+++ b/release/make-release-artifacts.sh
@@ -0,0 +1,250 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Creates the following releases with archives (.tar.gz/.zip), signatures and checksums:
+# binary (-bin) - contains the userale dist binary release
+# source (-src) - contains all the source code files that are permitted to be released
+
+set -e
+
+# Import common script and run clone for useralejs
+release_script_dir=$( cd $( dirname $0 ) && pwd )
+[ -f "${release_script_dir}/common.sh" ] || {
+ echo >&2 "Could not find common.sh in the same directory as this script"
+ exit 1
+}
+. "${release_script_dir}/common.sh"
+
+###############################################################################
+show_help() {
+ cat >&2 <<END
+Usage: make-release-artifacts.sh [-v version] [-r rc_number]
+Prepares and builds the source and binary distribution artifacts of a SensSoft
+release.
+
+ -vVERSION overrides the name of this version, if detection
+ from package.json is not accurate for any reason.
+ -rRC_NUMBER specifies the release candidate number. The
+ produced artifact names include the 'rc' suffix,
+ but the contents of the archive artifact do *not*
+ include the suffix. Therefore, turning a release
+ candidate into a release requires only renaming
+ the artifacts.
+ -y answers "y" to all questions automatically, to
+ use defaults and make this suitable for batch mode
+ -n dry run - NPM deployments and SVN commits will
+ NOT be done. This will still delete working and
+ temporary files, however.
+
+Specifying the RC number is required. Specifying the version number is
+discouraged; if auto detection is not working, then this script is buggy.
+
+Additionally if APACHE_DIST_SVN_DIR is set, this will transfer artifacts to
+that directory.
+END
+}
+
+###############################################################################
+# Argument parsing
+rc_suffix=
+OPTIND=1
+while getopts "h?v:r:y?:n?" opt; do
+ case "$opt" in
+ h|\?)
+ show_help
+ exit 0
+ ;;
+ v)
+ current_version=$OPTARG
+ ;;
+ r)
+ rc_suffix=$OPTARG
+ ;;
+ y)
+ batch_confirm_y=true
+ ;;
+ n)
+ dry_run=true
+ ;;
+ *)
+ show_help
+ exit 1
+ esac
+done
+
+shift $((OPTIND-1))
+[ "$1" = "--" ] && shift
+
+###############################################################################
+# Prerequisite checks
+assert_in_project_root
+
+detect_version
+
+###############################################################################
+# Determine all filenames and paths, and confirm
+
+release_name=apache-senssoft-useralejs-${current_version}
+if [ -z "$rc_suffix" ]; then
+ fail Specifying the RC number is required
+else
+ artifact_name=${release_name}-rc${rc_suffix}
+fi
+
+userale_dir=$( pwd )
+working_dir=${TMPDIR:-/tmp}/release-working-dir
+rm -rf ${working_dir}
+staging_dir="${working_dir}/source/"
+src_staging_dir="${working_dir}/source/${release_name}-src"
+bin_staging_dir="${working_dir}/bin/"
+artifact_dir="${release_script_dir}/${artifact_name}"
+
+echo "The version is ${current_version}"
+echo "The rc suffix is rc${rc_suffix}"
+echo "The release name is ${release_name}"
+echo "The artifact name is ${artifact_name}"
+echo "The artifact directory is ${artifact_dir}"
+if [ -z "${dry_run}" -a ! -z "${APACHE_DIST_SVN_DIR}" ] ; then
+ echo "The artifacts will be copied to ${APACHE_DIST_SVN_DIR} and readied for commit"
+else
+ echo "The artifacts will not be copied into a Subversion working copy"
+fi
+echo "The working directory is ${working_dir}"
+echo ""
+confirm "Is this information correct? [y/N]" || exit
+echo ""
+echo "WARNING! This script will run 'git clean -dxf' to remove ALL files that are not under Git source control."
+echo "This includes build artifacts and all uncommitted local files and directories."
+echo "If you want to check what will happen, answer no and run 'git clean -dxn' to dry run."
+echo ""
+confirm || exit
+if [ -z "${dry_run}" ]; then
+ echo ""
+ echo "This script will cause uploads to be made to a staging repository on the Apache Nexus server."
+ echo ""
+ confirm "Shall I continue? [y/N]" || exit
+fi
+
+# Set up GPG agent
+if [ ! -z "${GPG_AGENT_INFO}" ]; then
+ echo "GPG_AGENT_INFO set; assuming gpg-agent is running correctly."
+else
+ eval $(gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info)
+ GPG_TTY=$(tty)
+ export GPG_TTY GPG_AGENT_INFO
+fi
+
+# A GPG no-op, but causes the password request to happen. It should then be cached by gpg-agent.
+gpg2 -o /dev/null --sign /dev/null
+
+# Discover submodules
+# submodules="$( perl -n -e 'if ($_ =~ /path += +(.*)$/) { print $1."\n" }' < .gitmodules )"
+# modules=". ${submodules}"
+
+###############################################################################
+# Clean the workspace
+# for module in ${modules}; do ( cd $module && git clean -dxf ); done
+
+###############################################################################
+# Source release
+echo "Creating source release folder called ${src_staging_dir} for ${release_name}"
+set -x
+mkdir -p ${src_staging_dir}
+
+# exclude:
+# * docs (which isn't part of the release, and adding license headers to js files is cumbersome)
+rsync -rtp --exclude .git\* --exclude userale-docs/ --exclude node_modules . ${staging_dir}/${release_name}-src
+
+rm -rf ${artifact_dir}
+mkdir -p ${artifact_dir}
+set +x
+echo "Creating artifact ${artifact_dir}/${artifact_name}-src.tar.gz and .zip"
+set -x
+( cd ${staging_dir} && tar czf ${artifact_dir}/${artifact_name}-src.tar.gz ${release_name}-src )
+( cd ${staging_dir} && zip -qr ${artifact_dir}/${artifact_name}-src.zip ${release_name}-src )
+
+# ###############################################################################
+# Binary release
+set +x
+echo "Proceeding to build binary release in ${bin_staging_dir}"
+set -x
+
+mkdir -p ${bin_staging_dir}
+
+# Perform the build
+( cd ${src_staging_dir} && npm install && npm run build && npm test)
+
+set +x
+echo "Make artifacts"
+set -x
+
+# copy js and min version of userale.js
+mkdir ${bin_staging_dir}/${release_name}-bin
+
+cp ${src_staging_dir}/build/userale-*.js ${bin_staging_dir}/${release_name}-bin
+
+# copy in the LICENSE, README and NOTICE
+cp ${src_staging_dir}/README.md ${bin_staging_dir}/${release_name}-bin
+cp ${src_staging_dir}/LICENSE ${bin_staging_dir}/${release_name}-bin
+cp ${src_staging_dir}/NOTICE ${bin_staging_dir}/${release_name}-bin
+
+( cd ${bin_staging_dir} && tar czf ${artifact_dir}/${artifact_name}-bin.tar.gz ${release_name}-bin )
+( cd ${bin_staging_dir} && zip -qr ${artifact_dir}/${artifact_name}-bin.zip ${release_name}-bin )
+
+###############################################################################
+# Signatures and checksums
+
+# OSX doesn't have md5sum, sha1sum, and sha256sum, even if MacPorts md5sha1sum package is installed.
+# Easy to fake it though.
+which md5sum >/dev/null || alias md5sum='md5 -r' && shopt -s expand_aliases
+which sha1sum >/dev/null || alias sha1sum='shasum -a 1' && shopt -s expand_aliases
+which sha256sum >/dev/null || alias sha256sum='shasum -a 256' && shopt -s expand_aliases
+
+( cd ${artifact_dir} &&
+ for a in *.tar.gz *.zip; do
+ md5sum ${a} > ${a}.md5
+ sha1sum -b ${a} > ${a}.sha1
+ sha256sum -b ${a} > ${a}.sha256
+ gpg2 --armor --output ${a}.asc --detach-sig ${a}
+ done
+)
+
+###############################################################################
+# Publish to dist repo
+
+if [ -z "${dry_run}" -a ! -z "${APACHE_DIST_SVN_DIR}" ] ; then (
+ cd ${APACHE_DIST_SVN_DIR}
+ [ -d ${artifact_name} ] && ( svn --non-interactive revert -R ${artifact_name}; svn --non-interactive rm --force ${artifact_name}; rm -rf ${artifact_name} )
+ cp -r ${artifact_dir} ${artifact_name}
+ svn --non-interactive add ${artifact_name}
+ )
+ artifact_dir=${APACHE_DIST_SVN_DIR}/${artifact_name}
+fi
+
+###############################################################################
+# Conclusion
+
+set +x
+echo "The release is done - here is what has been created:"
+ls ${artifact_dir}
+echo "You can find these files in: ${artifact_dir}"
+echo "The git commit IDs for the voting emails are:"
+echo -n "incubator-senssoft-userale: " && git rev-parse HEAD
+git submodule --quiet foreach 'echo -n "${name}: " && git rev-parse HEAD'
\ No newline at end of file