Skip to content

Commit

Permalink
scripts/prepare-release: patch golang version in Makefile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marquiz committed Aug 9, 2022
1 parent e41c5a7 commit 989565d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions scripts/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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/" \
Expand Down

0 comments on commit 989565d

Please sign in to comment.