diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..e9102ff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +.github export-ignore +.gitignore export-ignore +.gitattributes export-ignore +.requirements export-ignore +test/mocklib export-ignore diff --git a/.github/workflows/libipcon_main.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/libipcon_main.yml rename to .github/workflows/ci.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a16914 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,183 @@ +name: Release + +on: + push: + branches: + - main + paths: + - 'CMakeLists.txt' + +permissions: + contents: write + +jobs: + check-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.extract.outputs.version }} + should_release: ${{ steps.check.outputs.should_release }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from CMakeLists.txt + id: extract + run: | + VERSION=$(grep -Po 'project\(libipcon\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) + if [ -z "$VERSION" ]; then + echo "Error: Failed to extract version from CMakeLists.txt" + exit 1 + fi + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "Extracted version: ${VERSION}" + + - name: Check if release needed + id: check + run: | + VERSION="${{ steps.extract.outputs.version }}" + if git rev-parse "v${VERSION}" >/dev/null 2>&1; then + echo "Tag v${VERSION} already exists, skipping release" + echo "should_release=false" >> $GITHUB_OUTPUT + else + echo "New version detected: v${VERSION}" + echo "should_release=true" >> $GITHUB_OUTPUT + fi + + create-release: + needs: check-version + if: needs.check-version.outputs.should_release == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + libnl-genl-3-dev \ + cmake \ + build-essential \ + ruby \ + ruby-dev \ + rubygems + sudo gem install --no-document fpm + + - name: Generate changelog + id: changelog + run: | + VERSION="${{ needs.check-version.outputs.version }}" + PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -z "$PREV_TAG" ]; then + echo "First release - generating full changelog" + COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges) + else + echo "Generating changelog from ${PREV_TAG}" + COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) + fi + + cat > changelog.md << EOF + ## Changes + + ${COMMITS} + + ## Installation + + ### Debian/Ubuntu (24.04+) + + **Note:** The Debian package is built for **Ubuntu 24.04 (Noble Numbat) and later versions**. It depends on \`libnl-genl-3-200\` which is available in Ubuntu 24.04+. For older Ubuntu versions (22.04, 20.04), please install from source. + + \`\`\`bash + sudo apt install ./libipcon_${VERSION}_amd64.deb + \`\`\` + + ### From Source + + For all Linux distributions and older Ubuntu versions: + + \`\`\`bash + tar -xzf libipcon-${VERSION}.tar.gz + cd libipcon-${VERSION} + mkdir build && cd build + cmake .. + make + sudo make install + \`\`\` + EOF + + echo "Changelog generated:" + cat changelog.md + + - name: Create source tarball + run: | + VERSION="${{ needs.check-version.outputs.version }}" + git archive --format=tar.gz \ + --prefix=libipcon-${VERSION}/ \ + -o libipcon-${VERSION}.tar.gz \ + HEAD + + echo "Tarball created:" + ls -lh libipcon-${VERSION}.tar.gz + + echo "Verifying tarball contents:" + tar -tzf libipcon-${VERSION}.tar.gz | head -20 + + - name: Build project and create Debian package + run: | + VERSION="${{ needs.check-version.outputs.version }}" + + mkdir build && cd build + cmake -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_VERBOSE_MAKEFILE=1 \ + -DUNIT_TEST=OFF \ + .. + make -j $(nproc) + + if [ ! -f lib/libipcon.so ]; then + echo "Error: Library not built" + exit 1 + fi + + make DESTDIR=$PWD/install install + + echo "Installed files:" + find install -type f + + cd .. + fpm -s dir -t deb \ + -n libipcon \ + -v ${VERSION} \ + -a amd64 \ + --description "LIBIPCON - High-performance IPC over Netlink" \ + --url "https://github.com/saimizi/libipcon" \ + --license "LGPL-2.1" \ + --maintainer "saimizi" \ + --depends "libnl-genl-3-200" \ + --category libs \ + --deb-priority optional \ + -C build/install \ + usr + + echo "Debian package created:" + ls -lh *.deb + + dpkg-deb -c libipcon_${VERSION}_amd64.deb + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION="${{ needs.check-version.outputs.version }}" + + gh release create "v${VERSION}" \ + --title "v${VERSION}" \ + --notes-file changelog.md \ + libipcon-${VERSION}.tar.gz \ + libipcon_${VERSION}_amd64.deb + + echo "Release v${VERSION} created successfully!" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7027094..976791b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(libipcon VERSION 0.0.1) +project(libipcon VERSION 0.1.0) # Enable cmake makefile debug set(CMAKE_VERBOSE_MAKEFILE ON) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 69a7af9..66299b4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -64,3 +64,15 @@ target_link_libraries(ipcon ${LIBNL_GENL_LIBRARIES}) set_target_properties(ipcon PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) target_include_directories(ipcon PUBLIC ${LIBIPCON_INCLUDE_DIR}) + +# Installation rules +install(TARGETS ipcon + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(FILES + libipcon.h + libipcon_priv.h + libipcon_dbg.h + util.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/lib/meson.build b/lib/meson.build deleted file mode 100644 index fa68ea7..0000000 --- a/lib/meson.build +++ /dev/null @@ -1,16 +0,0 @@ - -sources = [ - 'libipcon.c', - 'libipcon_priv.c', - 'util.c', - 'libipcon_dbg.c' -] - -libipcon = library('ipcon', - sources: sources, - install: true, - dependencies: libnl, - include_directories: include_directories('../driver'), - version: '0.0.1', - soversion: '0' - ) diff --git a/logger/meson.build b/logger/meson.build deleted file mode 100644 index 50a8325..0000000 --- a/logger/meson.build +++ /dev/null @@ -1,28 +0,0 @@ -include_dir = include_directories([ - '../lib', - '../driver', - ]) - - - -executable('ipcon_cmd', - sources: 'ipcon_cmd.c', - dependencies: libnl, - include_directories: include_dir, - link_with: libipcon - ) - -executable('ipcon_logger', - sources: 'ipcon_logger.c', - dependencies: libnl, - include_directories: include_dir, - link_with: libipcon, - link_args: ['-lm'] - ) - -executable('ipcon_kevent', - sources: 'ipcon_kevent.c', - dependencies: libnl, - include_directories: include_dir, - link_with: libipcon - ) diff --git a/meson.build b/meson.build deleted file mode 100644 index b5023fa..0000000 --- a/meson.build +++ /dev/null @@ -1,29 +0,0 @@ -project('libipcon', 'c', version: '0.0.1', default_options : ['warning_level=3', 'optimization=2']) - -unit_test = get_option('unit_test') -build_logger = get_option('build_logger') -build_sample = get_option('build_sample') -libnl = dependency('libnl-genl-3.0') - - -if unit_test - add_project_arguments('-DUNIT_TEST', language : 'c') - subdir('lib') - subdir('test') - if build_logger - message('build_logger is ignored when unit_test is enabled') - endif - - if build_sample - message('build_sample is ignored when unit_test is enabled') - endif -else - subdir('lib') - if build_logger - subdir('logger') - endif - - if build_sample - subdir('samples') - endif -endif diff --git a/meson.options b/meson.options deleted file mode 100644 index c3e1fa3..0000000 --- a/meson.options +++ /dev/null @@ -1,5 +0,0 @@ -option('build_logger', type: 'boolean', value: false, description: 'Build ipcon logger',) -option('build_sample', type: 'boolean', value: false, description: 'Build ipcon samples',) -option('unit_test', type: 'boolean', value: false, description: 'Build ipcon unit test',) -option('enable_coverage', type: 'boolean', value: false, description: 'Build coverage in unit test',) -option('enable_nl_mock', type: 'boolean', value: false, description: 'Build coverage with libnl-genl mock',) diff --git a/samples/meson.build b/samples/meson.build deleted file mode 100644 index eb598be..0000000 --- a/samples/meson.build +++ /dev/null @@ -1,38 +0,0 @@ -libjslist = library('jslist', - sources: 'jsutils/jslist/jslist.c', - ) - -include_inc = [ - 'jsutils/jslist/', - '../lib', - '../driver', - '../logger', - ] - -executable('ipcon_server', - sources: 'ipcon_server.c', - include_directories: include_inc, - dependencies: libnl, - link_with: [libipcon,libjslist], - ) - -executable('ipcon_server_poll', - sources: 'ipcon_server_poll.c', - include_directories: include_inc, - dependencies: libnl, - link_with: [libipcon,libjslist], - ) - -executable('ipcon_sender', - sources: 'ipcon_sender.c', - include_directories: include_inc, - dependencies: libnl, - link_with: [libipcon,libjslist], - ) - -executable('ipcon_user', - sources: 'ipcon_user.c', - include_directories: include_inc, - dependencies: libnl, - link_with: [libipcon,libjslist], - ) diff --git a/test/meson.build b/test/meson.build deleted file mode 100644 index 4447a17..0000000 --- a/test/meson.build +++ /dev/null @@ -1,28 +0,0 @@ - -subdir('mocklib') - -enable_coverage = get_option('enable_coverage') - -ut_link_args = ['-lcmocka'] - -if enable_coverage - if meson.get_compiler('c').get_id() == 'gcc' - add_project_arguments(['-fprofile-arcs', '-ftest-coverage'], language : 'c') - ut_link_args += ['-lgcov', '--coverage'] - endif -endif - -ut_sources = [ - 'ut_main.c', - 'ut_ipcon_create_handler.c' - ] - -executable('ut_ipcon', - sources: ut_sources, - link_with: [wrap_symbols_lib, libipcon], - include_directories: ['../lib/', '../driver'], - dependencies: libnl, - link_args: ut_link_args, - ) - -