From 989565de9790ebadff5a53ecbc216fe515d7c461 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 8 Jul 2022 10:57:06 +0300 Subject: [PATCH] scripts/prepare-release: patch golang version in Makefile Make it mandatory to specify a golang version with "-g" when running the script (and patching repo content). The given version will be patched into the Makefile to fix the version used in the release build - it is meant to use a exact point release (like 1.18.3) to get reproducible builds. --- scripts/prepare-release.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh index 8e607f46f4..f8b09d4fe5 100755 --- a/scripts/prepare-release.sh +++ b/scripts/prepare-release.sh @@ -5,12 +5,14 @@ this=`basename $0` usage () { cat << EOF -Usage: $this [-h] [-a] [-b] [-k GPG_KEY] RELEASE_VERSION +Usage: $this [-h] [-b] [-k GPG_KEY] {-a|-g GOLANG_VERSION} RELEASE_VERSION Options: -h show this help and exit -a do not patch files in the repo -b do not generate assets + -g golang version to fix for the release (mandatory when -a not + specified). Should be a exact point release e.g. 1.18.3. -k gpg key to use for signing the assets Example: @@ -39,12 +41,14 @@ files: # no_patching= no_assets= -while getopts "abk:h" opt; do +while getopts "abg:k:h" opt; do case $opt in a) no_patching=y ;; b) no_assets=y ;; + g) golang_version="$OPTARG" + ;; k) signing_key="$OPTARG" ;; h) usage @@ -68,6 +72,12 @@ if [ $# -ne 1 ]; then exit 1 fi +if [ -z "$no_patching" -a -z "$golang_version" ]; then + echo -e "ERROR: '-g GOLANG_VERSION' must be specified when modifying repo (i.e. when '-a' is not used)\n" + usage + exit 1 +fi + release=$1 shift 1 @@ -94,6 +104,11 @@ fi # Modify files in the repo to point to new release # if [ -z "$no_patching" ]; then + # Patch docs configuration + echo Patching golang version $golang_version into Makefile + sed -e s"/\(^BUILDER_IMAGE.*=.*golang:\)[0-9][0-9.]*\(.*\)/\1$golang_version\2/" \ + -i Makefile + # Patch docs configuration echo Patching docs/_config.yml sed -e s"/release:.*/release: $release/" \