Skip to content

Commit

Permalink
Add Sentry support to new CPack packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferroin committed May 9, 2024
1 parent cd7bb3e commit b6527c6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ jobs:
if: needs.file-check.outputs.run == 'true'
shell: bash
run: |
docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 -e VERSION=${{ needs.version-check.outputs.version }} \
docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 \
-e ENABLE_SENTRY=${{ matrix.bundle_sentry }} -e RELEASE_PIPELINE=${{ env.RELEASE_PIPELINE }} \
-e BUILD_DESTINATION=${{ matrix.distro }}${{ matrix.version }}_${{ matrix.arch }} -e UPLOAD_SENTRY=${{ env.UPLOAD_SENTRY }} \
-e SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_CLI_TOKEN }} -e NETDATA_SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
Expand All @@ -273,9 +273,8 @@ jobs:
shell: bash
run: |
docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 -e DISTRO=${{ matrix.distro }} \
-e VERSION=${{ needs.version-check.outputs.version }} -e DISTRO_VERSION=${{ matrix.version }} \
--platform=${{ matrix.platform }} -v "$PWD":/netdata ${{ matrix.base_image }} \
/netdata/.github/scripts/pkg-test.sh
-e DISTRO_VERSION=${{ matrix.version }} --platform=${{ matrix.platform }} -v "$PWD":/netdata \
${{ matrix.base_image }} /netdata/.github/scripts/pkg-test.sh
- name: Upload to PackageCloud
id: upload
if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true'
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ endif()

set(NETDATA_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}.${FIELD_TWEAK})

if(FIELD_DESCR STREQUAL "N/A")
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH})
else()
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}-${FIELD_TWEAK}-${FIELD_DESCR})
endif()

#
# project
#
Expand Down
23 changes: 23 additions & 0 deletions packaging/build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,31 @@ case "${PKG_TYPE}" in
*) echo "Unrecognized package type ${PKG_TYPE}." ; exit 1 ;;
esac

if [ "${ENABLE_SENTRY}" = "true" ]; then
if [ -z "${SENTRY_DSN}" ]; then
echo "ERROR: Sentry enabled but no DSN specified, exiting."
exit 1
fi

add_cmake_option ENABLE_SENTRY On
add_cmake_option NETDATA_SENTRY_ENVIRONMENT "${RELEASE_PIPELINE:-Unknown}"
add_cmake_option NETDATA_SENTRY_DIST "${BUILD_DESTINATION:-Unknown}"
add_cmake_option NETDATA_SENTRY_DSN "${SENTRY_DSN}"

if [ -n "${VERSION}" ]; then
add_cmake_option NETDATA_SENTRY_RELEASE "${VERSION}"
fi
else
add_cmake_option ENABLE_SENTRY Off
fi

# shellcheck disable=SC2086
cmake ${CMAKE_ARGS}
cmake --build "${BUILD_DIR}" --parallel "$(nproc)"

if [ "${ENABLE_SENTRY}" = "true" ] && [ "${UPLOAD_SENTRY}" = "true" ]; then
sentry-cli debug-files upload -o netdata-inc -p netdata-agent --force-foreground --log-level=debug --wait --include-sources build/netdata
fi

cd "${BUILD_DIR}" || exit 1
cpack -V -G "${PKG_TYPE}"
4 changes: 4 additions & 0 deletions packaging/cmake/Modules/NetdataSentry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function(netdata_bundle_sentry)
set(SENTRY_BACKEND "breakpad")
set(SENTRY_BUILD_SHARED_LIBS OFF)

if(NOT DEFINED NETDATA_SENTRY_RELEASE)
set(NETDATA_SENTRY_RELEASE "${CPACK_PACKAGE_VERSION}")
endif()

FetchContent_Declare(
sentry
GIT_REPOSITORY https://github.com/getsentry/sentry-native.git
Expand Down
6 changes: 0 additions & 6 deletions packaging/cmake/Modules/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ set(CPACK_DEBIAN_DEBUGINFO_PACKAGE NO)

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)

if(FIELD_DESCR STREQUAL "N/A")
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH})
else()
set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}-${FIELD_TWEAK}-${FIELD_DESCR})
endif()

set(CPACK_PACKAGING_INSTALL_PREFIX "/")

set(CPACK_PACKAGE_VENDOR "Netdata Inc.")
Expand Down

0 comments on commit b6527c6

Please sign in to comment.