Skip to content

Commit

Permalink
Reference chart and container image in release notes
Browse files Browse the repository at this point in the history
Also print some output for each step in the release script for
visibility and to ease troubleshooting
  • Loading branch information
oyvindio committed Jun 2, 2022
1 parent 95909a9 commit 838e4f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
28 changes: 22 additions & 6 deletions bin/make_release
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cd "$(git rev-parse --show-toplevel)"

# the first parameter should be the name of an annotated tag in the git repo
RELEASE="$1"
RELEASE_NOTES_FILE=build/release-notes
IMAGE=fiaas/fiaas-deploy-daemon
# the following files under build/ are artifacts expected to be created by the initial build stage
# the container image tarball
Expand All @@ -21,10 +22,10 @@ function update_chart_release_version() {
for file in Chart.yaml.tpl values.yaml.tpl; do
local template_path="helm/fiaas-deploy-daemon/$file"
local result_path="helm/fiaas-deploy-daemon/${file%%.tpl}" # remove .tpl suffix
echo "Setting RELEASE_VERSION=${release} CHART_VERSION=${chart_version} in $result_path"
# '$RELEASE_VERSION' and '$CHART_VERSION' not supposed to be expanded below; it tells envsubst to substitute
# those variables only
# shellcheck disable=SC2016
echo "Setting RELEASE_VERSION=${release} CHART_VERSION=${chart_version} in $result_path"
RELEASE_VERSION="$release" CHART_VERSION="$chart_version" \
envsubst '$RELEASE_VERSION $CHART_VERSION' < "$template_path" > "$result_path"
done
Expand Down Expand Up @@ -73,6 +74,19 @@ function tag_push_docker_image() {
echo "Pushed image $release_tag"
}

function generate_release_notes() {
local release="$1"
local release_image_ref="$2"
# strip the `v` prefix of the tag name to get chart version
local chart_version="${release##v}"
local git_tag_annotation
git_tag_annotation="$(git tag --list --format='%(contents)' "$release")"

# shellcheck disable=SC2016
GIT_TAG_ANNOTATION="$git_tag_annotation" RELEASE_IMAGE_REF="$release_image_ref" CHART_VERSION="$chart_version" \
envsubst '$GIT_TAG_ANNOTATION $RELEASE_IMAGE_REF $CHART_VERSION' < release-notes.md.tpl
}

if [[ "${CI:-false}" != "true" ]]; then
echo "$0 is intended to run only in CI, run CI=true $0 to override"
exit 1
Expand All @@ -88,17 +102,19 @@ if gh release view "$RELEASE" &> /dev/null; then
exit 3
fi

# get release notes from the content of the annotated release tag
git tag --list --format='%(contents)' "$RELEASE" > build/release-notes
echo "Generating release notes for $RELEASE to $RELEASE_NOTES_FILE"
generate_release_notes "$RELEASE" "${IMAGE}:$RELEASE" > "$RELEASE_NOTES_FILE"

# publish artifacts
echo "Tagging and pushing container image from $IMAGE_TARBALL as ${IMAGE}:$RELEASE"
tag_push_docker_image "$IMAGE_TARBALL" "${IMAGE}:$IMAGE_VERSION" "${IMAGE}:$RELEASE"

echo "Packaging and publishing helm chart"
publish_helm_chart "$RELEASE"

# create the github release
echo "Creating Github release $RELEASE"
gh release create \
--title "fiaas-deploy-daemon $RELEASE" \
--notes-file build/release-notes \
--notes-file "$RELEASE_NOTES_FILE" \
--generate-notes \
--prerelease \
--draft \
Expand Down
11 changes: 11 additions & 0 deletions release-notes.md.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
${GIT_TAG_ANNOTATION}

## Release Artifacts
- Container image: `${RELEASE_IMAGE_REF}`
- `fiaas-deploy-daemon` Helm chart version `${CHART_VERSION}`

Find the helm chart by adding the FIAAS helm repo and inspecting the chart from there:
```shell
helm repo add fiaas https://fiaas.github.io/helm
helm search repo fiaas-deploy-daemon --version ${CHART_VERSION}
```

0 comments on commit 838e4f0

Please sign in to comment.