Skip to content

Commit

Permalink
Get RPM and Kuryr version from git
Browse files Browse the repository at this point in the history
This commit makes sure we're getting the version to use as RPM and
Python package semver from the last tag in git. This should solve issue
of `kuryr-k8s-controller --version` returning 0.0.0 and remove the need
to update versions in various places each time master gets opened to new
release development.

Change-Id: I5f2d56e1cdad6dace4c456ee7a6ff34f57a02b5d
  • Loading branch information
dulek committed Jun 9, 2020
1 parent c7cf4a1 commit d796a9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 7 additions & 2 deletions openshift-kuryr-kubernetes-rhel8.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ with OpenStack networking.
%global commit 0000000

Name: openshift-%project
Version: 4.6.1
Release: 1%{?dist}
Version: %{_version}
Release: %{_release}%{?dist}
Summary: OpenStack networking integration with OpenShift and Kubernetes
License: ASL 2.0
URL: http://docs.openstack.org/developer/kuryr-kubernetes/
Expand Down Expand Up @@ -112,6 +112,11 @@ rm -f requirements.txt
rm -f test-requirements.txt
rm -f doc/requirements.txt

# We'd get the info directly from git tags, but in OCP builds .git dir is gone,
# so let's just use %{Version} which is passed in OKD builds and sed'ed in OCP
# builds and hardcode it into setup.cfg.
sed -i '/\[metadata\]/aversion = %{version}' setup.cfg

# Kill egg-info in order to generate new SOURCES.txt
rm -rf kuryr_kubernetes.egg-info

Expand Down
14 changes: 9 additions & 5 deletions tools/build-rpm-rhel8.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/bash -x

version=4.6.1
source_path=_output/SOURCES

mkdir -p ${source_path}

# Getting version from last tag in git
version=`git describe --tags --abbrev=0`
version=${version#openshift-kuryr-} # remove prefix
release=${version#*-} # remove prefix
version=${version%-*} # remove date suffix

# NOTE(dulek): rpmbuild requires that inside the tar there will be a
# ${service}-${version} directory, hence this --transform option.
# Also note that for some reason it doesn't work without excluding
# .git directory. Excluding .tox is convenient for local builds.
tar -czvf ${source_path}/kuryr-kubernetes.tar.gz --exclude=.git --exclude=.tox --transform "flags=r;s|\.|kuryr-kubernetes-${version}|" .
# Excluding .tox is convenient for local builds.
tar -czvf ${source_path}/kuryr-kubernetes.tar.gz --exclude=.tox --transform "flags=r;s|\.|kuryr-kubernetes-${version}|" .
cp kuryr.logrotate ${source_path}
cp kuryr-controller.service ${source_path}
cp openshift-kuryr.tmpfs ${source_path}
Expand All @@ -20,5 +24,5 @@ curl http://base-openstack-4-6.ocp.svc > /etc/yum.repos.d/base-openstack-4-6.rep

yum install -y python3-pbr python3-devel

rpmbuild -ba -D "_topdir `pwd`/_output" openshift-kuryr-kubernetes-rhel8.spec
rpmbuild -ba -D "_version $version" -D "_release $release" -D "_topdir `pwd`/_output" openshift-kuryr-kubernetes-rhel8.spec
createrepo _output/RPMS/noarch

0 comments on commit d796a9d

Please sign in to comment.