diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh index 5bbbe6269..f8b09d4fe 100755 --- a/scripts/prepare-release.sh +++ b/scripts/prepare-release.sh @@ -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 " + $this v0.1.2 -k "Jane Doe " NOTE: The GPG key should be associated with the signer's Github account. + Use -k to specify the correct key (if needed). EOF } @@ -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 @@ -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" @@ -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 @@ -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/" \ @@ -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 @@ -140,3 +166,4 @@ cat << EOF *** ******************************************************************************* EOF +fi