Skip to content

Commit

Permalink
build: fix rpm release names for snapshot builds
Browse files Browse the repository at this point in the history
GitHub builds had duplicated dates in RPM names. Also swapped date and
githash so that RPMs are time-sorted. Use githash for snapshot builds.
  • Loading branch information
michalskrivanek committed Nov 8, 2022
1 parent 2b9f47d commit 18e663d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 41 deletions.
1 change: 0 additions & 1 deletion .automation/build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ BUILD_LOCALES=0
rpmbuild \
-D "_topmdir rpmbuild" \
-D "_rpmdir rpmbuild" \
${RELEASE:+-D "release_suffix ${RELEASE}"} \
-D "ovirt_build_ut ${BUILD_UT}" \
-D "ovirt_build_all_user_agents ${BUILD_ALL_USER_AGENTS}" \
-D "ovirt_build_locales ${BUILD_LOCALES}" \
Expand Down
17 changes: 4 additions & 13 deletions .automation/build-srpm.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
#!/bin/bash -xe

# git hash of current commit should be passed as the 1st paraameter
if [ "${GITHUB_SHA}" == "" ]; then
GIT_HASH=$(git rev-list HEAD | wc -l)
else
GIT_HASH=$(git rev-parse --short $GITHUB_SHA)
fi
# git hash of current commit passed from GitHub or HEAD
GIT_HASH=$(git rev-parse --short ${GITHUB_SHA:-HEAD})
SUFFIX=$(grep -E "<version" pom.xml | head -n1 | awk -F '[<>]' '/version/{print $3}' | grep -q -- -SNAPSHOT && echo .git${GIT_HASH})

# Directory, where build artifacts will be stored, should be passed as the 1st parameter
ARTIFACTS_DIR=${1:-exported-artifacts}

# Prepare the version string (with support for SNAPSHOT versioning)
VERSION=$(mvn help:evaluate -q -DforceStdout -Dexpression=project.version)
VERSION=${VERSION/-SNAPSHOT/-0.${GIT_HASH}.$(date +%04Y%02m%02d%02H%02M)}
IFS='-' read -ra VERSION <<< "$VERSION"
RELEASE=${VERSION[1]-1}
MILESTONE=master

# GH RPM builds will be used only for OST so Firefox and Chrome are enough
# GWT build memory needs to be limited
EXTRA_BUILD_FLAGS=""
Expand All @@ -42,4 +32,5 @@ mv *.tar.gz rpmbuild/SOURCES
# create the src.rpm
rpmbuild \
-D "_topdir rpmbuild" \
${SUFFIX:+-D "release_suffix ${SUFFIX}"} \
-ts rpmbuild/SOURCES/*.gz
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ OFFLINE_BUILD_MAVEN_SETTINGS=$(shell pwd)/build/offline-build-maven-settings.xml

include version.mak
# major, minor, seq
ENGINE_VERSION:=$(shell cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' -e 's/-SNAPSHOT//')
PACKAGE_VERSION=$(ENGINE_VERSION)$(if $(MILESTONE),_$(MILESTONE))
PACKAGE_VERSION=$(RPM_VERSION)$(if $(MILESTONE),_$(MILESTONE))
DISPLAY_VERSION=$(PACKAGE_VERSION)

DEV_BUILD_FLAGS:=-P brand-source-maps
Expand Down Expand Up @@ -172,7 +171,7 @@ BUILD_TARGET=install
-e "s|@SETUP_VAR@|$(PKG_STATE_DIR)|g" \
-e "s|@DEV_PYTHON_DIR@|$(DEV_PYTHON_DIR)|g" \
-e "s|@DEV_SETUP_ENV_DIR@|$(DEV_SETUP_ENV_DIR)|g" \
-e "s|@RPM_VERSION@|$(ENGINE_VERSION)|g" \
-e "s|@RPM_VERSION@|$(RPM_VERSION)|g" \
-e "s|@RPM_RELEASE@|$(RPM_RELEASE)|g" \
-e "s|@MILESTONE@|$(MILESTONE)|g" \
-e "s|@PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
Expand Down
40 changes: 16 additions & 24 deletions version.mak
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,28 @@
# - master
# - <none>
#
MILESTONE_IF_NEEDED=master
MILESTONE_IF_NEEDED=zstream

# RPM_RELEASE_ON_RELEASE should be set to the rpm release to have on release (non-SNAPSHOT) builds.
RPM_RELEASE_ON_RELEASE=1

# AUTO_MILESTONE is set to MILESTONE_IF_NEEDED on SNAPSHOT builds, empty otherwise.
AUTO_MILESTONE=$(shell cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' | grep -q 'SNAPSHOT$$' && echo $(MILESTONE_IF_NEEDED))
# MILESTONE is set to MILESTONE_IF_NEEDED on SNAPSHOT builds, empty otherwise.
ifndef MILESTONE
MILESTONE=$(shell cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' | grep -q 'SNAPSHOT$$' && echo $(MILESTONE_IF_NEEDED))
endif

# AUTO_RPM_RELEASE is set to 0.0.something on SNAPSHOT builds, and to RPM_RELEASE_ON_RELEASE otherwise.
AUTO_RPM_RELEASE=$(shell if cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' | grep -q 'SNAPSHOT$$'; then echo 0.2.$(MILESTONE).$$(date -u +%Y%m%d%H%M%S); else echo $(RPM_RELEASE_ON_RELEASE); fi)
# RPM_VERSION is set to pom version without -SNAPSHOT
ifndef RPM_VERSION
RPM_VERSION:=$(shell cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' -e 's/-SNAPSHOT//')
endif

MILESTONE=$(AUTO_MILESTONE)

# RPM release should be automatic. If needed to be set manually:
# RPM release should be automatic.
# Set to 0.something on SNAPSHOT builds, and to RPM_RELEASE_ON_RELEASE otherwise.
# If needed to be set manually:
# For pre-release:
# RPM_RELEASE=0.N.$(MILESTONE).$(shell date -u +%Y%m%d%H%M%S)
# While N is incremented when milestone is changed.
# RPM_RELEASE=0.$(MILESTONE).$(shell date -u +%Y%m%d%H%M%S)
#
# For release:
# RPM_RELEASE=N
# while N is incremented each re-release
#
RPM_RELEASE=$(AUTO_RPM_RELEASE)

#
# Downstream only release prefix
# Downstream (mead) does not use RPM_RELEASE but internal
# mead versioning.
# Increment the variable bellow after every milestone is
# released.
# Or leave empty to have only mead numbering.
#
DOWNSTREAM_RPM_RELEASE_PREFIX=0.
ifndef RPM_RELEASE
RPM_RELEASE=$(shell if cat pom.xml | head -n 20 | grep '<version>' | head -n 1 | sed -e 's/.*>\(.*\)<.*/\1/' | grep -q 'SNAPSHOT$$'; then echo 0.$(MILESTONE).$$(date -u +%Y%m%d%H%M%S); else echo $(RPM_RELEASE_ON_RELEASE); fi)
endif

0 comments on commit 18e663d

Please sign in to comment.