Skip to content

Commit

Permalink
Add generate-release-pr to /hack/release-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSirenko committed Oct 20, 2023
1 parent ea601bf commit 6daf796
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash
# This script generates (most of) the file changes needed for a new aws-ebs-csi-driver release

tmp_filename="tmp-$RANDOM.txt" # TODO Needed?

# --- Script Tools
set -euo pipefail # Exit on any error

Expand All @@ -19,6 +17,16 @@ check_dependencies() {
exit 1
fi
done

# Force macOS users to use gsed due to -i incompatibility
export SED="sed"
if [[ $(uname) = "Darwin" ]]; then
if ! command -v "gsed" &>/dev/null; then
log "gsed could not be found, please install it."
exit 1
fi
SED="gsed"
fi
}

error_handler() {
Expand All @@ -29,8 +37,6 @@ error_handler() {
trap 'error_handler ${LINENO} $? "$BASH_COMMAND"' ERR

# --- Script
# trap 'rm $tmp_filename' EXIT TODO ?

usage () {
echo "Usage: $0 [NEW_DRIVER_VERSION] [optional-cmd]"
echo "example: $0 v1.24.0"
Expand Down Expand Up @@ -66,9 +72,6 @@ parse_args () {
[[ $# -ne 1 ]] && usage

setup_vars "$@"

# Confirm sure new version isn't same as current version
[[ "$NEW_DRIVER_VERSION" == "$PREV_DRIVER_VERSION" ]] || log "ERROR: $NEW_DRIVER_VERSION is the existing driver version"
}

update_driver_source_of_truth () {
Expand All @@ -90,26 +93,24 @@ update_readme () {

update_makefile () {
log "Updating Makefile"
# TODO figure out how to standardize GNU and BSD sed? Always redirect into tmp file?
gsed "s/VERSION?=$PREV_DRIVER_VERSION/VERSION?=$NEW_DRIVER_VERSION/g" "$MAKEFILE_PATH"
$SED "s/VERSION?=$PREV_DRIVER_VERSION/VERSION?=$NEW_DRIVER_VERSION/g" -i "$MAKEFILE_PATH"
}

update_installmd () {
log "Updating docs/install.md"
prev_major_minor_version=$(echo "$PREV_DRIVER_VERSION" | sed 's/v\([0-9]*\.[0-9]*\).*/\1/')
new_major_minor_version=$(echo "$NEW_DRIVER_VERSION" | sed 's/v\([0-9]*\.[0-9]*\).*/\1/')
gsed "s/?ref=release-$prev_major_minor_version/?ref=release-$new_major_minor_version/g" "$INSTALL_MD_PATH"
$SED "s/?ref=release-$prev_major_minor_version/?ref=release-$new_major_minor_version/g" -i "$INSTALL_MD_PATH"
}

update_chart_and_overlays () {
log "Updating helm chart and generates kustomize"
prev_minor_patch_version=$(echo "$PREV_DRIVER_VERSION" | sed 's/v[0-9]*\.//')
new_minor_patch_version=$(echo "$NEW_DRIVER_VERSION" | sed 's/v[0-9]*\.//')

gsed "s/$prev_minor_patch_version$/$new_minor_patch_version/g" "$CHART_PATH"
$SED "s/$prev_minor_patch_version$/$new_minor_patch_version/g" -i "$CHART_PATH"

(cd "$ROOT_DIRECTORY"; make generate-kustomize) > tmp.f # TODO look up proper null print
rm tmp.f
(cd "$ROOT_DIRECTORY"; make generate-kustomize) > "/dev/null"
}

update_upstream_repo () {
Expand All @@ -122,14 +123,15 @@ update_upstream_repo () {
print_rest_of_release_steps () {
echo "SUCCESS!
Before you submit the release PR, you must also:
1. Update CHANGELOG.md
2. Update charts/aws-ebs-csi-driver/CHANGELOG.md"
1. Check that 'git diff' produces what you expected.
2. Update CHANGELOG.md
3. Update charts/aws-ebs-csi-driver/CHANGELOG.md"
}

main () {
check_dependencies
parse_args "$@"
# update_driver_source_of_truth TODO test
update_driver_source_of_truth

# Post-release PR except changelogs
update_upstream_repo
Expand Down
2 changes: 1 addition & 1 deletion hack/release-scripts/image-source-of-truth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ driver:
name: "aws-ebs-csi-driver"
version: "v1.24.0"
gcrStagingImage: "gcr.io/k8s-staging-provider-aws/aws-ebs-csi-driver"
manifestDigest: ""
manifestDigest: "sha256:3dba81d0c3c8ce51abeda40ec0dbad7e4930a89c8c6a1984a64bf67caa46a3ae"
gcrImage: "registry.k8s.io/provider-aws/aws-ebs-csi-driver"
ecrImage: "public.ecr.aws/ebs-csi-driver/aws-ebs-csi-driver"
sidecars: # sidecar names match upstream helm chart values.yaml
Expand Down

0 comments on commit 6daf796

Please sign in to comment.