-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24372][build] Add scripts to help with preparing releases. #21515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
44454b6
1366f23
04f6371
48eda71
7fe133a
faab8ae
82ae00e
5771354
a39933e
b6d4c70
745342d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/usr/bin/env 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 | ||
| SELF=$(cd $(dirname $0) && pwd) | ||
| . "$SELF/release-util.sh" | ||
|
|
||
| WORKDIR= | ||
| IMGTAG=latest | ||
| while getopts "d:n:t:" opt; do | ||
| case $opt in | ||
| d) WORKDIR="$OPTARG" ;; | ||
| n) DRY_RUN=1 ;; | ||
| t) IMGTAG="$OPTARG" ;; | ||
| ?) error "Invalid option: $OPTARG" ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -z "$WORKDIR" ] || [ ! -d "$WORKDIR" ]; then | ||
| error "Work directory (-d) must be defined and exist." | ||
| fi | ||
|
|
||
| if [ -d "$WORKDIR/output" ]; then | ||
| read -p "Output directory already exists. Overwrite and continue? [y/n] " ANSWER | ||
| if [ "$ANSWER" != "y" ]; then | ||
| error "Exiting." | ||
| fi | ||
| fi | ||
|
|
||
| cd "$WORKDIR" | ||
| rm -rf "$WORKDIR/output" | ||
| mkdir "$WORKDIR/output" | ||
|
|
||
| get_release_info | ||
|
|
||
| # Place all RM scripts and necessary data in a local directory that must be defined in the command | ||
| # line. This directory is mounted into the image. | ||
| for f in "$SELF"/*; do | ||
| if [ -f "$f" ]; then | ||
| cp "$f" "$WORKDIR" | ||
| fi | ||
| done | ||
| GPG_KEY_FILE="$WORKDIR/gpg.key" | ||
| fcreate_secure "$GPG_KEY_FILE" | ||
| $GPG --export-secret-key --armor "$GPG_KEY" > "$GPG_KEY_FILE" | ||
|
|
||
| run_silent "Building spark-rm image with tag $IMGTAG..." "docker-build.log" \ | ||
| docker build -t "spark-rm:$IMGTAG" --build-arg UID=$UID "$SELF/spark-rm" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need to do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it. This is a system variable. So we can't run this script with root user... |
||
|
|
||
| # Write the release information to a file with environment variables to be used when running the | ||
| # image. | ||
| ENVFILE="$WORKDIR/env.list" | ||
| fcreate_secure "$ENVFILE" | ||
|
|
||
| function cleanup { | ||
| rm -f "$ENVFILE" | ||
| rm -f "$GPG_KEY_FILE" | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| cat > $ENVFILE <<EOF | ||
| DRY_RUN=$DRY_RUN | ||
| SKIP_TAG=$SKIP_TAG | ||
| RUNNING_IN_DOCKER=1 | ||
| GIT_BRANCH=$GIT_BRANCH | ||
| NEXT_VERSION=$NEXT_VERSION | ||
| RELEASE_VERSION=$RELEASE_VERSION | ||
| RELEASE_TAG=$RELEASE_TAG | ||
| GIT_REF=$GIT_REF | ||
| SPARK_PACKAGE_VERSION=$SPARK_PACKAGE_VERSION | ||
| ASF_USERNAME=$ASF_USERNAME | ||
| GIT_NAME=$GIT_NAME | ||
| GIT_EMAIL=$GIT_EMAIL | ||
| GPG_KEY=$GPG_KEY | ||
| ASF_PASSWORD=$ASF_PASSWORD | ||
| GPG_PASSPHRASE=$GPG_PASSPHRASE | ||
| EOF | ||
|
|
||
| echo "Building $RELEASE_TAG; output will be at $WORKDIR/output" | ||
| docker run \ | ||
| --env-file "$ENVFILE" \ | ||
| --volume "$WORKDIR":/opt/spark-rm \ | ||
| "spark-rm:$IMGTAG" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env 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. | ||
| # | ||
|
|
||
| SELF=$(cd $(dirname $0) && pwd) | ||
| . "$SELF/release-util.sh" | ||
|
|
||
| while getopts "bn" opt; do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be nice to have a high level description in the script just saying this does a release which does things like tag, build, etc and pushes things to the asf spark repo. |
||
| case $opt in | ||
| b) GIT_BRANCH=$OPTARG ;; | ||
| n) DRY_RUN=1 ;; | ||
| ?) error "Invalid option: $OPTARG" ;; | ||
| esac | ||
| done | ||
|
|
||
| set -e | ||
|
|
||
| if [ "$RUNNING_IN_DOCKER" = "1" ]; then | ||
| # Inside docker, need to import the GPG key stored in the current directory. | ||
| echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 "$SELF/gpg.key" | ||
| else | ||
| # Outside docker, need to ask for information about the release. | ||
| get_release_info | ||
| fi | ||
|
|
||
| if [ $SKIP_TAG = 0 ]; then | ||
| run_silent "Creating release tag $RELEASE_TAG..." "tag.log" \ | ||
| "$SELF/release-tag.sh" | ||
| else | ||
| echo "Skipping tag creation for $RELEASE_TAG." | ||
| fi | ||
|
|
||
| run_silent "Building Spark..." "build.log" \ | ||
| "$SELF/release-build.sh" package | ||
| run_silent "Building documentation..." "docs.log" \ | ||
| "$SELF/release-build.sh" docs | ||
| run_silent "Publishing release" "publish.log" \ | ||
| "$SELF/release-build.sh" publish-release | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| #!/usr/bin/env 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. | ||
| # | ||
|
|
||
| DRY_RUN=${DRY_RUN:-0} | ||
| GPG="gpg --no-tty --batch" | ||
| ASF_REPO="https://git-wip-us.apache.org/repos/asf/spark.git" | ||
| ASF_REPO_WEBUI="https://git-wip-us.apache.org/repos/asf?p=spark.git" | ||
|
|
||
| function error { | ||
| echo "$*" | ||
| exit 1 | ||
| } | ||
|
|
||
| function read_config { | ||
| local PROMPT="$1" | ||
| local DEFAULT="$2" | ||
| local REPLY= | ||
|
|
||
| read -p "$PROMPT [$DEFAULT]: " REPLY | ||
| local RETVAL="${REPLY:-$DEFAULT}" | ||
| if [ -z "$RETVAL" ]; then | ||
| error "$PROMPT is must be provided." | ||
| fi | ||
| echo "$RETVAL" | ||
| } | ||
|
|
||
| function parse_version { | ||
| grep -e '<version>.*</version>' | \ | ||
| head -n 2 | tail -n 1 | cut -d'>' -f2 | cut -d '<' -f1 | ||
| } | ||
|
|
||
| function run_silent { | ||
| local BANNER="$1" | ||
| shift | ||
| local LOG_FILE="$1" | ||
| shift | ||
|
|
||
| echo "==================================" | ||
| echo "= $BANNER" | ||
| echo "Command: $@" | ||
| echo "Log file: $LOG_FILE" | ||
|
|
||
| if [ $DRY_RUN = 0 ]; then | ||
| "$@" 1>"$LOG_FILE" 2>&1 | ||
| else | ||
| echo "$@" | ||
| touch "$LOG_FILE" | ||
| fi | ||
|
|
||
| local EC=$? | ||
| if [ $EC != 0 ]; then | ||
| echo "Command FAILED. Check full logs for details." | ||
| tail "$LOG_FILE" | ||
| return $EC | ||
| fi | ||
| } | ||
|
|
||
| function fcreate_secure { | ||
| local FPATH="$1" | ||
| rm -f "$FPATH" | ||
| touch "$FPATH" | ||
| chmod 600 "$FPATH" | ||
| } | ||
|
|
||
| function check_for_tag { | ||
| curl -s --head --fail "$ASF_REPO_WEBUI;a=commit;h=$1" >/dev/null | ||
| } | ||
|
|
||
| function get_release_info { | ||
| if [ -z "$GIT_BRANCH" ]; then | ||
| # If no branch is specified, found out the latest branch from the repo. | ||
| GIT_BRANCH=$(git ls-remote --heads "$ASF_REPO" | | ||
| grep -v refs/heads/master | | ||
| awk '{print $2}' | | ||
| sort -r | | ||
| head -n 1 | | ||
| cut -d/ -f3) | ||
| fi | ||
|
|
||
| export GIT_BRANCH=$(read_config "Branch" "$GIT_BRANCH") | ||
|
|
||
| # Find the current version for the branch. | ||
| local VERSION=$(curl -s "$ASF_REPO_WEBUI;a=blob_plain;f=pom.xml;hb=refs/heads/$GIT_BRANCH" | | ||
| parse_version) | ||
| echo "Current branch version is $VERSION." | ||
|
|
||
| if [[ ! $VERSION =~ .*-SNAPSHOT ]]; then | ||
| error "Not a SNAPSHOT version: $VERSION" | ||
| fi | ||
|
|
||
| NEXT_VERSION="$VERSION" | ||
| RELEASE_VERSION="${VERSION/-SNAPSHOT/}" | ||
| SHORT_VERSION=$(echo "$VERSION" | cut -d . -f 1-2) | ||
| local REV=$(echo "$VERSION" | cut -d . -f 3) | ||
|
|
||
| # Find out what rc is being prepared. | ||
| # - If the current version is "x.y.0", then this is rc1 of the "x.y.0" release. | ||
| # - If not, need to check whether the previous version has been already released or not. | ||
| # - If it has, then we're building rc1 of the current version. | ||
| # - If it has not, we're building the next RC of the previous version. | ||
| local RC_COUNT | ||
| if [ $REV != 0 ]; then | ||
| local PREV_REL_REV=$((REV - 1)) | ||
| local PREV_REL_TAG="v${SHORT_VERSION}.${PREV_REL_REV}" | ||
| if check_for_tag "$PREV_REL_TAG"; then | ||
| RC_COUNT=1 | ||
| REV=$((REV + 1)) | ||
| NEXT_VERSION="${SHORT_VERSION}-${REV}-SNAPSHOT" | ||
| else | ||
| RELEASE_VERSION="${SHORT_VERSION}.${PREV_REL_REV}" | ||
| RC_COUNT=$(git ls-remote --tags "$ASF_REPO" "v${RELEASE_VERSION}-rc*" | wc -l) | ||
| RC_COUNT=$((RC_COUNT + 1)) | ||
| fi | ||
| else | ||
| REV=$((REV + 1)) | ||
| NEXT_VERSION="${SHORT_VERSION}-${REV}-SNAPSHOT" | ||
| RC_COUNT=1 | ||
| fi | ||
|
|
||
| export NEXT_VERSION | ||
| export RELEASE_VERSION=$(read_config "Release" "$RELEASE_VERSION") | ||
|
|
||
| RC_COUNT=$(read_config "RC #" "$RC_COUNT") | ||
|
|
||
| # Check if the RC already exists, and if re-creating the RC, skip tag creation. | ||
| RELEASE_TAG="v${RELEASE_VERSION}-rc${RC_COUNT}" | ||
| SKIP_TAG=0 | ||
| if check_for_tag "RELEASE_TAG"; then | ||
|
||
| read -p "$RELEASE_TAG already exists. Continue anyway [y/n]? " ANSWER | ||
| if [ "$ANSWER" != "y" ]; then | ||
| error "Exiting." | ||
| fi | ||
| SKIP_TAG=1 | ||
| fi | ||
|
|
||
| export RELEASE_TAG | ||
| export GIT_REF="$RELEASE_TAG" | ||
| export SPARK_PACKAGE_VERSION="$RELEASE_TAG" | ||
|
|
||
| # Gather some user information. | ||
| export ASF_USERNAME=$(read_config "ASF user" "$LOGNAME") | ||
|
|
||
| GIT_NAME=$(git config user.name) | ||
|
||
| export GIT_NAME=$(read_config "Full name" "$GIT_NAME") | ||
|
|
||
| export GIT_EMAIL="[email protected]" | ||
| export GPG_KEY=$(read_config "GPG key" "$GIT_EMAIL") | ||
|
|
||
| cat <<EOF | ||
| ================ | ||
| Release details: | ||
| BRANCH: $GIT_BRANCH | ||
| VERSION: $RELEASE_VERSION | ||
| TAG: $RELEASE_TAG | ||
| NEXT: $NEXT_VERSION | ||
|
|
||
| ASF USER: $ASF_USERNAME | ||
| GPG KEY: $GPG_KEY | ||
| FULL NAME: $GIT_NAME | ||
| E-MAIL: $GIT_EMAIL | ||
| ================ | ||
| EOF | ||
|
|
||
| read -p "Is this info correct [y/n]? " ANSWER | ||
| if [ "$ANSWER" != "y" ]; then | ||
| echo "Exiting." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$ASF_PASSWORD" ]; then | ||
| stty -echo && printf "ASF password: " && read ASF_PASSWORD && printf '\n' && stty echo | ||
| export ASF_PASSWORD | ||
| fi | ||
|
|
||
| if [ -z "$GPG_PASSPHRASE" ]; then | ||
| stty -echo && printf "GPG passphrase: " && read GPG_PASSPHRASE && printf '\n' && stty echo | ||
| export GPG_PASSPHRASE | ||
| fi | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even if rat doesn't check, isn't vote.tmpl packaged into the source release this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example,
.gitis removed from release here https://github.com/apache/spark/blob/master/dev/create-release/release-build.sh#L157There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying this file should not be packaged in the source release? Not sure I see why that would be the case. There's a lot of stuff in
.rat-excludesthat is still packaged.