|
| 1 | +#!/bin/bash |
| 2 | +#============================================================================= |
| 3 | +# Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA) |
| 4 | +# |
| 5 | +# All rights reserved. |
| 6 | +# |
| 7 | +# Redistribution and use in source and binary forms, with or without |
| 8 | +# modification, are permitted provided that the following conditions are met: |
| 9 | +# * Redistributions of source code must retain the above copyright notice, |
| 10 | +# this list of conditions and the following disclaimer. |
| 11 | +# * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | +# this list of conditions and the following disclaimer in the documentation |
| 13 | +# and/or other materials provided with the distribution. |
| 14 | +# * Neither the names of CEA, nor the names of the contributors may be used to |
| 15 | +# endorse or promote products derived from this software without specific |
| 16 | +# prior written permission. |
| 17 | +# |
| 18 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | +# POSSIBILITY OF SUCH DAMAGE. |
| 29 | +#============================================================================= |
| 30 | + |
| 31 | +set -e -o pipefail |
| 32 | +export LC_ALL=C |
| 33 | + |
| 34 | +cd "$(mktemp --tmpdir -d PDI.release.XXXXXXXXXX)" |
| 35 | +printf "cloning..." |
| 36 | +git clone -q git@github.com:pdidev/pdi.git . |
| 37 | +printf "\n" |
| 38 | +PDIDIR="$PWD" |
| 39 | + |
| 40 | +OMAJOR="$(git tag -l | sort -V | tail -n 1 | sed -E 's/^([0-9]+)\.[0-9]+\.[0-9]+/\1/')" |
| 41 | +OMINOR="$(git tag -l | sort -V | tail -n 1 | sed -E 's/^[0-9]+\.([0-9]+)\.[0-9]+/\1/')" |
| 42 | +OPATCH="$(git tag -l | sort -V | tail -n 1 | sed -E 's/^[0-9]+\.[0-9]+\.([0-9]+)/\1/')" |
| 43 | + |
| 44 | +printf "select your type of release:\n * mInor $((OMAJOR)).$((OMINOR+1)).0 (i)\n * mAjor $((OMAJOR+1)).0.0 (a)\n * cancel and eXit (x)\n" |
| 45 | +read -p '[iaX] ' RELTYPE |
| 46 | +while [[ ! "$RELTYPE" =~ ^i$|^I$|^a$|^A$|^x$|^X$|^$ ]] |
| 47 | +do read -p 'please enter either i, a, or x [iaX] ' RELTYPE |
| 48 | +done |
| 49 | +case "$RELTYPE" in |
| 50 | +[iI]) |
| 51 | + MAJOR="$(( OMAJOR ))" |
| 52 | + MINOR="$(( OMINOR + 1 ))" |
| 53 | +;; |
| 54 | +[aA]) |
| 55 | + MAJOR="$(( OMAJOR + 1 ))" |
| 56 | + MINOR=0 |
| 57 | +;; |
| 58 | +*) |
| 59 | + printf "Ok, exiting...\n" |
| 60 | + rm -rf "${PDIDIR}" |
| 61 | + exit |
| 62 | +;; |
| 63 | +esac |
| 64 | +PATCH=0 |
| 65 | + |
| 66 | +git switch -qc "v$MAJOR.$MINOR" |
| 67 | +echo "$MAJOR.$MINOR.$PATCH" > VERSION |
| 68 | +sed " |
| 69 | +s/release $OMAJOR\.$OMINOR\.$OPATCH/release $MAJOR.$MINOR.$PATCH/; |
| 70 | +s%$OMAJOR\.$OMINOR\.$OPATCH\.tar\.gz%$MAJOR.$MINOR.$PATCH\.tar\.gz%; |
| 71 | +s%$OMAJOR\.$OMINOR\.$OPATCH/build%$MAJOR.$MINOR.$PATCH/build%; |
| 72 | +" -i pdi/docs/Source_installation.md |
| 73 | +sed "s/set(PDI_VERSION .*/set(PDI_VERSION \"$MAJOR.$MINOR.$PATCH\")/" -i mock_pdi/PDIConfigVersion.cmake |
| 74 | +sed " |
| 75 | +s/## \[Unreleased\].*/## [$MAJOR.$MINOR.$PATCH] - $(date +%Y-%d-%m)/; |
| 76 | +/^#### /{N;/^####.*\n *$/d} |
| 77 | +" -i CHANGELOG.md |
| 78 | +git commit -qm "PDI Release $MAJOR.$MINOR.$PATCH" VERSION pdi/docs/Source_installation.md mock_pdi/PDIConfigVersion.cmake CHANGELOG.md |
| 79 | +git tag -m "PDI release $MAJOR.$MINOR.$PATCH" -s "$MAJOR.$MINOR.$PATCH" |
| 80 | +git switch -q main |
| 81 | +git merge -qm "Merge branch 'v1.10' back into main" --no-ff "v$MAJOR.$MINOR" |
| 82 | + |
| 83 | +echo "$MAJOR.$((MINOR+1)).0-alpha" > VERSION |
| 84 | +sed -E '1,/^(## .*)/s/^(## .*)/## [Unreleased]\n\n### For users\n\n#### Added\n\n#### Changed\n\n#### Deprecated\n\n#### Removed\n\n#### Fixed\n\n#### Security\n\n\n### For plugin developers\n\n#### Added\n\n#### Changed\n\n#### Deprecated\n\n#### Removed\n\n#### Fixed\n\n#### Security\n\n\n\n\1/' -i CHANGELOG.md |
| 85 | +git commit -qC HEAD --amend VERSION CHANGELOG.md |
| 86 | + |
| 87 | +read -p "Do you want to push the release that has been prepared in ${PDIDIR} ? [yN] " VALID |
| 88 | +while [[ ! "$RELTYPE" =~ ^i$|^I$|^a$|^A$|^x$|^X$|^$ ]] |
| 89 | +do read -p 'please enter either y or n [yN] ' VALID |
| 90 | +done |
| 91 | +case "${VALID}" in |
| 92 | +[Yy]) |
| 93 | + git push origin "v$MAJOR.$MINOR:v$MAJOR.$MINOR" "main:main" "$MAJOR.$MINOR.$PATCH" |
| 94 | + rm -rf "${PDIDIR}" |
| 95 | + printf "Please now:\n * describe the release at https://github.com/pdidev/pdi/releases\n * publish new binary packages at https://github.com/pdidev/pkgs\n * publish new spack packages at https://github.com/pdidev/spack and https://github.com/spack/spack-packages/\n" |
| 96 | +;; |
| 97 | +*) |
| 98 | + printf "release candidate kept in ${PDIDIR}\n" |
| 99 | +;; |
| 100 | +esac |
0 commit comments