diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27e7cbf6..34b0619f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,70 +3,13 @@ name: Release on: push: tags: - - 'v*' - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release + - "[0-9]+.[0-9]+.[0-9]+" jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-18.04 - + release: + name: Create Release + steps: - - uses: actions/checkout@v2 - - - name: Download libdict - shell: bash - run: wget https://github.com/rtbrick/libdict/releases/download/v1.0.1/libdict-debian.zip - - - name: Install libdict - shell: bash - run: unzip libdict-debian.zip; sudo dpkg -i libdict_1.0.1_amd64.deb; sudo dpkg -i libdict-dev_1.0.1_amd64.deb - - - name: Install dependencies - shell: bash - run: sudo apt install -y libcunit1-dev libncurses5-dev libssl-dev libjansson-dev - - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{github.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{github.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - - - name: Build - working-directory: ${{github.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Test - working-directory: ${{github.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE - - - name: Package - working-directory: ${{github.workspace}}/build - shell: bash - run: | - cpack -G DEB - zip bngblaster-ubuntu1804 *.deb - - name: Create Release id: create_release uses: actions/create-release@v1 @@ -79,13 +22,64 @@ jobs: draft: true # need to manually publish prerelease: false + build: + name: Build Release + needs: [release] + runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-18.04, ubuntu-20.04] + + steps: + - uses: actions/checkout@v2 + + - name: Download RtBrick libdict + shell: bash + run: wget https://github.com/rtbrick/libdict/releases/download/v1.0.1/libdict-debian.zip + + - name: Install RtBrick libdict + shell: bash + run: unzip libdict-debian.zip; sudo dpkg -i libdict_1.0.1_amd64.deb; sudo dpkg -i libdict-dev_1.0.1_amd64.deb + + - name: Install Dependencies + shell: bash + run: sudo apt install -y libcunit1-dev libncurses5-dev libssl-dev libjansson-dev libcmocka-dev libpcap-dev + + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + shell: bash + working-directory: ${{github.workspace}}/build + run: cmake $GITHUB_WORKSPACE -DBNGBLASTER_VERSION=${{ github.ref }} -DBNGBLASTER_TESTS=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{github.workspace}}/build + shell: bash + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{github.workspace}}/build + shell: bash + run: ctest -C $BUILD_TYPE + + - name: Package + working-directory: ${{github.workspace}}/build + shell: bash + run: cpack -G DEB + + - name: Get Release + uses: pdamianik/release-tag-to-upload-url-action@v1.0.1 + with: + tag: ${{ github.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Debian Package id: upload-release-asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: build/bngblaster-ubuntu1804.zip - asset_name: bngblaster-ubuntu1804.zip - asset_content_type: application/zip \ No newline at end of file + upload_url: ${{ steps.get_release.outputs.uploadUrl }} + asset_path: build/bngblaster_${{ github.ref }}_amd64.deb + asset_name: bngblaster-${{matrix.os}-${{ github.ref }}_amd64.deb diff --git a/CMakeLists.txt b/CMakeLists.txt index faa6405c..b8329954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,16 +3,13 @@ # For Debug Build Try below command #cmake -DCMAKE_BUILD_TYPE=Debug . cmake_minimum_required (VERSION 3.0) -project(bngblaster LANGUAGES C VERSION 0.3.0) +project(bngblaster LANGUAGES C VERSION 0.0.0) + +option(BNGBLASTER_TESTS "Build unit tests (requires cmocka)" OFF) configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h") -option(BNGBLASTER_TESTS "Built unit tests (requires cmocka)" OFF) - -set(GIT_REF "") -set(GIT_SHA "") - if (CMAKE_BUILD_TYPE STREQUAL "Debug") message("Debug Build") set(CMAKE_BUILD_TYPE Debug) @@ -46,6 +43,10 @@ set(CPACK_DEBIAN_LIB_PACKAGE_DEPENDS "libssl1.1, libncurses5, libjansson4") set(CPACK_DEBIAN_LIB_PACKAGE_NAME "bngblaster") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_PACKAGE_CONTACT "RtBrick ") -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/rtbrick/bngblaster") +if (NOT DEFINED BNGBLASTER_VERSION) + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +else() + set(CPACK_PACKAGE_VERSION ${BNGBLASTER_VERSION}) +endif() include(CPack) \ No newline at end of file diff --git a/src/bbl.c b/src/bbl.c index 0770a114..ef6a525c 100644 --- a/src/bbl.c +++ b/src/bbl.c @@ -521,9 +521,11 @@ bbl_print_usage_arg (struct option *option) void bbl_print_version (void) { - printf("Version: %s\n", PROJECT_VER); + if(strlen(BNGBLASTER_VERSION)) { + printf("Version: %s\n", BNGBLASTER_VERSION); + } if(strlen(GIT_REF) + strlen(GIT_SHA)) { - printf("\nGIT:\n"); + printf("GIT:\n"); printf(" REF: %s\n", GIT_REF); printf(" SHA: %s\n", GIT_SHA); } diff --git a/src/config.h b/src/config.h index 8b69aeae..4d2a3aee 100644 --- a/src/config.h +++ b/src/config.h @@ -6,8 +6,9 @@ #define PROJECT_VER "0.0.0" #define PROJECT_VER_MAJOR "0" #define PROJECT_VER_MINOR "0" -#define PTOJECT_VER_PATCH "0" +#define PROJECT_VER_PATCH "0" +#define BNGBLASTER_VERSION "" #define GIT_REF "" #define GIT_SHA "" diff --git a/src/config.h.in b/src/config.h.in index 284b1c12..a59452f6 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -6,8 +6,9 @@ #define PROJECT_VER "@PROJECT_VERSION@" #define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" #define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" -#define PTOJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" +#define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" +#define BNGBLASTER_VERSION "@BNGBLASTER_VERSION@" #define GIT_REF "@GIT_REF@" #define GIT_SHA "@GIT_SHA@"