Skip to content

Commit

Permalink
Merge pull request #846 from marquiz/devel/prepare-release-golang-ver…
Browse files Browse the repository at this point in the history
…sion

Improvements to scripts/prepare-release.sh
  • Loading branch information
k8s-ci-robot authored Aug 9, 2022
2 parents 35e41b6 + 989565d commit 07e9d5b
Showing 1 changed file with 44 additions and 17 deletions.
61 changes: 44 additions & 17 deletions scripts/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ this=`basename $0`

usage () {
cat << EOF
Usage: $this [-h] RELEASE_VERSION GPG_KEY
Usage: $this [-h] [-b] [-k GPG_KEY] {-a|-g GOLANG_VERSION} RELEASE_VERSION
Options:
-h show this help and exit
-a only generate release assets, do not patch files in the repo
-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:
$this v0.1.2 "Jane Doe <[email protected]>"
$this v0.1.2 -k "Jane Doe <[email protected]>"
NOTE: The GPG key should be associated with the signer's Github account.
Use -k to specify the correct key (if needed).
EOF
}

Expand All @@ -28,16 +33,23 @@ sign_helm_chart() {
echo "$yaml
...
files:
$chart: sha256:$sha256" | gpg -u "$key" --clearsign -o "$chart.prov"
$chart: sha256:$sha256" | gpg ${signing_key:+-u "$signing_key"} --clearsign -o "$chart.prov"
}

#
# Parse command line
#
assets_only=
while getopts "ah" opt; do
no_patching=
no_assets=
while getopts "abg:k:h" opt; do
case $opt in
a) assets_only=y
a) no_patching=y
;;
b) no_assets=y
;;
g) golang_version="$OPTARG"
;;
k) signing_key="$OPTARG"
;;
h) usage
exit 0
Expand All @@ -50,8 +62,8 @@ done
shift "$((OPTIND - 1))"

# Check that no extra args were provided
if [ $# -ne 2 ]; then
if [ $# -lt 2 ]; then
if [ $# -ne 1 ]; then
if [ $# -lt 1 ]; then
echo -e "ERROR: too few arguments\n"
else
echo -e "ERROR: unknown arguments: ${@:3}\n"
Expand All @@ -60,9 +72,14 @@ if [ $# -ne 2 ]; 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
key="$2"
shift 2
shift 1

container_image=k8s.gcr.io/nfd/node-feature-discovery:$release

Expand All @@ -83,7 +100,15 @@ else
exit 1
fi

if [ -z "$assets_only" ]; then
#
# 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 Expand Up @@ -123,13 +148,14 @@ fi
#
# Create release assets to be uploaded
#
helm package deployment/helm/node-feature-discovery/ --version $semver
if [ -z "$no_assets" ]; then
helm package deployment/helm/node-feature-discovery/ --version $semver

chart_name="node-feature-discovery-chart-$semver.tgz"
mv node-feature-discovery-$semver.tgz $chart_name
sign_helm_chart $chart_name
chart_name="node-feature-discovery-chart-$semver.tgz"
mv node-feature-discovery-$semver.tgz $chart_name
sign_helm_chart $chart_name

cat << EOF
cat << EOF
*******************************************************************************
*** Please manually upload the following generated files to the Github release
Expand All @@ -140,3 +166,4 @@ cat << EOF
***
*******************************************************************************
EOF
fi

0 comments on commit 07e9d5b

Please sign in to comment.