Skip to content

Commit

Permalink
feat: add automated way of cutting releases w/ generation of CHANGELO…
Browse files Browse the repository at this point in the history
…G.md & Makefile changes (#2786)
  • Loading branch information
aaron-prindle committed Oct 10, 2023
1 parent ee3ea59 commit c8c839a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
55 changes: 52 additions & 3 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,57 @@
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
EXAMPLES_DIR=${DIR}/../examples

# Prompt the user for the version
echo -n "Enter the version for this release - ex: v1.14.0: "
read VERSION

# Remove 'v' prefix from version
MAKEFILE_VERSION=$(echo $VERSION | sed 's/^[v]//')

# Extract major, minor, and build version numbers
VERSION_MAJOR=$(echo $MAKEFILE_VERSION | cut -d. -f1)
VERSION_MINOR=$(echo $MAKEFILE_VERSION | cut -d. -f2)
VERSION_BUILD=$(echo $MAKEFILE_VERSION | cut -d. -f3)

echo "Processing (takes some time)..."

# Get the current date
DATE=$(date +'%Y-%m-%d')

# you can pass your github token with --token here if you run out of requests
go run ${DIR}/release_notes/listpullreqs.go
# Capture output and replace newline characters with a placeholder
PULL_REQS=$(go run ${DIR}/release_notes/listpullreqs.go | tr '\n' '|')
CONTRIBUTORS=$(git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }' | tr '\n' '|')

# Substitute placeholders with actual data in the template
TEMP_CHANGELOG=$(mktemp)
TEMP_CHANGELOG_FIXED=$(mktemp)
sed -e "s@{{PULL_REQUESTS}}@${PULL_REQS}@g" \
-e "s@{{CONTRIBUTORS}}@${CONTRIBUTORS}@g" \
-e "s@{{VERSION}}@${VERSION}@g" \
-e "s@{{DATE}}@${DATE}@g" \
${DIR}/release_notes/changelog_template.txt > $TEMP_CHANGELOG

# Replace '|' with '\n' in temporary changelog
sed 's/|/\n/g' $TEMP_CHANGELOG > $TEMP_CHANGELOG_FIXED

# Prepend to CHANGELOG.md
cat $TEMP_CHANGELOG_FIXED CHANGELOG.md > TEMP && mv TEMP CHANGELOG.md

echo "Prepended the following to release information to CHANGELOG.md"
echo ""
cat $TEMP_CHANGELOG_FIXED

# Optionally, clean up the fixed temporary changlog file
rm $TEMP_CHANGELOG_FIXED

# Cleanup
rm $TEMP_CHANGELOG

echo "Huge thank you for this release towards our contributors: "
git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }'
echo "Updated Makefile for the new version: $VERSION"
# Update Makefile
sed -i.bak \
-e "s|VERSION_MAJOR ?=.*|VERSION_MAJOR ?= $VERSION_MAJOR|" \
-e "s|VERSION_MINOR ?=.*|VERSION_MINOR ?= $VERSION_MINOR|" \
-e "s|VERSION_BUILD ?=.*|VERSION_BUILD ?= $VERSION_BUILD|" \
./Makefile
24 changes: 24 additions & 0 deletions hack/release_notes/changelog_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# {{VERSION}} Release {{DATE}}
The executor images in this release are:
```
gcr.io/kaniko-project/executor:{{VERSION}}
gcr.io/kaniko-project/executor:latest
```

The debug images are available at:
```
gcr.io/kaniko-project/executor:debug
gcr.io/kaniko-project/executor:{{VERSION}}-debug
```

The slim executor images which don't contain any authentication binaries are available at:
```
gcr.io/kaniko-project/executor:slim
gcr.io/kaniko-project/executor:{{VERSION}}-slim
```

{{PULL_REQUESTS}}

Huge thank you for this release towards our contributors:
{{CONTRIBUTORS}}

0 comments on commit c8c839a

Please sign in to comment.