Skip to content

Commit

Permalink
Merge pull request #77 from Jinxto/feature/1.1.1
Browse files Browse the repository at this point in the history
Automated debian packaging and release
  • Loading branch information
rozukke authored Aug 29, 2024
2 parents 4a369b8 + 8397440 commit 4de79f6
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 9 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: package-release

on:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- "Doxyfile"
- "doxygen-awesome"

pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- "Doxyfile"
- "doxygen-awesome"

release:
types: [published]

jobs:
check_commit_message:
outputs:
commit_message: ${{ steps.capture_message.outputs.message }}
name: Check if workflow disabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Capturing commit message
id: capture_message
run: |
echo "message=$(git log --format=%B -n 1 ${{ github.event.after }})" >> $GITHUB_OUTPUT
linux:
strategy:
fail-fast: false
matrix:
build-type: [Release]
distro: [stable]
needs: check_commit_message
if: ${{ contains(needs.check_commit_message.outputs.commit_message, 'RELEASE') }}
name: Debian-release ${{ matrix.distro }}
runs-on: ubuntu-latest
container: debian:${{ matrix.distro }}
steps:
- name: Setting up git
run: |
apt-get update
apt-get install -y git
- name: Add Safe Directory for Git
run: |
git config --global --add safe.directory /__w/mcpp/mcpp
- name: Getting version
id: get_version
shell: bash
run: |
VERSION=$(echo $GITHUB_REF_NAME | cut -d - -f 2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Checking out sources
uses: actions/checkout@v4

- name: Install build dependencies
run: |
apt-get install -y build-essential ninja-build qtbase5-dev qttools5-dev cmake pkgconf bash libspdlog-dev
- name: Configure build
run: |
mkdir build
cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DPROJECT_VERSION=${{ steps.get_version.outputs.VERSION }}
echo "VERSION=${{ steps.get_version.outputs.VERSION }}"
- name: Build
run: |
cd build
cmake --build . --target package --parallel $(nproc)
- name: Get package name
shell: bash
id: get_package
run: |
NAME=$(basename build/mcpp-*.deb)
echo "NAME=$NAME" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mcpp-${{ steps.get_version.outputs.VERSION }}-debian-${{ matrix.distro }}-${{ matrix.build-type }}.deb
path: build/${{ steps.get_package.outputs.NAME }}

- name: Create tag
run: |
git tag release-${{ steps.get_version.outputs.VERSION }}
git push origin release-${{ steps.get_version.outputs.VERSION }} --force
- name: Upload package to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/${{ steps.get_package.outputs.NAME }}
asset_name: mcpp-${{ steps.get_version.outputs.VERSION }}-debian-${{ matrix.distro }}-${{ matrix.build-type }}.deb
tag: release-${{ steps.get_version.outputs.VERSION }}
overwrite: true

- name: Debug GitHub Ref
run: |
echo "GitHub Ref: ${{ github.ref }}"
echo "GitHub Ref Name: ${{ github.ref_name }}"
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.16)

project(mcpp)
# Check if PROJECT_VERSION is already defined, otherwise set a default
if(NOT DEFINED PROJECT_VERSION)
set(PROJECT_VERSION 1.0.0)
endif()

project(mcpp VERSION ${PROJECT_VERSION})

set(CMAKE_CXX_STANDARD 17)

Expand Down Expand Up @@ -29,14 +34,19 @@ file(GLOB_RECURSE MCPP_SOURCE_FILES ${MCPP_SRC_DIR}/*.cpp)
add_library(${PROJECT_NAME} SHARED ${MCPP_INCLUDE_FILES} ${MCPP_SOURCE_FILES})

set_target_properties(${PROJECT_NAME}
PROPERTIES
PUBLIC_HEADER "${MCPP_INCLUDE_FILES}"
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "${MCPP_INCLUDE_FILES}"
)

install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME}
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME}
)



# CPack setup
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "rozukke")
INCLUDE(CPack)
4 changes: 2 additions & 2 deletions include/mcpp/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class SocketConnection {

/**
* Takes in parameters supporting std::stringstream conversion and a string
* prefix and transforms them into format "prefix(arg1,arg2,arg3)\n" (e.g.
* "chat.post(test)\n") and sends command to the server.
* prefix and transforms them into format "prefix(arg1,arg2,arg3)\n" e.g.
* "chat.post(test)\n)" and sends command to the server.
*
* @tparam Types
* @param prefix
Expand Down

0 comments on commit 4de79f6

Please sign in to comment.