-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from gdbranco/chore/hack-scripts-to-help-release
Adding hack scripts to help release process
- Loading branch information
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# OCM Helper Scripts | ||
|
||
These scripts help in the process of releasing new versions of `ocm`. | ||
|
||
Once all changes for a specific release are in `main`, the next step is to | ||
create a release commit: | ||
|
||
./hack/commit-release.sh | ||
|
||
This creates a new branch, updates the OCM build version and changelog file | ||
then commits and pushes to GitHub. Any potentially destructing action has a | ||
confirmation prompt. | ||
|
||
Once this new branch is pushed, someone has to merge it. Once merged, make sure | ||
to update your local copy. Then you can tag the actual release: | ||
|
||
./hack/tag-release.sh | ||
|
||
This will create a new annotated tag and push it to the upstream OCM | ||
repository. | ||
|
||
Now that the tag is in place, you will go to the | ||
[tags page](https://github.com/openshift/ocm/tags) and edit the latest one. In | ||
there make sure that the release title and description match the release tag | ||
annotation. | ||
|
||
Publish the release and you're done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2022 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# This generates the commit necessary for release of the next z-stream tag. | ||
|
||
git fetch --tags | ||
tagcommit=$(git rev-list --tags --max-count=1) | ||
current=$(git describe --tags $tagcommit | sed 's/v//') | ||
echo "Current version is $current" | ||
|
||
base=$(echo $current | grep -o ".*\.") | ||
next_z=$(echo $current | sed -E "s/.*\.([0-9]*)/\1+1/" | bc) | ||
base_y=$(echo $current | grep -o "^[0-9]*\.[0-9]*") | ||
next_y=$(echo $base_y | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | ||
|
||
# Update version | ||
read -r -p "Bump minor version for '$current' ocm cli? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
next=$next_y.0 | ||
else | ||
next=$base$next_z | ||
fi | ||
|
||
echo "Next version will be $next" | ||
|
||
# Update version | ||
read -r -p "Update version to '$next'? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
sed -i "s/$current/$next/" pkg/info/info.go | ||
fi | ||
|
||
# Update changelog | ||
read -r -p "Update changelog? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
log=$(git log v$current..HEAD --oneline --no-merges --no-decorate --reverse | sed "s/^\w*/-/") | ||
echo "$log" | ||
|
||
rest=$(awk "/ $current /{found=1} found" CHANGES.md) | ||
header=$(cat << EOM | ||
# Changes | ||
This document describes the relevant changes between releases of the\n\`ocm\` command line tool. | ||
EOM | ||
) | ||
echo -e "$header\n\n## $next $(date "+%b %-d %Y")\n\n$log\n\n$rest" > CHANGES.md | ||
fi | ||
|
||
# Commit changes | ||
branch="release_$next" | ||
read -r -p "Commit changes to branch '$branch'? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
git checkout -b $branch | ||
git commit --all --message "Release v$next" --message "$log" | ||
else | ||
echo -e "\tgit checkout -b $branch" | ||
echo -e "\tgit commit --all" | ||
fi | ||
|
||
read -r -p "Push branch '$branch' to GitHub? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
git push --set-upstream origin $branch | ||
else | ||
echo -e "\tgit push --set-upstream origin $branch" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2022 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# This tags the latest release | ||
|
||
current=$(git tag --list --sort version:refname | tail -n1) | ||
next="v$(cat pkg/info/info.go | grep -o '[0-9.]*' | tail -n1)" | ||
echo "Tagging release $next" | ||
|
||
# Create git release tag | ||
log=$(git log $current..HEAD --oneline --no-merges --no-decorate --reverse | grep -v $next | sed "s/^\w*/-/") | ||
read -r -p "Create release tag '$next'? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
git tag --annotate --message "Release $next" --message "$log" $next | ||
else | ||
echo -e "\tgit tag --annotate $next" | ||
fi | ||
|
||
# Push git release tag to upstream GitHub repository | ||
upstream=$(git remote --verbose | grep "github\.com.openshift-online\/ocm-cli\.git" | tail -n1 | awk '{print $1}') | ||
read -r -p "Push tag '$next' to GitHub? [y/N] " response | ||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] | ||
then | ||
git push $upstream $next | ||
else | ||
echo -e "\tgit push $upstream $next" | ||
fi |