Skip to content

Commit

Permalink
Align RPM release with release reported by command line tools
Browse files Browse the repository at this point in the history
Make sure, that RPM release for snapshot builds is properly passed to
the build, so this release can be reported correctly in command line
tools.

Fixes: eclipse-bluechi#753
Signed-off-by: Martin Perina <[email protected]>
  • Loading branch information
mwperina committed Feb 20, 2024
1 parent 76c6d4f commit 2327958
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ builddir/
bluechi.spec
rpmbuild/
artifacts/
build-scripts/RELEASE

## python build artifacts
build/
dist/
Expand Down
4 changes: 4 additions & 0 deletions build-scripts/build-srpm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash -xe
# SPDX-License-Identifier: LGPL-2.1-or-later

# Clean previously generated release cache
$(dirname "$(readlink -f "$0")")/version.sh clean

# Create source archive
source $(dirname "$(readlink -f "$0")")/create-archive.sh

mv bluechi-$VERSION.tar.gz rpmbuild/SOURCES/
Expand Down
9 changes: 8 additions & 1 deletion build-scripts/create-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ source $(dirname "$(readlink -f "$0")")/create-spec.sh
# Prepare source archive
[[ -d rpmbuild/SOURCES ]] || mkdir -p rpmbuild/SOURCES

git archive --format=tar --prefix=bluechi-$VERSION/ --add-file=bluechi.spec -o bluechi-$VERSION.tar HEAD
git archive \
--format=tar \
-o bluechi-$VERSION.tar \
--prefix=bluechi-$VERSION/build-scripts/ \
--add-file=build-scripts/RELEASE \
--prefix=bluechi-$VERSION/ \
--add-file=bluechi.spec \
HEAD
git submodule foreach --recursive \
"git archive --prefix=bluechi-$VERSION/\$path/ --output=\$sha1.tar HEAD && \
tar --concatenate --file=$(pwd)/bluechi-$VERSION.tar \$sha1.tar && rm \$sha1.tar"
Expand Down
13 changes: 12 additions & 1 deletion build-scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ VERSION=0.8.0
IS_RELEASE=false
# Used for official releases. Increment if necessary
RELEASE="1"
# Used to cache generated snapshot release for further usage
RELEASE_FILE=$(dirname "$(readlink -f "$0")")/RELEASE

function short(){
echo ${VERSION}
Expand All @@ -21,9 +23,18 @@ function release(){

if [ $IS_RELEASE = false ]; then
# Used for nightly builds
RELEASE="0.$(date +%04Y%02m%02d%02H%02M).git$(git rev-parse --short ${GITHUB_SHA:-HEAD})"
if [ -f "${RELEASE_FILE}" ]; then
RELEASE="$(cat ${RELEASE_FILE})"
else
RELEASE="0.$(date +%04Y%02m%02d%02H%02M).git$(git rev-parse --short ${GITHUB_SHA:-HEAD})"
echo ${RELEASE} > ${RELEASE_FILE}
fi
fi
echo $RELEASE
}

function clean(){
rm -f "${RELEASE_FILE}"
}

[ -z $1 ] && short || $1

0 comments on commit 2327958

Please sign in to comment.