github.com/GoogleContainerTools/kaniko@v1.23.0/hack/release.sh (about) 1 #!/bin/bash 2 3 # Copyright 2018 Google LLC 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 18 EXAMPLES_DIR=${DIR}/../examples 19 20 # Prompt the user for the version 21 echo -n "Enter the version for this release - ex: v1.14.0: " 22 read VERSION 23 24 # Remove 'v' prefix from version 25 MAKEFILE_VERSION=$(echo $VERSION | sed 's/^[v]//') 26 27 # Extract major, minor, and build version numbers 28 VERSION_MAJOR=$(echo $MAKEFILE_VERSION | cut -d. -f1) 29 VERSION_MINOR=$(echo $MAKEFILE_VERSION | cut -d. -f2) 30 VERSION_BUILD=$(echo $MAKEFILE_VERSION | cut -d. -f3) 31 32 echo "Processing (takes some time)..." 33 34 # Get the current date 35 DATE=$(date +'%Y-%m-%d') 36 37 # you can pass your github token with --token here if you run out of requests 38 # Capture output and replace newline characters with a placeholder 39 PULL_REQS=$(go run ${DIR}/release_notes/listpullreqs.go | tr '\n' '|') 40 CONTRIBUTORS=$(git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }' | tr '\n' '|') 41 42 # Substitute placeholders with actual data in the template 43 TEMP_CHANGELOG=$(mktemp) 44 TEMP_CHANGELOG_FIXED=$(mktemp) 45 sed -e "s@{{PULL_REQUESTS}}@${PULL_REQS}@g" \ 46 -e "s@{{CONTRIBUTORS}}@${CONTRIBUTORS}@g" \ 47 -e "s@{{VERSION}}@${VERSION}@g" \ 48 -e "s@{{DATE}}@${DATE}@g" \ 49 ${DIR}/release_notes/changelog_template.txt > $TEMP_CHANGELOG 50 51 # Replace '|' with '\n' in temporary changelog 52 sed 's/|/\n/g' $TEMP_CHANGELOG > $TEMP_CHANGELOG_FIXED 53 54 # Prepend to CHANGELOG.md 55 cat $TEMP_CHANGELOG_FIXED CHANGELOG.md > TEMP && mv TEMP CHANGELOG.md 56 57 echo "Prepended the following release information to CHANGELOG.md" 58 echo "" 59 cat $TEMP_CHANGELOG_FIXED 60 61 # Optionally, clean up the fixed temporary changlog file 62 rm $TEMP_CHANGELOG_FIXED 63 64 # Cleanup 65 rm $TEMP_CHANGELOG 66 67 echo "Updated Makefile for the new version: $VERSION" 68 # Update Makefile 69 sed -i.bak \ 70 -e "s|VERSION_MAJOR ?=.*|VERSION_MAJOR ?= $VERSION_MAJOR|" \ 71 -e "s|VERSION_MINOR ?=.*|VERSION_MINOR ?= $VERSION_MINOR|" \ 72 -e "s|VERSION_BUILD ?=.*|VERSION_BUILD ?= $VERSION_BUILD|" \ 73 ./Makefile 74 75 # Cleanup 76 rm ./Makefile.bak