Skip to content

Commit 319a0d0

Browse files
committed
ci: upload debian package on release
1 parent d3dfcc5 commit 319a0d0

2 files changed

Lines changed: 67 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ jobs:
4747
git push origin v${{ needs.release-please.outputs.major }}.${{ needs.release-please.outputs.minor }}
4848
4949
release:
50-
name: Build and Release (${{ matrix.os }})
51-
runs-on: ${{ matrix.os }}
50+
name: Build and Release
51+
runs-on: ubuntu-latest
5252
needs: release-please
5353
if: ${{ needs.release-please.outputs.release_created }}
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
os: [ubuntu-latest, macos-13, macos-latest]
5854
steps:
5955
- name: Checkout repository
6056
uses: actions/checkout@v4
@@ -63,32 +59,15 @@ jobs:
6359
uses: ./.github/actions/deps
6460

6561
- name: Build
62+
id: build
6663
shell: bash
6764
run: |
68-
cmake -DCMAKE_BUILD_TYPE=Release -B build
69-
cmake --build build -j
70-
71-
- name: Rename Shared Library
72-
id: rename
73-
shell: bash
74-
run: |
75-
OS_NAME=""
76-
ARCH="$(uname -m)"
77-
78-
if [[ "${{ runner.os }}" == "Linux" ]]; then
79-
OS_NAME="ubuntu_$(lsb_release -rs)"
80-
EXT="so"
81-
else
82-
OS_NAME="macos_$(sw_vers -productVersion | cut -d '.' -f1,2)"
83-
EXT="dylib"
84-
fi
85-
86-
NEW_NAME="libgpac_plugin_${OS_NAME}_${ARCH}.${EXT}"
87-
mv ./build/libgpac_plugin.${EXT} "./build/${NEW_NAME}"
88-
echo "artifact=${NEW_NAME}" >> $GITHUB_OUTPUT
65+
cmake -DPACKAGE=ON -B build
66+
cmake --build build -j --target package
67+
echo "artifact=${ls build/*.deb}" >> $GITHUB_OUTPUT
8968
9069
- name: Upload Release Artifact
9170
shell: bash
9271
env:
9372
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94-
run: gh release upload ${{ needs.release-please.outputs.tag_name }} ./build/${{ steps.rename.outputs.artifact }} --clobber
73+
run: gh release upload ${{ needs.release-please.outputs.tag_name }} ${{ steps.build.outputs.artifact }} --clobber

CMakeLists.txt

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ project(gpac_plugin VERSION 0.2.1 LANGUAGES C) # x-release-please-version
1414

1515
# Options
1616
option(ENABLE_TESTS "Enable and build tests" OFF)
17+
option(PACKAGE "Package the plugin" OFF)
1718

1819
# Set default build type to Release
1920
if(NOT CMAKE_BUILD_TYPE)
@@ -23,6 +24,13 @@ endif()
2324
# Define allowed values for CMAKE_BUILD_TYPE
2425
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release)
2526

27+
# Check if we are packaging
28+
if(PACKAGE)
29+
message(STATUS "Building for packaging ")
30+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g., Debug, Release)" FORCE)
31+
set(ENABLE_TESTS OFF CACHE BOOL "Disable tests for packaging" FORCE)
32+
endif()
33+
2634
# clang-tidy
2735
find_program(CLANG_TIDY NAMES clang-tidy)
2836

@@ -50,7 +58,10 @@ file(GLOB_RECURSE SOURCES
5058
)
5159

5260
add_library(${PROJECT_NAME} SHARED ${SOURCES})
53-
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON)
61+
set_target_properties(${PROJECT_NAME} PROPERTIES
62+
EXPORT_COMPILE_COMMANDS ON
63+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
64+
)
5465
target_compile_options(${PROJECT_NAME} PRIVATE
5566
-Wall -Wextra -Werror
5667
-Wcast-align
@@ -115,3 +126,51 @@ endif()
115126
if(ENABLE_TESTS)
116127
add_subdirectory(tests)
117128
endif()
129+
130+
# Try to get multiarch triple
131+
execute_process(
132+
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
133+
OUTPUT_VARIABLE DEB_MULTIARCH
134+
OUTPUT_STRIP_TRAILING_WHITESPACE
135+
)
136+
137+
# Default to plain /usr/lib if detection fails
138+
if(NOT DEB_MULTIARCH)
139+
set(DEB_MULTIARCH "unknown")
140+
endif()
141+
142+
# Install to GStreamer plugin directory
143+
install(TARGETS ${PROJECT_NAME}
144+
LIBRARY DESTINATION /usr/lib/${DEB_MULTIARCH}/gstreamer-1.0
145+
)
146+
147+
# Package
148+
set(CPACK_GENERATOR "DEB")
149+
set(CPACK_PACKAGE_NAME gst-gpac-plugin
150+
CACHE STRING "The resulting package name"
151+
)
152+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GPAC GStreamer Plugin"
153+
CACHE STRING "A GStreamer plugin for GPAC" FORCE
154+
)
155+
156+
set(CPACK_PACKAGE_VENDOR "GPAC Project")
157+
set(CPACK_VERBATIM_VARIABLES YES)
158+
159+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
160+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
161+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
162+
163+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Deniz Ugur <deniz@gpac.io>")
164+
165+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
166+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
167+
168+
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
169+
170+
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
171+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgstreamer1.0-0, libgstreamer-plugins-base1.0-0")
172+
173+
if(PACKAGE)
174+
message(STATUS "Packaging the plugin")
175+
include(CPack)
176+
endif()

0 commit comments

Comments
 (0)