From 2283f29b19d12f85e0925efe9e109871a21e3464 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 20 Nov 2020 14:05:46 +0200 Subject: [PATCH] scripts: add prepare-release.xh A helper script for preparing the release branch. --- .github/ISSUE_TEMPLATE/new-release.md | 8 +-- scripts/prepare-release.sh | 80 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 6 deletions(-) create mode 100755 scripts/prepare-release.sh diff --git a/.github/ISSUE_TEMPLATE/new-release.md b/.github/ISSUE_TEMPLATE/new-release.md index 5c2985f5d..c32702440 100644 --- a/.github/ISSUE_TEMPLATE/new-release.md +++ b/.github/ISSUE_TEMPLATE/new-release.md @@ -15,12 +15,8 @@ Please do not remove items from the checklist - [ ] For major releases (v0.$MAJ.0), an OWNER creates a release branch with `git branch release-0.$MAJ master` - [ ] Prepare `release-0.$MAJ` release branch - - [ ] Update the deployment templates to use the new tagged container image: - `sed s"|image: .*|image: k8s.gcr.io/nfd/node-feature-discovery:$VERSION|" -i *yaml.template` - - [ ] Update quick start instructions in README.md to use $VERSION - - [ ] Update version configuration in `docs/_config.yml`: - - set `version: $VERSION` - - add $VERSION to `versions:` list + - [ ] Run `scripts/prepare-release.sh $VERSION` to turn references to point to the upcoming release + (README, deployment templates, docs .md files, docs configuration, test/e2e flags) - [ ] An OWNER runs `git tag -s $VERSION` and inserts the changelog into the tag description. diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh new file mode 100755 index 000000000..d95918df3 --- /dev/null +++ b/scripts/prepare-release.sh @@ -0,0 +1,80 @@ +#!/bin/bash -e +set -o pipefail + +this=`basename $0` + +usage () { +cat << EOF +Usage: $this [-h] RELEASE_VERSION + +Options: + -h show this help and exit +EOF +} + +# +# Parse command line +# +while getopts "h" opt; do + case $opt in + h) usage + exit 0 + ;; + *) usage + exit 1 + ;; + esac +done +shift "$((OPTIND - 1))" + +# Check that no extra args were provided +if [ $# -gt 1 ]; then + echo -e "ERROR: unknown arguments: $@\n" + usage + exit 1 +fi + +release=$1 +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]} +else + echo -e "ERROR: invalid RELEASE_VERSION '$release'" + exit 1 +fi + +# Patch docs configuration +echo Patching docs/_config.yml +sed -e s"/release:.*/release: $release/" \ + -e s"/version:.*/version: $docs_version/" \ + -i docs/_config.yml + +# Patch container image repo +echo Patching '*.md' files to refer to $container_image +find . -path ./docs/vendor -prune -o -name '*.md' -print | xargs \ + sed -i -e s"!gcr.io/k8s-staging-nfd/node-feature-discovery:[[:alnum:]][[:alnum:].-]*!$container_image!" \ + -e s"!k8s.gcr.io/nfd/node-feature-discovery:[[:alnum:]][[:alnum:].-]*!$container_image!" + +# 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 +echo Patching '*.yaml.template' to use $container_image +sed -E s",^([[:space:]]+)image:.+$,\1image: $container_image," -i *yaml.template + +# 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