2020-11-20 12:05:46 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
this=`basename $0`
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
cat << EOF
|
2021-03-16 19:48:14 +00:00
|
|
|
Usage: $this [-h] RELEASE_VERSION GPG_KEY
|
2020-11-20 12:05:46 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
-h show this help and exit
|
2021-03-31 08:37:28 +00:00
|
|
|
-a only generate release assets, do not patch files in the repo
|
2021-02-26 13:21:31 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2021-03-16 19:48:14 +00:00
|
|
|
$this v0.1.2 "Jane Doe <jane.doe@example.com>"
|
2021-02-26 13:21:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
NOTE: The GPG key should be associated with the signer's Github account.
|
2020-11-20 12:05:46 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2021-03-16 19:48:14 +00:00
|
|
|
sign_helm_chart() {
|
|
|
|
local chart="$1"
|
|
|
|
echo "Signing Helm chart $chart"
|
|
|
|
local sha256=`openssl dgst -sha256 "$chart" | awk '{ print $2 }'`
|
|
|
|
local yaml=`tar xf $chart -O node-feature-discovery/Chart.yaml`
|
|
|
|
echo "$yaml
|
|
|
|
...
|
|
|
|
files:
|
|
|
|
$chart: sha256:$sha256" | gpg -u "$key" --clearsign -o "$chart.prov"
|
|
|
|
}
|
|
|
|
|
2020-11-20 12:05:46 +00:00
|
|
|
#
|
|
|
|
# Parse command line
|
|
|
|
#
|
2021-03-31 08:37:28 +00:00
|
|
|
assets_only=
|
|
|
|
while getopts "ah" opt; do
|
2020-11-20 12:05:46 +00:00
|
|
|
case $opt in
|
2021-03-31 08:37:28 +00:00
|
|
|
a) assets_only=y
|
|
|
|
;;
|
2020-11-20 12:05:46 +00:00
|
|
|
h) usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*) usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift "$((OPTIND - 1))"
|
|
|
|
|
|
|
|
# Check that no extra args were provided
|
2021-03-16 19:48:14 +00:00
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
if [ $# -lt 2 ]; then
|
2021-02-26 13:21:31 +00:00
|
|
|
echo -e "ERROR: too few arguments\n"
|
|
|
|
else
|
2021-03-16 19:48:14 +00:00
|
|
|
echo -e "ERROR: unknown arguments: ${@:3}\n"
|
2021-02-26 13:21:31 +00:00
|
|
|
fi
|
2020-11-20 12:05:46 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
release=$1
|
2021-02-26 13:21:31 +00:00
|
|
|
key="$2"
|
2021-03-16 19:48:14 +00:00
|
|
|
shift 2
|
2021-02-26 13:21:31 +00:00
|
|
|
|
2020-11-20 12:05:46 +00:00
|
|
|
container_image=k8s.gcr.io/nfd/node-feature-discovery:$release
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check/parse release number
|
|
|
|
#
|
|
|
|
if [ -z "$release" ]; then
|
|
|
|
echo -e "ERROR: missing RELEASE_VERSION\n"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $release =~ ^(v[0-9]+\.[0-9]+)(\..+)?$ ]]; then
|
|
|
|
docs_version=${BASH_REMATCH[1]}
|
2021-02-26 13:21:31 +00:00
|
|
|
semver=${release:1}
|
2020-11-20 12:05:46 +00:00
|
|
|
else
|
|
|
|
echo -e "ERROR: invalid RELEASE_VERSION '$release'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-03-31 08:37:28 +00:00
|
|
|
if [ -z "$assets_only" ]; then
|
|
|
|
# Patch docs configuration
|
|
|
|
echo Patching docs/_config.yml
|
|
|
|
sed -e s"/release:.*/release: $release/" \
|
|
|
|
-e s"/version:.*/version: $docs_version/" \
|
|
|
|
-e s"!container_image:.*!container_image: k8s.gcr.io/nfd/node-feature-discovery:$release!" \
|
|
|
|
-i docs/_config.yml
|
|
|
|
|
|
|
|
# Patch README
|
|
|
|
echo Patching README.md to refer to $release
|
|
|
|
sed s"!node-feature-discovery/v.*/!node-feature-discovery/$release/!" -i README.md
|
|
|
|
|
|
|
|
# Patch deployment templates
|
2021-08-13 14:35:22 +00:00
|
|
|
echo Patching kustomize templates to use $container_image
|
2021-03-31 08:37:28 +00:00
|
|
|
sed -E -e s",^([[:space:]]+)image:.+$,\1image: $container_image," \
|
|
|
|
-e s",^([[:space:]]+)imagePullPolicy:.+$,\1imagePullPolicy: IfNotPresent," \
|
2021-08-13 14:35:22 +00:00
|
|
|
-i deployment/base/*/*yaml
|
2021-03-31 08:37:28 +00:00
|
|
|
|
|
|
|
# Patch Helm chart
|
2021-08-11 08:25:30 +00:00
|
|
|
echo "Patching Helm chart"
|
2021-03-11 16:50:33 +00:00
|
|
|
sed -e s"/appVersion:.*/appVersion: $release/" -i deployment/helm/node-feature-discovery/Chart.yaml
|
2021-03-31 08:37:28 +00:00
|
|
|
sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" \
|
|
|
|
-e s"!gcr.io/k8s-staging-nfd/node-feature-discovery!k8s.gcr.io/nfd/node-feature-discovery!" \
|
2021-03-11 16:50:33 +00:00
|
|
|
-i deployment/helm/node-feature-discovery/values.yaml
|
2021-08-11 08:25:30 +00:00
|
|
|
sed -e s"!kubernetes-sigs.github.io/node-feature-discovery/master!kubernetes-sigs.github.io/node-feature-discovery/$docs_version!" \
|
2021-03-11 16:50:33 +00:00
|
|
|
-i deployment/helm/node-feature-discovery/README.md
|
2021-03-31 08:37:28 +00:00
|
|
|
|
|
|
|
# Patch e2e test
|
|
|
|
echo Patching test/e2e/node_feature_discovery.go flag defaults to k8s.gcr.io/nfd/node-feature-discovery and $release
|
|
|
|
sed -e s'!"nfd\.repo",.*,!"nfd.repo", "k8s.gcr.io/nfd/node-feature-discovery",!' \
|
|
|
|
-e s"!\"nfd\.tag\",.*,!\"nfd.tag\", \"$release\",!" \
|
|
|
|
-i test/e2e/node_feature_discovery.go
|
|
|
|
fi
|
2021-02-26 13:21:31 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create release assets to be uploaded
|
|
|
|
#
|
2021-03-11 16:50:33 +00:00
|
|
|
helm package deployment/helm/node-feature-discovery/ --version $semver
|
2021-02-26 13:21:31 +00:00
|
|
|
|
|
|
|
chart_name="node-feature-discovery-chart-$semver.tgz"
|
|
|
|
mv node-feature-discovery-$semver.tgz $chart_name
|
2021-03-16 19:48:14 +00:00
|
|
|
sign_helm_chart $chart_name
|
2021-02-26 13:21:31 +00:00
|
|
|
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
*******************************************************************************
|
|
|
|
*** Please manually upload the following generated files to the Github release
|
|
|
|
*** page:
|
|
|
|
***
|
|
|
|
*** $chart_name
|
|
|
|
*** $chart_name.prov
|
|
|
|
***
|
|
|
|
*******************************************************************************
|
|
|
|
EOF
|