Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next #7

Merged
merged 6 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -88,7 +90,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
100 changes: 100 additions & 0 deletions ci/create_debian_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/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-"wolfgang.gehrhardt@emlix.com"}
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"
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
if [ "${dependency}" = "cmocka_mocks" ]; then
sudo find ../ -type f -name "libmock-*_*.deb" -exec dpkg -i {} \;
fi
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(SAFU_VERSION .*\$,set(SAFU_VERSION ${VERSION})," "${INPUTFILE_CMAKE}"

git add -p

git commit -m "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(SAFU_VERSION 0.54.1)
set(SAFU_VERSION 0.55.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 isaac.true@emlix.com [@IsaacJT](https://github.com/IsaacJT)