Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 1 | #! /bin/bash -e |
Matt Caswell | a28d06f | 2021-02-18 14:57:13 +0000 | [diff] [blame] | 2 | # Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 | # this file except in compliance with the License. You can obtain a copy |
| 6 | # in the file LICENSE in the source distribution or at |
| 7 | # https://www.openssl.org/source/license.html |
| 8 | |
| 9 | # This is the most shell agnostic way to specify that POSIX rules. |
| 10 | POSIXLY_CORRECT=1 |
| 11 | |
| 12 | usage () { |
| 13 | cat <<EOF |
| 14 | Usage: release.sh [ options ... ] |
| 15 | |
| 16 | --alpha Start or increase the "alpha" pre-release tag. |
| 17 | --next-beta Switch to the "beta" pre-release tag after alpha release. |
| 18 | It can only be given with --alpha. |
| 19 | --beta Start or increase the "beta" pre-release tag. |
| 20 | --final Get out of "alpha" or "beta" and make a final release. |
| 21 | Implies --branch. |
| 22 | |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 23 | --branch Create a release branch 'openssl-{major}.{minor}', |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 24 | where '{major}' and '{minor}' are the major and minor |
| 25 | version numbers. |
| 26 | |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 27 | --reviewer=<id> The reviewer of the commits. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 28 | --local-user=<keyid> |
| 29 | For the purpose of signing tags and tar files, use this |
| 30 | key (default: use the default e-mail address’ key). |
| 31 | |
| 32 | --no-upload Don't upload to upload@dev.openssl.org. |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 33 | --no-update Don't perform 'make update' and 'make update-fips-checksums'. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 34 | --verbose Verbose output. |
| 35 | --debug Include debug output. Implies --no-upload. |
| 36 | |
| 37 | --force Force execution |
| 38 | |
| 39 | --help This text |
| 40 | --manual The manual |
| 41 | |
| 42 | If none of --alpha, --beta, or --final are given, this script tries to |
| 43 | figure out the next step. |
| 44 | EOF |
| 45 | exit 0 |
| 46 | } |
| 47 | |
| 48 | # Set to one of 'major', 'minor', 'alpha', 'beta' or 'final' |
| 49 | next_method= |
| 50 | next_method2= |
| 51 | |
| 52 | do_branch=false |
| 53 | warn_branch=false |
| 54 | |
| 55 | do_clean=true |
| 56 | do_upload=true |
| 57 | do_update=true |
| 58 | DEBUG=: |
| 59 | VERBOSE=: |
| 60 | git_quiet=-q |
| 61 | |
| 62 | force=false |
| 63 | |
| 64 | do_help=false |
| 65 | do_manual=false |
| 66 | |
| 67 | tagkey=' -s' |
| 68 | gpgkey= |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 69 | reviewers= |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 70 | |
| 71 | upload_address=upload@dev.openssl.org |
| 72 | |
| 73 | TEMP=$(getopt -l 'alpha,next-beta,beta,final' \ |
| 74 | -l 'branch' \ |
| 75 | -l 'no-upload,no-update' \ |
| 76 | -l 'verbose,debug' \ |
| 77 | -l 'local-user:' \ |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 78 | -l 'reviewer:' \ |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 79 | -l 'force' \ |
| 80 | -l 'help,manual' \ |
| 81 | -n release.sh -- - "$@") |
| 82 | eval set -- "$TEMP" |
| 83 | while true; do |
| 84 | case $1 in |
| 85 | --alpha | --beta | --final ) |
| 86 | next_method=$(echo "x$1" | sed -e 's|^x--||') |
| 87 | if [ -z "$next_method2" ]; then |
| 88 | next_method2=$next_method |
| 89 | fi |
| 90 | shift |
| 91 | if [ "$next_method" = 'final' ]; then |
| 92 | do_branch=true |
| 93 | fi |
| 94 | ;; |
| 95 | --next-beta ) |
| 96 | next_method2=$(echo "x$1" | sed -e 's|^x--next-||') |
| 97 | shift |
| 98 | ;; |
| 99 | --branch ) |
| 100 | do_branch=true |
| 101 | warn_branch=true |
| 102 | shift |
| 103 | ;; |
| 104 | --no-upload ) |
| 105 | do_upload=false |
| 106 | shift |
| 107 | ;; |
| 108 | --no-update ) |
| 109 | do_update=false |
| 110 | shift |
| 111 | ;; |
| 112 | --verbose ) |
| 113 | VERBOSE=echo |
| 114 | git_quiet= |
| 115 | shift |
| 116 | ;; |
| 117 | --debug ) |
| 118 | DEBUG=echo |
| 119 | do_upload=false |
| 120 | shift |
| 121 | ;; |
| 122 | --local-user ) |
| 123 | shift |
Richard Levitte | 93bae03 | 2020-11-09 08:39:39 +0100 | [diff] [blame] | 124 | tagkey=" -u $1" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 125 | gpgkey=" -u $1" |
| 126 | shift |
| 127 | ;; |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 128 | --reviewer ) |
| 129 | reviewers="$reviewers $1=$2" |
| 130 | shift |
| 131 | shift |
| 132 | ;; |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 133 | --force ) |
| 134 | force=true |
| 135 | shift |
| 136 | ;; |
| 137 | --help ) |
| 138 | usage |
| 139 | exit 0 |
| 140 | ;; |
| 141 | --manual ) |
| 142 | sed -e '1,/^### BEGIN MANUAL/d' \ |
| 143 | -e '/^### END MANUAL/,$d' \ |
| 144 | < "$0" \ |
| 145 | | pod2man \ |
| 146 | | man -l - |
| 147 | exit 0 |
| 148 | ;; |
| 149 | -- ) |
| 150 | shift |
| 151 | break |
| 152 | ;; |
| 153 | * ) |
| 154 | echo >&2 "Unknown option $1" |
| 155 | shift |
| 156 | exit 1 |
| 157 | ;; |
| 158 | esac |
| 159 | done |
| 160 | |
| 161 | $DEBUG >&2 "DEBUG: \$next_method=$next_method" |
| 162 | $DEBUG >&2 "DEBUG: \$next_method2=$next_method2" |
| 163 | |
| 164 | $DEBUG >&2 "DEBUG: \$do_branch=$do_branch" |
| 165 | |
| 166 | $DEBUG >&2 "DEBUG: \$do_upload=$do_upload" |
| 167 | $DEBUG >&2 "DEBUG: \$do_update=$do_update" |
| 168 | $DEBUG >&2 "DEBUG: \$DEBUG=$DEBUG" |
| 169 | $DEBUG >&2 "DEBUG: \$VERBOSE=$VERBOSE" |
| 170 | $DEBUG >&2 "DEBUG: \$git_quiet=$git_quiet" |
| 171 | |
| 172 | case "$next_method+$next_method2" in |
| 173 | major+major | minor+minor ) |
| 174 | # These are expected |
| 175 | ;; |
| 176 | alpha+alpha | alpha+beta | beta+beta | final+final | + | +beta ) |
| 177 | # These are expected |
| 178 | ;; |
| 179 | * ) |
| 180 | echo >&2 "Internal option error ($next_method, $next_method2)" |
| 181 | exit 1 |
| 182 | ;; |
| 183 | esac |
| 184 | |
| 185 | # Verbosity feed for certain commands |
| 186 | VERBOSITY_FIFO=/tmp/openssl-$$.fifo |
| 187 | mkfifo -m 600 $VERBOSITY_FIFO |
| 188 | ( cat $VERBOSITY_FIFO | while read L; do $VERBOSE "> $L"; done ) & |
| 189 | exec 42>$VERBOSITY_FIFO |
| 190 | trap "exec 42>&-; rm $VERBOSITY_FIFO" 0 2 |
| 191 | |
| 192 | # Setup ############################################################## |
| 193 | |
| 194 | # Make sure we're in the work directory |
| 195 | cd $(dirname $0)/.. |
| 196 | HERE=$(pwd) |
| 197 | |
| 198 | # Check that we have the scripts that define functions we use |
| 199 | found=true |
| 200 | for fn in "$HERE/dev/release-aux/release-version-fn.sh" \ |
| 201 | "$HERE/dev/release-aux/release-state-fn.sh"; do |
| 202 | if ! [ -f "$fn" ]; then |
| 203 | echo >&2 "'$fn' is missing" |
| 204 | found=false |
| 205 | fi |
| 206 | done |
| 207 | if ! $found; then |
| 208 | exit 1 |
| 209 | fi |
| 210 | |
| 211 | # Load version functions |
| 212 | . $HERE/dev/release-aux/release-version-fn.sh |
| 213 | . $HERE/dev/release-aux/release-state-fn.sh |
| 214 | |
| 215 | # Make sure it's a branch we recognise |
| 216 | orig_branch=$(git rev-parse --abbrev-ref HEAD) |
| 217 | if (echo "$orig_branch" \ |
| 218 | | grep -E -q \ |
| 219 | -e '^master$' \ |
| 220 | -e '^OpenSSL_[0-9]+_[0-9]+_[0-9]+[a-z]*-stable$' \ |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 221 | -e '^openssl-[0-9]+\.[0-9]+$'); then |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 222 | : |
| 223 | elif $force; then |
| 224 | : |
| 225 | else |
| 226 | echo >&2 "Not in master or any recognised release branch" |
| 227 | echo >&2 "Please 'git checkout' an approprite branch" |
| 228 | exit 1 |
| 229 | fi |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 230 | orig_HEAD=$(git rev-parse HEAD) |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 231 | |
| 232 | # Initialize ######################################################### |
| 233 | |
| 234 | echo "== Initializing work tree" |
| 235 | |
| 236 | get_version |
| 237 | |
| 238 | # Generate a cloned directory name |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 239 | release_clone="$orig_branch-release-tmp" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 240 | |
| 241 | echo "== Work tree will be in $release_clone" |
| 242 | |
| 243 | # Make a clone in a subdirectory and move there |
| 244 | if ! [ -d "$release_clone" ]; then |
| 245 | $VERBOSE "== Cloning to $release_clone" |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 246 | git clone $git_quiet -b "$orig_branch" -o parent . "$release_clone" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 247 | fi |
| 248 | cd "$release_clone" |
| 249 | |
| 250 | get_version |
| 251 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 252 | # Branches we will work with. The release branch is where we make the |
| 253 | # changes for the release, the update branch is where we make the post- |
| 254 | # release changes |
| 255 | update_branch="$orig_branch" |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 256 | release_branch="openssl-$SERIES" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 257 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 258 | # among others, we only create a release branch if the patch number is zero |
| 259 | if [ "$update_branch" = "$release_branch" ] || [ $PATCH -ne 0 ]; then |
| 260 | if $do_branch && $warn_branch; then |
| 261 | echo >&2 "Warning! We're already in a release branch; --branch ignored" |
| 262 | fi |
| 263 | do_branch=false |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 264 | fi |
| 265 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 266 | if ! $do_branch; then |
| 267 | release_branch="$update_branch" |
| 268 | fi |
| 269 | |
| 270 | # Branches we create for PRs |
| 271 | branch_version="$VERSION${PRE_LABEL:+-$PRE_LABEL$PRE_NUM}" |
| 272 | tmp_update_branch="OSSL--$update_branch--$branch_version" |
| 273 | tmp_release_branch="OSSL--$release_branch--$branch_version" |
| 274 | |
| 275 | # Check that we're still on the same branch as our parent repo, or on a |
| 276 | # release branch |
| 277 | current_branch=$(git rev-parse --abbrev-ref HEAD) |
| 278 | if [ "$current_branch" = "$update_branch" ]; then |
| 279 | : |
| 280 | elif [ "$current_branch" = "$release_branch" ]; then |
| 281 | : |
| 282 | else |
| 283 | echo >&2 "The cloned sub-directory '$release_clone' is on a branch" |
| 284 | if [ "$update_branch" = "$release_branch" ]; then |
| 285 | echo >&2 "other than '$update_branch'." |
| 286 | else |
| 287 | echo >&2 "other than '$update_branch' or '$release_branch'." |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 288 | fi |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 289 | echo >&2 "Please 'cd \"$(pwd)\"; git checkout $update_branch'" |
| 290 | exit 1 |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 291 | fi |
| 292 | |
| 293 | SOURCEDIR=$(pwd) |
| 294 | $DEBUG >&2 "DEBUG: Source directory is $SOURCEDIR" |
| 295 | |
| 296 | # Release ############################################################ |
| 297 | |
| 298 | # We always expect to start from a state of development |
| 299 | if [ "$TYPE" != 'dev' ]; then |
| 300 | echo >&2 "Not in a development branch" |
| 301 | echo >&2 "Have a look at the git log in $release_clone, it may be that" |
| 302 | echo >&2 "a previous crash left it in an intermediate state and that" |
| 303 | echo >&2 "need to drop the top commit:" |
| 304 | echo >&2 "" |
| 305 | echo >&2 "(cd $release_clone; git reset --hard HEAD^)" |
| 306 | echo >&2 "# WARNING! LOOK BEFORE YOU ACT" |
| 307 | exit 1 |
| 308 | fi |
| 309 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 310 | # Update the version information. This won't save anything anywhere, yet, |
| 311 | # but does check for possible next_method errors before we do bigger work. |
| 312 | next_release_state "$next_method" |
| 313 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 314 | # Create our temporary release branch |
| 315 | $VERBOSE "== Creating a local release branch: $tmp_release_branch" |
| 316 | git checkout $git_quiet -b "$tmp_release_branch" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 317 | |
| 318 | echo "== Configuring OpenSSL for update and release. This may take a bit of time" |
| 319 | |
| 320 | ./Configure cc >&42 |
| 321 | |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 322 | $VERBOSE "== Checking source file updates and fips checksums" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 323 | |
| 324 | make update >&42 |
Matt Caswell | 6ee4741 | 2021-06-24 16:07:03 +0100 | [diff] [blame] | 325 | # As long as we're doing an alpha release, we can have symbols without specific |
| 326 | # numbers assigned. In a beta or final release, all symbols MUST have an |
| 327 | # assigned number. |
| 328 | if [ "$next_method" != 'alpha' ]; then |
| 329 | make renumber >&42 |
| 330 | fi |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 331 | make update-fips-checksums >&42 |
| 332 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 333 | if [ -n "$(git status --porcelain)" ]; then |
| 334 | $VERBOSE "== Committing updates" |
| 335 | git add -u |
| 336 | git commit $git_quiet -m 'make update' |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 337 | if [ -n "$reviewers" ]; then |
| 338 | addrev --nopr $reviewers |
| 339 | fi |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 340 | fi |
| 341 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 342 | # Create our temporary update branch, if it's not the release branch. |
| 343 | # This is used in post-release below |
| 344 | if $do_branch; then |
| 345 | $VERBOSE "== Creating a local update branch: $tmp_update_branch" |
| 346 | git branch $git_quiet "$tmp_update_branch" |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 347 | fi |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 348 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 349 | # Write the version information we updated |
| 350 | set_version |
| 351 | |
| 352 | if [ -n "$PRE_LABEL" ]; then |
| 353 | release="$VERSION-$PRE_RELEASE_TAG$BUILD_METADATA" |
| 354 | release_text="$SERIES$BUILD_METADATA $PRE_LABEL $PRE_NUM" |
| 355 | announce_template=openssl-announce-pre-release.tmpl |
| 356 | else |
| 357 | release="$VERSION$BUILD_METADATA" |
| 358 | release_text="$release" |
| 359 | announce_template=openssl-announce-release.tmpl |
| 360 | fi |
| 361 | tag="openssl-$release" |
| 362 | $VERBOSE "== Updated version information to $release" |
| 363 | |
| 364 | $VERBOSE "== Updating files with release date for $release : $RELEASE_DATE" |
| 365 | for fixup in "$HERE/dev/release-aux"/fixup-*-release.pl; do |
| 366 | file="$(basename "$fixup" | sed -e 's|^fixup-||' -e 's|-release\.pl$||')" |
| 367 | $VERBOSE "> $file" |
| 368 | RELEASE="$release" RELEASE_TEXT="$release_text" RELEASE_DATE="$RELEASE_DATE" \ |
| 369 | perl -pi $fixup $file |
| 370 | done |
| 371 | |
| 372 | $VERBOSE "== Comitting updates and tagging" |
| 373 | git add -u |
| 374 | git commit $git_quiet -m "Prepare for release of $release_text" |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 375 | if [ -n "$reviewers" ]; then |
| 376 | addrev --nopr $reviewers |
| 377 | fi |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 378 | echo "Tagging release with tag $tag. You may need to enter a pass phrase" |
| 379 | git tag$tagkey "$tag" -m "OpenSSL $release release tag" |
| 380 | |
| 381 | tarfile=openssl-$release.tar |
| 382 | tgzfile=$tarfile.gz |
| 383 | announce=openssl-$release.txt |
| 384 | |
| 385 | echo "== Generating tar, hash and announcement files. This make take a bit of time" |
| 386 | |
| 387 | $VERBOSE "== Making tarfile: $tgzfile" |
| 388 | # Unfortunately, util/mktar.sh does verbose output on STDERR... for good |
| 389 | # reason, but it means we don't display errors unless --verbose |
| 390 | ./util/mktar.sh --tarfile="../$tarfile" 2>&1 \ |
| 391 | | while read L; do $VERBOSE "> $L"; done |
| 392 | |
| 393 | if ! [ -f "../$tgzfile" ]; then |
| 394 | echo >&2 "Where did the tarball end up? (../$tgzfile)" |
| 395 | exit 1 |
| 396 | fi |
| 397 | |
| 398 | $VERBOSE "== Generating checksums: $tgzfile.sha1 $tgzfile.sha256" |
| 399 | openssl sha1 < "../$tgzfile" | \ |
| 400 | (IFS='='; while read X H; do echo $H; done) > "../$tgzfile.sha1" |
| 401 | openssl sha256 < "../$tgzfile" | \ |
| 402 | (IFS='='; while read X H; do echo $H; done) > "../$tgzfile.sha256" |
| 403 | length=$(wc -c < "../$tgzfile") |
| 404 | sha1hash=$(cat "../$tgzfile.sha1") |
| 405 | sha256hash=$(cat "../$tgzfile.sha256") |
| 406 | |
| 407 | $VERBOSE "== Generating announcement text: $announce" |
| 408 | # Hack the announcement template |
| 409 | cat "$HERE/dev/release-aux/$announce_template" \ |
| 410 | | sed -e "s|\\\$release_text|$release_text|g" \ |
| 411 | -e "s|\\\$release|$release|g" \ |
| 412 | -e "s|\\\$series|$SERIES|g" \ |
| 413 | -e "s|\\\$label|$PRE_LABEL|g" \ |
| 414 | -e "s|\\\$tarfile|$tgzfile|" \ |
| 415 | -e "s|\\\$length|$length|" \ |
| 416 | -e "s|\\\$sha1hash|$sha1hash|" \ |
| 417 | -e "s|\\\$sha256hash|$sha256hash|" \ |
| 418 | | perl -p "$HERE/dev/release-aux/fix-title.pl" \ |
| 419 | > "../$announce" |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 420 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 421 | $VERBOSE "== Generating signatures: $tgzfile.asc $announce.asc" |
| 422 | rm -f "../$tgzfile.asc" "../$announce.asc" |
| 423 | echo "Signing the release files. You may need to enter a pass phrase" |
| 424 | gpg$gpgkey --use-agent -sba "../$tgzfile" |
| 425 | gpg$gpgkey --use-agent -sta --clearsign "../$announce" |
| 426 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 427 | # Push everything to the parent repo |
| 428 | $VERBOSE "== Push what we have to the parent repository" |
| 429 | git push --follow-tags parent HEAD |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 430 | |
| 431 | if $do_upload; then |
| 432 | ( |
| 433 | if [ "$VERBOSE" != ':' ]; then |
| 434 | echo "progress" |
| 435 | fi |
| 436 | echo "put ../$tgzfile" |
| 437 | echo "put ../$tgzfile.sha1" |
| 438 | echo "put ../$tgzfile.sha256" |
| 439 | echo "put ../$tgzfile.asc" |
| 440 | echo "put ../$announce.asc" |
| 441 | ) \ |
| 442 | | sftp "$upload_address" |
| 443 | fi |
| 444 | |
| 445 | # Post-release ####################################################### |
| 446 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 447 | $VERBOSE "== Reset all files to their pre-release contents" |
| 448 | git reset $git_quiet HEAD^ -- . |
| 449 | git checkout -- . |
| 450 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 451 | prev_release_text="$release_text" |
| 452 | prev_release_date="$RELEASE_DATE" |
| 453 | |
| 454 | next_release_state "$next_method2" |
| 455 | set_version |
| 456 | |
| 457 | release="$VERSION-$PRE_RELEASE_TAG$BUILD_METADATA" |
| 458 | release_text="$VERSION$BUILD_METADATA" |
| 459 | if [ -n "$PRE_LABEL" ]; then |
| 460 | release_text="$SERIES$BUILD_METADATA $PRE_LABEL $PRE_NUM" |
| 461 | fi |
| 462 | $VERBOSE "== Updated version information to $release" |
| 463 | |
| 464 | $VERBOSE "== Updating files for $release :" |
| 465 | for fixup in "$HERE/dev/release-aux"/fixup-*-postrelease.pl; do |
| 466 | file="$(basename "$fixup" | sed -e 's|^fixup-||' -e 's|-postrelease\.pl$||')" |
| 467 | $VERBOSE "> $file" |
| 468 | RELEASE="$release" RELEASE_TEXT="$release_text" \ |
| 469 | PREV_RELEASE_TEXT="$prev_release_text" \ |
| 470 | PREV_RELEASE_DATE="$prev_release_date" \ |
| 471 | perl -pi $fixup $file |
| 472 | done |
| 473 | |
| 474 | $VERBOSE "== Comitting updates" |
| 475 | git add -u |
| 476 | git commit $git_quiet -m "Prepare for $release_text" |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 477 | if [ -n "$reviewers" ]; then |
| 478 | addrev --nopr $reviewers |
| 479 | fi |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 480 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 481 | # Push everything to the parent repo |
| 482 | $VERBOSE "== Push what we have to the parent repository" |
| 483 | git push parent HEAD |
| 484 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 485 | if $do_branch; then |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 486 | $VERBOSE "== Going back to the update branch $tmp_update_branch" |
| 487 | git checkout $git_quiet "$tmp_update_branch" |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 488 | |
| 489 | get_version |
| 490 | next_release_state "minor" |
| 491 | set_version |
| 492 | |
| 493 | release="$VERSION-$PRE_RELEASE_TAG$BUILD_METADATA" |
| 494 | release_text="$SERIES$BUILD_METADATA" |
| 495 | $VERBOSE "== Updated version information to $release" |
| 496 | |
| 497 | $VERBOSE "== Updating files for $release :" |
| 498 | for fixup in "$HERE/dev/release-aux"/fixup-*-postrelease.pl; do |
| 499 | file="$(basename "$fixup" | sed -e 's|^fixup-||' -e 's|-postrelease\.pl$||')" |
| 500 | $VERBOSE "> $file" |
| 501 | RELEASE="$release" RELEASE_TEXT="$release_text" \ |
| 502 | perl -pi $fixup $file |
| 503 | done |
| 504 | |
| 505 | $VERBOSE "== Comitting updates" |
| 506 | git add -u |
| 507 | git commit $git_quiet -m "Prepare for $release_text" |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 508 | if [ -n "$reviewers" ]; then |
| 509 | addrev --nopr $reviewers |
| 510 | fi |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 511 | fi |
| 512 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 513 | # Push everything to the parent repo |
| 514 | $VERBOSE "== Push what we have to the parent repository" |
| 515 | git push parent HEAD |
| 516 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 517 | # Done ############################################################### |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 518 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 519 | $VERBOSE "== Done" |
| 520 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 521 | cd $HERE |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 522 | cat <<EOF |
| 523 | |
| 524 | ====================================================================== |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 525 | The release is done, and involves a few files and commits for you to |
| 526 | deal with. Everything you need has been pushed to your repository, |
| 527 | please see instructions that follow. |
| 528 | ====================================================================== |
| 529 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 530 | EOF |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 531 | |
| 532 | if $do_release; then |
| 533 | cat <<EOF |
| 534 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 535 | The following files were uploaded to $upload_address, please ensure they |
| 536 | are dealt with appropriately: |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 537 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 538 | $tgzfile |
| 539 | $tgzfile.sha1 |
| 540 | $tgzfile.sha256 |
| 541 | $tgzfile.asc |
| 542 | $announce.asc |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 543 | EOF |
| 544 | fi |
| 545 | |
| 546 | cat <<EOF |
| 547 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 548 | ---------------------------------------------------------------------- |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 549 | EOF |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 550 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 551 | if $do_branch; then |
| 552 | cat <<EOF |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 553 | You need to prepare the main repository with a new branch, '$release_branch'. |
| 554 | That is done directly in the server's bare repository like this: |
| 555 | |
| 556 | git branch $release_branch $orig_HEAD |
| 557 | |
| 558 | Two additional release branches have been added to your repository. |
| 559 | Push them to github, make PRs from them and have them approved: |
| 560 | |
| 561 | $tmp_update_branch |
| 562 | $tmp_release_branch |
| 563 | |
| 564 | When merging them into the main repository, do it like this: |
| 565 | |
Richard Levitte | a1fc464 | 2020-10-16 10:24:18 +0200 | [diff] [blame] | 566 | git push openssl-git@git.openssl.org:openssl.git \\ |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 567 | $tmp_release_branch:$release_branch |
| 568 | git push openssl-git@git.openssl.org:openssl.git \\ |
| 569 | $tmp_update_branch:$update_branch |
Richard Levitte | a1fc464 | 2020-10-16 10:24:18 +0200 | [diff] [blame] | 570 | git push openssl-git@git.openssl.org:openssl.git \\ |
| 571 | $tag |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 572 | EOF |
| 573 | else |
| 574 | cat <<EOF |
| 575 | One additional release branch has been added to your repository. |
| 576 | Push it to github, make a PR from it and have it approved: |
| 577 | |
| 578 | $tmp_release_branch |
| 579 | |
| 580 | When merging it into the main repository, do it like this: |
| 581 | |
Richard Levitte | a1fc464 | 2020-10-16 10:24:18 +0200 | [diff] [blame] | 582 | git push openssl-git@git.openssl.org:openssl.git \\ |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 583 | $tmp_release_branch:$release_branch |
Richard Levitte | a1fc464 | 2020-10-16 10:24:18 +0200 | [diff] [blame] | 584 | git push openssl-git@git.openssl.org:openssl.git \\ |
| 585 | $tag |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 586 | EOF |
| 587 | fi |
| 588 | |
| 589 | cat <<EOF |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 590 | |
| 591 | ---------------------------------------------------------------------- |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 592 | EOF |
| 593 | |
| 594 | cat <<EOF |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 595 | |
| 596 | When everything is done, or if something went wrong and you want to start |
| 597 | over, simply clean away temporary things left behind: |
| 598 | |
| 599 | The release worktree: |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 600 | |
| 601 | rm -rf $release_clone |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 602 | EOF |
| 603 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 604 | if $do_branch; then |
| 605 | cat <<EOF |
| 606 | |
| 607 | The additional release branches: |
| 608 | |
| 609 | git branch -D $tmp_release_branch |
| 610 | git branch -D $tmp_update_branch |
| 611 | EOF |
| 612 | else |
| 613 | cat <<EOF |
| 614 | |
| 615 | The temporary release branch: |
| 616 | |
| 617 | git branch -D $tmp_release_branch |
| 618 | EOF |
| 619 | fi |
| 620 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 621 | exit 0 |
| 622 | |
| 623 | # cat is inconsequential, it's only there to fend off zealous shell parsers |
| 624 | # that parse all the way here. |
| 625 | cat <<EOF |
| 626 | ### BEGIN MANUAL |
| 627 | =pod |
| 628 | |
| 629 | =head1 NAME |
| 630 | |
| 631 | release.sh - OpenSSL release script |
| 632 | |
| 633 | =head1 SYNOPSIS |
| 634 | |
| 635 | B<release.sh> |
| 636 | [ |
| 637 | B<--alpha> | |
| 638 | B<--next-beta> | |
| 639 | B<--beta> | |
| 640 | B<--final> | |
| 641 | B<--branch> | |
| 642 | B<--local-user>=I<keyid> | |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 643 | B<--reviewer>=I<id> | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 644 | B<--no-upload> | |
| 645 | B<--no-update> | |
| 646 | B<--verbose> | |
| 647 | B<--debug> | |
| 648 | B<--help> | |
| 649 | B<--manual> |
| 650 | ] |
| 651 | |
| 652 | =head1 DESCRIPTION |
| 653 | |
| 654 | B<release.sh> creates an OpenSSL release, given current worktree conditions. |
| 655 | It will refuse to work unless the current branch is C<master> or a release |
| 656 | branch (see L</RELEASE BRANCHES AND TAGS> below for a discussion on those). |
| 657 | |
| 658 | B<release.sh> tries to be smart and figure out the next release if no hints |
| 659 | are given through options, and will exit with an error in ambiguous cases. |
| 660 | |
Richard Levitte | 4588f35 | 2020-08-09 14:22:09 +0200 | [diff] [blame] | 661 | B<release.sh> finishes off with instructions on what to do next. When |
| 662 | finishing commands are given, they must be followed exactly. |
| 663 | |
| 664 | B<release.sh> leaves behind a clone of the local workspace, as well as one |
| 665 | or two branches in the local repository. These will be mentioned and can |
| 666 | safely be removed after all instructions have been successfully followed. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 667 | |
| 668 | =head1 OPTIONS |
| 669 | |
| 670 | =over 4 |
| 671 | |
| 672 | =item B<--alpha>, B<--beta> |
| 673 | |
| 674 | Set the state of this branch to indicate that alpha or beta releases are |
| 675 | to be done. |
| 676 | |
| 677 | B<--alpha> is only acceptable if the I<PATCH> version number is zero and |
| 678 | the current state is "in development" or that alpha releases are ongoing. |
| 679 | |
| 680 | B<--beta> is only acceptable if the I<PATCH> version number is zero and |
| 681 | that alpha or beta releases are ongoing. |
| 682 | |
| 683 | =item B<--next-beta> |
| 684 | |
| 685 | Use together with B<--alpha> to switch to beta releases after the current |
| 686 | release is done. |
| 687 | |
| 688 | =item B<--final> |
| 689 | |
| 690 | Set the state of this branch to indicate that regular releases are to be |
| 691 | done. This is only valid if alpha or beta releases are currently ongoing. |
| 692 | |
| 693 | This implies B<--branch>. |
| 694 | |
| 695 | =item B<--branch> |
| 696 | |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 697 | Create a branch specific for the I<SERIES> release series, if it doesn't |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 698 | already exist, and switch to it. The exact branch name will be |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 699 | C<< openssl-I<SERIES> >>. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 700 | |
| 701 | =item B<--no-upload> |
| 702 | |
| 703 | Don't upload the produced files. |
| 704 | |
| 705 | =item B<--no-update> |
| 706 | |
Tomas Mraz | 773f1c3 | 2021-05-13 19:41:09 +0200 | [diff] [blame] | 707 | Don't run C<make update> and C<make update-fips-checksums>. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 708 | |
| 709 | =item B<--verbose> |
| 710 | |
| 711 | Verbose output. |
| 712 | |
| 713 | =item B<--debug> |
| 714 | |
| 715 | Display extra debug output. Implies B<--no-upload> |
| 716 | |
| 717 | =item B<--local-user>=I<keyid> |
| 718 | |
| 719 | Use I<keyid> as the local user for C<git tag> and for signing with C<gpg>. |
| 720 | |
| 721 | If not given, then the default e-mail address' key is used. |
| 722 | |
Richard Levitte | 64af3ae | 2020-04-24 11:03:28 +0200 | [diff] [blame] | 723 | =item B<--reviewer>=I<id> |
| 724 | |
| 725 | Add I<id> to the set of reviewers for the commits performed by this script. |
| 726 | Multiple reviewers are allowed. |
| 727 | |
| 728 | If no reviewer is given, you will have to run C<addrev> manually, which |
| 729 | means retagging a release commit manually as well. |
| 730 | |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 731 | =item B<--force> |
| 732 | |
| 733 | Force execution. Precisely, the check that the current branch is C<master> |
| 734 | or a release branch is not done. |
| 735 | |
| 736 | =item B<--help> |
| 737 | |
| 738 | Display a quick help text and exit. |
| 739 | |
| 740 | =item B<--manual> |
| 741 | |
| 742 | Display this manual and exit. |
| 743 | |
| 744 | =back |
| 745 | |
| 746 | =head1 RELEASE BRANCHES AND TAGS |
| 747 | |
| 748 | Prior to OpenSSL 3.0, the release branches were named |
| 749 | C<< OpenSSL_I<SERIES>-stable >>, and the release tags were named |
| 750 | C<< OpenSSL_I<VERSION> >> for regular releases, or |
| 751 | C<< OpenSSL_I<VERSION>-preI<n> >> for pre-releases. |
| 752 | |
| 753 | From OpenSSL 3.0 ongoing, the release branches are named |
Richard Levitte | 8e706c8 | 2021-08-31 12:07:33 +0200 | [diff] [blame^] | 754 | C<< openssl-I<SERIES> >>, and the release tags are named |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 755 | C<< openssl-I<VERSION> >> for regular releases, or |
| 756 | C<< openssl-I<VERSION>-alphaI<n> >> for alpha releases |
| 757 | and C<< openssl-I<VERSION>-betaI<n> >> for beta releases. |
| 758 | |
| 759 | B<release.sh> recognises both forms. |
| 760 | |
| 761 | =head1 VERSION AND STATE |
| 762 | |
| 763 | With OpenSSL 3.0, all the version and state information is in the file |
Dr. David von Oheimb | 036cbb6 | 2020-06-10 14:15:28 +0200 | [diff] [blame] | 764 | F<VERSION.dat>, where the following variables are used and changed: |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 765 | |
| 766 | =over 4 |
| 767 | |
| 768 | =item B<MAJOR>, B<MINOR>, B<PATCH> |
| 769 | |
| 770 | The three part of the version number. |
| 771 | |
| 772 | =item B<PRE_RELEASE_TAG> |
| 773 | |
| 774 | The indicator of the current state of the branch. The value may be one pf: |
| 775 | |
| 776 | =over 4 |
| 777 | |
| 778 | =item C<dev> |
| 779 | |
| 780 | This branch is "in development". This is typical for the C<master> branch |
| 781 | unless there are ongoing alpha or beta releases. |
| 782 | |
| 783 | =item C<< alphaI<n> >> or C<< alphaI<n>-dev >> |
| 784 | |
| 785 | This branch has alpha releases going on. C<< alphaI<n>-dev >> is what |
| 786 | should normally be seen in the git workspace, indicating that |
| 787 | C<< alphaI<n> >> is in development. C<< alphaI<n> >> is what should be |
| 788 | found in the alpha release tar file. |
| 789 | |
| 790 | =item C<< alphaI<n> >> or C<< alphaI<n>-dev >> |
| 791 | |
| 792 | This branch has beta releases going on. The details are otherwise exactly |
| 793 | as for alpha. |
| 794 | |
| 795 | =item I<no value> |
| 796 | |
| 797 | This is normally not seen in the git workspace, but should always be what's |
| 798 | found in the tar file of a regular release. |
| 799 | |
| 800 | =back |
| 801 | |
| 802 | =item B<RELEASE_DATE> |
| 803 | |
| 804 | This is normally empty in the git workspace, but should always have the |
| 805 | release date in the tar file of any release. |
| 806 | |
| 807 | =back |
| 808 | |
| 809 | =head1 COPYRIGHT |
| 810 | |
Matt Caswell | a28d06f | 2021-02-18 14:57:13 +0000 | [diff] [blame] | 811 | Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. |
Richard Levitte | b0b0b6a | 2020-04-06 23:58:24 +0200 | [diff] [blame] | 812 | |
| 813 | Licensed under the Apache License 2.0 (the "License"). You may not use |
| 814 | this file except in compliance with the License. You can obtain a copy |
| 815 | in the file LICENSE in the source distribution or at |
| 816 | L<https://www.openssl.org/source/license.html>. |
| 817 | |
| 818 | =cut |
| 819 | ### END MANUAL |
| 820 | EOF |