Skip to content

Commit 872004a

Browse files
authored
Merge pull request #149 from e0ne/auto-release
Add 'prepare-release.sh' script
2 parents 2935f8f + 2c20284 commit 872004a

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed

.github/ISSUE_TEMPLATE/new-release.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ Please do not remove items from the checklist
1515
- [ ] Manifest related component default versions
1616
- [ ] Example folder is up to date (otherwise submit PR to update)
1717
- [ ] Update network-operator Helm `Chart.yaml` with the release version (`appVersion`, `version` fields)
18+
```
19+
> ./scripts/releases/prepare-release.sh v0.1.2 "Jane Doe <[email protected]>"
20+
```
1821
- [ ] Ensure Helm CI is passing on updated Chart.
1922
- [ ] Tag release
2023
- [ ] Create a new github release
2124
- [ ] Release title: vx.y.z, Release description: Changelog from this issue
2225
- [ ] Release artifacts for current release
2326
- [ ] Update gh-pages branch
27+
```
28+
> ./scripts/releases/update-gh-pages.sh network-operator-0.1.2.tgz
29+
```
2430
- [ ] Create Helm package (master branch on release tag commit):
2531
```
2632
> helm package deployment/network-operator
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash -e
2+
# Copyright 2021 NVIDIA
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o pipefail
17+
18+
this=`basename $0`
19+
20+
usage () {
21+
cat << EOF
22+
Usage: $this [-h] [-p remote name] RELEASE_VERSION GPG_KEY
23+
24+
Options:
25+
-h show this help and exit
26+
-p REMOTE do git push to remote repo
27+
28+
Example:
29+
30+
$this v0.1.2 "Jane Doe <[email protected]>"
31+
32+
33+
NOTE: The GPG key should be associated with the signer's Github account.
34+
EOF
35+
}
36+
37+
sign_helm_chart() {
38+
local chart="$1"
39+
echo "Signing Helm chart $chart"
40+
local sha256=`openssl dgst -sha256 "$chart" | awk '{ print $2 }'`
41+
local yaml=`tar xf $chart -O network-operator/Chart.yaml`
42+
echo "$yaml
43+
...
44+
files:
45+
$chart: sha256:$sha256" | gpg -u "$key" --clearsign -o "$chart.prov"
46+
}
47+
48+
#
49+
# Parse command line
50+
#
51+
while getopts "h" opt; do
52+
case $opt in
53+
h) usage
54+
exit 0
55+
;;
56+
p) push_remote="$OPTARG"
57+
;;
58+
*) usage
59+
exit 1
60+
;;
61+
esac
62+
done
63+
shift "$((OPTIND - 1))"
64+
65+
# Check that no extra args were provided
66+
if [ $# -ne 2 ]; then
67+
if [ $# -lt 2 ]; then
68+
echo -e "ERROR: too few arguments\n"
69+
else
70+
echo -e "ERROR: unknown arguments: ${@:3}\n"
71+
fi
72+
usage
73+
exit 1
74+
fi
75+
76+
release=$1
77+
key="$2"
78+
shift 2
79+
80+
container_image=k8s.gcr.io/nfd/node-feature-discovery:$release
81+
82+
#
83+
# Check/parse release number
84+
#
85+
if [ -z "$release" ]; then
86+
echo -e "ERROR: missing RELEASE_VERSION\n"
87+
usage
88+
exit 1
89+
fi
90+
91+
if [[ $release =~ ^(v[0-9]+\.[0-9]+)(\..+)?$ ]]; then
92+
docs_version=${BASH_REMATCH[1]}
93+
semver=${release:1}
94+
else
95+
echo -e "ERROR: invalid RELEASE_VERSION '$release'"
96+
exit 1
97+
fi
98+
99+
## Patch deployment files
100+
sed -e s"/image:.*/image: mellanox\/network-operator:$release/" \
101+
-i deploy/operator.yaml
102+
103+
# Patch Helm chart
104+
chart=`echo $release | cut -c 2-`
105+
sed -e s"/appVersion:.*/appVersion: $release/" \
106+
-e s"/^version:.*/version: $chart/" \
107+
-i deployment/network-operator/Chart.yaml
108+
sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" \
109+
-i deployment/network-operator/values.yaml
110+
111+
# Commit changes
112+
git add .
113+
git commit -S -m "Release $release"
114+
115+
if [ -n "$push_remote" ]; then
116+
echo "Pushing gh-pages to $push_remote"
117+
git push "$push_remote" gh-pages
118+
119+
fi
120+
121+
#
122+
# Create release assets to be uploaded
123+
#
124+
helm package deployment/network-operator/ --version $semver
125+
126+
chart_name="network-operator-$semver.tgz"
127+
sign_helm_chart $chart_name
128+
129+
cat << EOF
130+
131+
*******************************************************************************
132+
*** Please manually upload the following generated files to the Github release
133+
*** page:
134+
***
135+
*** $chart_name
136+
*** $chart_name.prov
137+
***
138+
*******************************************************************************
139+
EOF
140+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash -e
2+
# Copyright 2021 NVIDIA
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o pipefail
17+
18+
this=`basename $0`
19+
20+
usage () {
21+
cat << EOF
22+
Usage: $this [-h] [-p remote name] <helm-chart>
23+
24+
Options:
25+
-h show this help and exit
26+
-p REMOTE do git push to remote repo
27+
EOF
28+
}
29+
30+
#
31+
# Argument parsing
32+
#
33+
while getopts "hap:" opt; do
34+
case $opt in
35+
h) usage
36+
exit 0
37+
;;
38+
p) push_remote="$OPTARG"
39+
;;
40+
*) usage
41+
exit 1
42+
;;
43+
esac
44+
done
45+
46+
# Check that no extra args were provided
47+
if [ $# -ne 1 ]; then
48+
echo "ERROR: extra positional arguments: $@"
49+
usage
50+
exit 1
51+
fi
52+
53+
exit 2
54+
chart="$1"
55+
release=${chart::-4}
56+
57+
build_dir="/tmp/network-operator-build"
58+
59+
src_dir=$(pwd)
60+
61+
git worktree add $build_dir origin/gh-pages
62+
63+
# Drop worktree on exit
64+
trap "echo 'Removing Git worktree $build_dir'; git worktree remove '$build_dir'" EXIT
65+
66+
# Update Helm package index
67+
mv $chart $build_dir/release
68+
cd $build_dir/release
69+
helm repo index . --url https://mellanox.github.io/network-operator/release --merge ./index.yaml
70+
71+
# Commit change
72+
commit_msg="Release $release"
73+
git add .
74+
git commit -S -m "$commit_msg"
75+
76+
if [ -n "$push_remote" ]; then
77+
echo "Pushing gh-pages to $push_remote"
78+
git push "$push_remote" gh-pages
79+
80+
fi

0 commit comments

Comments
 (0)