Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build do not patch copr for releases #599

Merged
merged 4 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .copr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ git_cfg_safe:
git config --global --add safe.directory "$(shell pwd)"

srpm: installdeps git_cfg_safe
$(eval SUFFIX=.git$(shell git rev-parse --short HEAD))
# Set SUFFIX to .git$HASH if we are on a -SNAPSHOT
$(eval SUFFIX=$(shell grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}' | grep -q -- -SNAPSHOT && echo .git$(git rev-parse --short HEAD)))
# changing the spec file as passing -D won't preserve the suffix when rebuilding in mock
sed "s:%{?release_suffix}:${SUFFIX}:" -i ovirt-engine.spec.in
mkdir -p tmp.repos/SOURCES
Expand Down
94 changes: 57 additions & 37 deletions bump_release.sh
Original file line number Diff line number Diff line change
@@ -1,56 +1,76 @@
#!/bin/bash -xe

# Usage:
#
# RPM_PACKAGER='Name Lastname <email@address.com>' ./bump_release.sh
#
# The built version is always taken from current pom.xml, only removing -SNAPSHOT
#
# You can override the _next_ version. E.g. if you are on 4.6.8-SNAPSHOT and
# intend to release 4.6.8 and then branch it to ovirt-engine-4.6, bumping master
# to 4.7, you can do:
#
# NEXT_VERSION=4.7 RPM_PACKAGER='Name Lastname <email@address.com>' ./bump_release.sh
#
# Then you should branch and bump there, e.g.:
# git branch ovirt-engine-4.6 ovirt-engine-4.6.8
# git checkout ovirt-engine-4.6
# RPM_PACKAGER='Name Lastname <email@address.com>' ./bump_release.sh

if [ -z "${RPM_PACKAGER}" ] ; then
echo 'Please export RPM_PACKAGER="Name Lastname <email@address.com>'
exit 1
fi

# Set pom to build final release
find . -name pom.xml -exec sed -i "s:-SNAPSHOT::" {} +

# Get current ovirt-engine version
VERSION="$(grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}')"

# Prepare changelog
CHANGELOG="* $(LC_ALL=C date "+%a %b %d %Y") ${RPM_PACKAGER} - ${VERSION}\n- Bump version to ${VERSION}\n"
export CHANGELOG

# Add changelog to the spec file
sed -i "/^%changelog/a ${CHANGELOG}" ovirt-engine.spec.in

# Adjust copr build config for releasing
patch -p0 --ignore-whitespace .copr/Makefile <<'__EOF__'
diff --git a/.copr/Makefile b/.copr/Makefile
index 51e3299e3e5..b2d4a195740 100644
--- a/.copr/Makefile
+++ b/.copr/Makefile
@@ -9,9 +9,9 @@ git_cfg_safe:
git config --global --add safe.directory "$(shell pwd)"

srpm: installdeps git_cfg_safe
- $(eval SUFFIX=.git$(shell git rev-parse --short HEAD))
+ # $(eval SUFFIX=.git$(shell git rev-parse --short HEAD))
# changing the spec file as passing -D won't preserve the suffix when rebuilding in mock
- sed "s:%{?release_suffix}:${SUFFIX}:" -i ovirt-engine.spec.in
+ # sed "s:%{?release_suffix}:${SUFFIX}:" -i ovirt-engine.spec.in
mkdir -p tmp.repos/SOURCES
make dist
rpmbuild \
__EOF__
if ! grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}' | grep -q -- -SNAPSHOT; then
# We are already on a release. Most likely this is because we are right after branching a stable branch from master.
# Get current ovirt-engine version
VERSION="$(grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}')"
else
# Set pom to build final release
find . -name pom.xml -exec sed -i "s:-SNAPSHOT::" {} +

# commit
git add -u
git commit -s --message="build: ovirt-engine-${VERSION}"
# Get current ovirt-engine version
VERSION="$(grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}')"

# Prepare changelog
CHANGELOG="* $(LC_ALL=C date "+%a %b %d %Y") ${RPM_PACKAGER} - ${VERSION}\n- Bump version to ${VERSION}\n"
export CHANGELOG

# Add changelog to the spec file
sed -i "/^%changelog/a ${CHANGELOG}" ovirt-engine.spec.in

# commit
git add -u
git commit -s --message="build: ovirt-engine-${VERSION}"

TAG="ovirt-engine-${VERSION}"
git tag "${TAG}"
fi

# Restore the -SNAPSHOT preserving latest changelog
git show |patch -p 1 -R
git checkout -- ovirt-engine.spec.in

# Bump to next version
NEXT_VERSION="$(echo ${VERSION} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')"
if [ -z "${NEXT_VERSION}" ]; then
NEXT_VERSION="$(echo ${VERSION} | awk -F. '{for (i=1; i<NF; i++) res=res $i "."; res=res $NF+1; print res}')"
MSG="build: post ovirt-engine-${VERSION}"
else
# If we did get NEXT_VERSION, we want the commit message to be
# post PREVIOUS
# where PREVIOUS only has the number of components as the NEXT VERSION.
# e.g. bumping from 4.6.8 to 4.7 should say "post 4.6", not "post 4.6.8".
# This isn't just cosmetic, it's also significant - because we are quite
# likely to branch a 4.6 branch from the 4.6.8 tag, and there we'll want
# a commit 'post 4.6.8'.
PREVIOUS_VERSION="$(echo ${NEXT_VERSION} | awk -F. '{for (i=1; i<NF; i++) res=res $i "."; res=res $NF-1; print res}')"
MSG="build: post ovirt-engine-${PREVIOUS_VERSION}"
fi

export NEXT_VERSION
find . -name pom.xml -exec sed -i "s:${VERSION}-SNAPSHOT:${NEXT_VERSION}-SNAPSHOT:" {} +

# commit
git add -u
git commit -s --message="build: post ovirt-engine-${VERSION}"
git commit -s --message="${MSG}"