Skip to content

Commit

Permalink
CI job
Browse files Browse the repository at this point in the history
-clang format
-build and publish debug
-build and publish release

Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed Nov 17, 2024
1 parent f0851aa commit 9cc011c
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 2 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/appstream_parser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: appstream-parser

on:
pull_request:
types: [ opened, synchronize, reopened, closed ]
release:
types: [ published, created, edited ]
workflow_dispatch:

jobs:

appstream-parser:

env:
VERSION: 0.0.1

strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04 ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1

- name: Install packages
run: |
sudo apt-get update
sudo apt-get -y install libflatpak-dev libxml2-dev zlib1g-dev flatpak
echo "flatpak list"
flatpak list
- name: Configure Debug
run: |
mkdir -p ${{github.workspace}}/build/debug
cmake ${{github.workspace}} -B ${{github.workspace}}/build/debug
- name: Build Debug
working-directory: ${{github.workspace}}/build/debug
run: |
rm -rf _packages || true
make package -j
ls -la _packages
- name: Configure Release
run: |
mkdir -p ${{github.workspace}}/build/release
cmake ${{github.workspace}} -B ${{github.workspace}}/build/release
- name: Build Release Package
working-directory: ${{github.workspace}}/build/release
run: |
rm -rf _packages || true
make package -j
ls -la _packages
echo "Release Info"
ls -la appstream_parser
echo "Strip executable"
strip appstream_parser
ls -la appstream_parser
echo "List Dependencies"
ldd appstream_parser
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
cmake_minimum_required(VERSION 3.14)
project(appstream_sax)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug, Release, RelWithDebInfo, or MinSizeRel." FORCE)
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.")
endif ()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

project(appstream_parser
VERSION 0.0.1
DESCRIPTION "Appstream Parser"
LANGUAGES CXX
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -24,4 +36,11 @@ FetchContent_Declare(

FetchContent_MakeAvailable(spdlog)

target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog LibXml2::LibXml2)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog LibXml2::LibXml2)

#
# Packaging
#
if (NOT CMAKE_CROSSCOMPILING)
include(packaging)
endif ()
61 changes: 61 additions & 0 deletions cmake/packaging.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright 2020 Toyota Connected North America
# Copyright 2024 Joel Winarske
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set(CPACK_GENERATOR "TGZ;RPM;DEB")

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CPACK_PACKAGE_NAME ${EXE_OUTPUT_NAME}-dbg)
else ()
set(CPACK_PACKAGE_NAME ${EXE_OUTPUT_NAME})
endif ()

set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "${EXE_OUTPUT_NAME} - ${CMAKE_BUILD_TYPE}")
set(CPACK_PACKAGE_VENDOR "Joel Winarske")
set(CPACK_PACKAGE_CONTACT "[email protected]")

set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/_packages")

set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)

set(CPACK_DEB_COMPONENT_INSTALL YES)

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joel Winarske <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS NO)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

set(CPACK_RPM_COMPONENT_INSTALL YES)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}")

set(CPACK_TGZ_FILE_NAME TGZ-DEFAULT)

if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(CPACK_STRIP_FILES ${EXE_OUTPUT_NAME})
endif ()

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
set(CMAKE_RPM_DEBUGINFO_PACKAGE ON)
set(CMAKE_TGZ_DEBUGINFO_PACKAGE ON)
endif ()

include(CPack)

0 comments on commit 9cc011c

Please sign in to comment.