summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevan Carpenter <devan@taler.net>2023-10-12 17:33:42 -0400
committerDevan Carpenter <devan@taler.net>2023-12-13 12:16:01 -0500
commit9736882af559a483fb14a5fbed61b839998f23ed (patch)
treeeeaf6f0823335a40eb1a2a641d6cba4b2eae1773
parent832d2f4faa5987016d066ced9b211e48cfc97d3a (diff)
downloadexchange-9736882af559a483fb14a5fbed61b839998f23ed.tar.gz
exchange-9736882af559a483fb14a5fbed61b839998f23ed.tar.bz2
exchange-9736882af559a483fb14a5fbed61b839998f23ed.zip
ci: fixup debian packaging job
cleanup and make packaging job more robust git version 2.4.4 changed the way rev-parsing worked in a detached head state
-rw-r--r--contrib/ci/Containerfile3
-rwxr-xr-xcontrib/ci/jobs/4-deb-package/job.sh21
-rwxr-xr-xcontrib/ci/jobs/4-deb-package/version.sh17
3 files changed, 29 insertions, 12 deletions
diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile
index b5f191ea7..c90204e20 100644
--- a/contrib/ci/Containerfile
+++ b/contrib/ci/Containerfile
@@ -32,7 +32,8 @@ RUN apt-get install -yqq \
po-debconf \
build-essential \
debhelper-compat \
- devscripts
+ devscripts \
+ git-buildpackage
# Documentation dependencies
RUN apt-get install -yqq \
diff --git a/contrib/ci/jobs/4-deb-package/job.sh b/contrib/ci/jobs/4-deb-package/job.sh
index dc78cdf24..adc2a777b 100755
--- a/contrib/ci/jobs/4-deb-package/job.sh
+++ b/contrib/ci/jobs/4-deb-package/job.sh
@@ -3,22 +3,21 @@ set -exuo pipefail
# This file is in the public domain.
# Helper script to build the latest DEB packages in the container.
-unset LD_LIBRARY_PATH
-
-git apply ./ci/jobs/2-deb-package/install-fix.patch
-
-# Get current version from debian/control file.
-DEB_VERSION=$(dpkg-parsechangelog -S Version)
+unset LD_LIBRARY_PATH
# Install build-time dependencies.
+# Update apt cache first
+apt-get update
+apt-get upgrade -y
mk-build-deps --install --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control
-# We do a sparse checkout, so we need to hint
-# the version to the build system.
-echo $DEB_VERSION > .version
+export VERSION="$(./contrib/ci/jobs/4-deb-package/version.sh)"
+echo "Building package version ${VERSION}"
+EMAIL=none gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="${VERSION}"
./bootstrap
dpkg-buildpackage -rfakeroot -b -uc -us
-ls ../*.deb
-mv ../*.deb /artifacts/
+ls -alh ../*.deb
+mkdir -p /artifacts/exchange/${CI_COMMIT_REF} # Variable comes from CI environment
+mv ../*.deb /artifacts/exchange/${CI_COMMIT_REF}/
diff --git a/contrib/ci/jobs/4-deb-package/version.sh b/contrib/ci/jobs/4-deb-package/version.sh
new file mode 100755
index 000000000..d2647785e
--- /dev/null
+++ b/contrib/ci/jobs/4-deb-package/version.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -ex
+
+BRANCH=$(git name-rev --name-only HEAD)
+if [ -z "${BRANCH}" ]; then
+ exit 1
+else
+ # "Unshallow" our checkout, but only our current branch, and exclude the submodules.
+ git fetch --no-recurse-submodules --tags --depth=1000 origin "${BRANCH}"
+ RECENT_VERSION_TAG=$(git describe --tags --match 'v*.*.*' --always --abbrev=0 HEAD || exit 1)
+ commits="$(git rev-list ${RECENT_VERSION_TAG}..HEAD --count)"
+ if [ "${commits}" = "0" ]; then
+ git describe --tag HEAD || exit 1
+ else
+ echo $(echo ${RECENT_VERSION_TAG} | sed -r 's/^v//')-${commits}-$(git rev-parse --short=8 HEAD)
+ fi
+fi