Skip to content

Commit

Permalink
Merge pull request #7 from Elektrobit/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
gehwolf authored Jul 4, 2024
2 parents 163e8ee + 506acb8 commit bc8d788
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ RUN apt-get update \
clang-tidy \
cmake \
curl \
debhelper \
expat \
gdb \
git \
git-buildpackage \
gnuplot \
jq \
libcmocka-dev \
Expand Down Expand Up @@ -89,7 +91,7 @@ RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/tru
# for llvm 16 packages\n\
deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main\n\
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main\n\
" | sudo tee /etc/apt/sources.list \
" | sudo tee -a /etc/apt/sources.list \
&& sudo apt-get update \
&& sudo apt-get install -y libclang1-16 \
&& sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-16.so.1 /usr/lib/libclang-16.so
Expand Down
106 changes: 106 additions & 0 deletions ci/create_debian_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash -e

function print_help() {
echo "$0 [-r|-p|-a|-h] <x.y.z>"
echo -e "-r\tonly do the debian/main release"
echo -e "-p\tonly do the pristine tar build and update"
echo -e "-a\tdo all (default)"
echo -e "-h\tprint help"
}

function setup_env() {
export GIT_AUTHOR_NAME="Wolfgang Gehrhardt"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export DEBNAME="${GIT_AUTHOR_NAME}"

export EMAIL=${EMAIL-"[email protected]"}
export GIT_AUTHOR_EMAIL="${EMAIL}"
export GIT_COMMITTER_EMAIL="${EMAIL}"
export DEBMAIL="${EMAIL}"

git config --local user.name "${GIT_AUTHOR_NAME}"
git config --local user.email "${GIT_AUTHOR_EMAIL}"
}

function create_and_publish_debian_main() {
gbp import-ref -u "${NEW_VERSION}" --debian-branch "$(git branch --show-current)"

cp debian/changelog debian.native/
cp debian/gbp.conf debian.native/
git rm -rf debian/
cp -arv debian.native debian
rm debian/README.md
echo "3.0 (quilt)" > debian/source/format

dch -M "--newversion=${NEW_VERSION}-1" "New upstream tag ${NEW_VERSION}"
git add debian/ && git commit -m "New upstream tag ${NEW_VERSION}"
git checkout HEAD -- debian.native && git clean -fxd -- debian.native
}

function install_dependencies() {
./ci/install_deps.py

DEP_LIST="cmocka_extensions cmocka_mocks safu"
for dependency in ${DEP_LIST}; do
pushd "build/deps/src/${dependency}"
git checkout debian/main
gbp buildpackage --git-ignore-branch --git-compression=xz -uc -us
case "${dependency}" in
cmocka_mocks)
sudo find ../ -type f -name "libmock-*_*.deb" -exec dpkg -i {} \;
;;
safu)
sudo find ../ -type f -name "libsafu*_*.deb" -exec dpkg -i {} \;
sudo find ../ -type f -name "libmock-safu*_*.deb" -exec dpkg -i {} \;
;;
esac
sudo find ../ -type f -name "*$(echo "${dependency}"| tr '_' '-')*-dev_*.deb" -exec dpkg -i {} \;
popd
done

rm -rf build/
}

function create_and_publish_pristine_tar() {
install_dependencies
sudo gbp buildpackage --git-ignore-branch --git-compression=xz --git-ignore-new -uc -us
}

UPDATE_RELEASE=0
UPDATE_PRISTINE=0
UPDATE_ALL=1

while getopts "raph" opt; do
case $opt in
r) UPDATE_RELEASE=1;;
p) UPDATE_PRISTINE=1;;
a) UPDATE_ALL=1;;
h) print_help; exit 0;;
\?) echo "Invalid option: -$OPTARG"; print_help; exit 1;;
esac
done
NEW_VERSION=${!OPTIND}

if [ -z "$NEW_VERSION" ]; then
echo "Error: Version number is required."
print_help
exit 1
fi

if [ $UPDATE_RELEASE -eq 0 ] && [ $UPDATE_PRISTINE -eq 0 ]; then
UPDATE_ALL=1
else
UPDATE_ALL=0
fi

echo "Create release: ${NEW_VERSION}"

setup_env

if [ $UPDATE_ALL -eq 1 ] || [ $UPDATE_RELEASE -eq 1 ]; then
create_and_publish_debian_main
fi

if [ $UPDATE_ALL -eq 1 ] || [ $UPDATE_PRISTINE -eq 1 ]; then
create_and_publish_pristine_tar
fi
26 changes: 26 additions & 0 deletions ci/updateversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -e
#
# Update all version numbers to given version
#

CMD_PATH=$(cd "$(dirname "$0")" && pwd)
BASE_DIR=${CMD_PATH%/*}
PROJECT_NAME=$(basename $BASE_DIR)

INPUTFILE_CMAKE="$BASE_DIR/cmake/project.cmake"

if [ $# -ne 1 ];
then
echo "Usage: $0 <version>"
exit 1
fi
VERSION=$1

# update version in cmake project file
sed -i "s,^set(SAMCONF_VERSION .*\$,set(SAMCONF_VERSION ${VERSION})," "${INPUTFILE_CMAKE}"

git add -p

git commit -m "elos: Update to ${VERSION}"
echo "New version:"
git show
2 changes: 1 addition & 1 deletion cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
set(SAMCONF_VERSION 0.53.4)
set(SAMCONF_VERSION 0.54.0)

# Attention: Aside from the version, as many things as possible in this file
# should be put into functions, as this solves potential issues with commands
Expand Down
7 changes: 7 additions & 0 deletions debian.native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ belong to.
New packages must be added to the `control` file, and their respective files
should be added to a new `.install` file matching the name of the new package.

## Release

To prepare a new release on `debian/main` run
1. `git checkout -b <task/-new-release> origin/debian/main`
2. `./ci/docker-run.sh ./ci/create_debian_release.sh <x.y.z>`
3. push branch and create MR for **debian/main** , not *main* and not *integration*!

## Packaging Script Maintainer

* Isaac True [email protected] [@IsaacJT](https://github.com/IsaacJT)
2 changes: 1 addition & 1 deletion debian.native/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Upstream-Contact: https://github.com/Elektrobit/samconf/issues
Source: https://github.com/Elektrobit/samconf

Files: *
Copyright: 2023, Elektrobit GmbH
Copyright: 2023, Elektrobit Automotive GmbH
2023, emlix GmbH
License: MIT

Expand Down
2 changes: 2 additions & 0 deletions debian.native/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=4
https://github.com/Elektrobit/samconf/tags .*/samconf-(\d+).(\d+).(\d+).tar.gz

0 comments on commit bc8d788

Please sign in to comment.