kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/release/setup_release.sh (about) 1 #!/bin/bash -e 2 3 # Copyright 2015 The Kythe Authors. All rights reserved. 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 # Marks a new release by incrementing the current version number, modifying both RELEASES.md and 18 # kythe/release/BUILD, and creating a new local Git commit. 19 20 # Dependencies: 21 # - https://github.com/clog-tool/clog-cli 22 23 # Guide to creating a Github release: 24 # 1) Run this script on the clean master commit to release 25 # This creates a new release branch with a single commit for the new 26 # release $VERSION and builds the optimized release archive. 27 # $ ./kythe/release/setup_release.sh 28 # 2) Review and edit updated RELEASES.md log 29 # 3) Open a Pull Request for review 30 # 4) "Draft a new release" at https://github.com/kythe/kythe/releases 31 # 5) Set tag version / release title to the new $VERSION 32 # 6) Set description to newest section of RELEASES.md 33 # 7) Upload release outputs (locations printed by the build rule). 34 # These files were generated in step 1. 35 # 8) Mark as "pre-release" and "Save draft" 36 # 9) Add draft release URL to Pull Request 37 # 10) Merge Pull Request once it has been accepted 38 # 11) Edit Github release draft to set the tag's commit as the freshly pushed 39 # release commit 40 # 12) "Publish release" 41 42 cd "$(dirname "$0")"/../.. 43 44 if [[ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]]; then 45 echo "ERROR: not on master branch" >&2 46 exit 1 47 elif [[ -n "$(git diff --name-only)" ]]; then 48 echo "ERROR: locally modified files" >&2 49 git diff --name-only >&2 50 exit 1 51 fi 52 53 # Make sure https://github.com/clog-tool/clog-cli is installed. 54 hash clog || { echo "ERROR: Please install clog-cli"; exit 1; } 55 56 if ! clog --setversion VERSION </dev/null 2>/dev/null | grep -q VERSION; then 57 echo "ERROR: clog appears to not be functioning" >&2 58 echo "ERROR: you may have 'colorized log filter' on your PATH rather than clog-cli" >&2 59 echo "ERROR: please check https://github.com/clog-tool/clog-cli for installation instructions" >&2 60 fi 61 62 previous_version=$(awk '/^release_version =/ { print substr($3, 2, length($3)-2) }' kythe/release/BUILD) 63 64 echo "Previous version: $previous_version" 65 if [[ "$previous_version" != v*.*.* ]]; then 66 echo "Unexpected version format" >&2 67 exit 1 68 fi 69 previous_version=${previous_version#v} 70 71 # shellcheck disable=SC2206 72 components=(${previous_version//./ }) 73 ((components[2]++)) 74 75 join() { local IFS="$1"; shift; echo "$*"; } 76 version="v$(join . "${components[@]}")" 77 echo "Marking release $version" 78 79 # Update RELEASES.md 80 { 81 cat <<EOF 82 # Release Notes 83 84 ## [$version] - $(date +%Y-%m-%d) 85 EOF 86 clog --from "v${previous_version}" --setversion "$version" -r https://github.com/kythe/kythe | tail -n+4 87 tail -n+2 RELEASES.md | sed \ 88 -e "s/\[Unreleased\]/[$version]/" \ 89 -e "s/HEAD/$version/" \ 90 -e "/^\[$version\]/i \ 91 [Unreleased] https://github.com/kythe/kythe/compare/${version}...HEAD" 92 } > RELEASES.md.new 93 mv -f RELEASES.md.new RELEASES.md 94 95 # Update release_version stamp for binaries 96 sed -ri "s/^release_version = .+/release_version = \"$version\"/" kythe/release/BUILD 97 98 if ! diff -q <(git diff --name-only) <(echo RELEASES.md; echo kythe/release/BUILD) >/dev/null; then 99 if [[ -z "$(git diff --name-only -- RELEASES.md)" ]]; then 100 echo "ERROR: RELEASES.md has not been updated (no listed changes?)" >&2 101 exit 1 102 elif [[ -z "$(git diff --name-only -- kythe/release/BUILD)" ]]; then 103 echo "ERROR: kythe/release/BUILD has not been updated" >&2 104 exit 1 105 fi 106 echo "Unexpected changed files in repository:" >&2 107 git diff --name-only | grep -v -e '^RELEASES.md$' -e '^kythe/release/BUILD$' 108 fi 109 110 git checkout -b "release-$version" 111 git commit -anm "release: $version" 112 113 # Build and test the Kythe release archive. 114 bazel --bazelrc=/dev/null test --config=release //kythe/release:release_test 115 bazel --bazelrc=/dev/null build --config=release //kythe/release