Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,43 @@ on:
pull_request:

jobs:
determine-version:
name: Determine Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install semantic-release dependencies
run: npm install

- name: Get next version
id: get_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
DRY=$(npx semantic-release --dry-run 2>&1 || true)
VERSION=$(echo "$DRY" | grep -oP '(?<=The next release version is )[0-9]+\.[0-9]+\.[0-9]+' | head -1)
fi
if [ -z "$VERSION" ]; then
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Determined version: $VERSION"

build-linux:
name: Build Linux
needs: [determine-version]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down Expand Up @@ -39,7 +74,7 @@ jobs:
else
BUILD_TYPE="Debug"
fi
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DAPP_VERSION=${{ needs.determine-version.outputs.version }}
make -j$(nproc)

- name: Package with CPack
Expand All @@ -57,6 +92,7 @@ jobs:

build-macos:
name: Build macOS
needs: [determine-version]
runs-on: macos-latest
steps:
- name: Checkout code
Expand All @@ -75,14 +111,14 @@ jobs:
else
BUILD_TYPE="Debug"
fi
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DAPP_VERSION=${{ needs.determine-version.outputs.version }}
make -j$(sysctl -n hw.ncpu)

- name: Create App Bundle
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
chmod +x bundle_macos.sh
BUILD_DIR="build" ./bundle_macos.sh
BUILD_DIR="build" APP_VERSION="${{ needs.determine-version.outputs.version }}" ./bundle_macos.sh

- name: Create DMG
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand All @@ -108,11 +144,15 @@ jobs:

build-windows:
name: Build Windows
needs: [determine-version]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Convert icon to .ico
run: magick "Resources/icon.png" -define icon:auto-resize=256,128,64,48,32,16 "Resources/P2ProViewer.ico"

- name: Initialize vcpkg
shell: pwsh
run: |
Expand All @@ -131,6 +171,7 @@ jobs:
}
cmake -S . -B build `
-DCMAKE_BUILD_TYPE=$build_type `
-DAPP_VERSION="${{ needs.determine-version.outputs.version }}" `
-DUSE_FFMPEG=OFF `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
Expand Down
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ project(P2ProViewer)

set(CMAKE_CXX_STANDARD 17)

if(DEFINED APP_VERSION AND NOT APP_VERSION STREQUAL "")
string(REPLACE "." ";" _ver_list "${APP_VERSION}")
list(GET _ver_list 0 APP_VERSION_MAJOR)
list(GET _ver_list 1 APP_VERSION_MINOR)
list(GET _ver_list 2 APP_VERSION_PATCH)
else()
set(APP_VERSION "0.0.0")
set(APP_VERSION_MAJOR 0)
set(APP_VERSION_MINOR 0)
set(APP_VERSION_PATCH 0)
endif()

if(WIN32 AND NOT DEFINED USE_FFMPEG)
set(USE_FFMPEG OFF CACHE BOOL "Use FFmpeg for video recording")
else()
Expand Down Expand Up @@ -101,6 +113,8 @@ if (APPLE)
set_target_properties(P2ProViewer PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_ICON_FILE P2ProViewer.icns
MACOSX_BUNDLE_SHORT_VERSION_STRING "${APP_VERSION}"
MACOSX_BUNDLE_BUNDLE_VERSION "${APP_VERSION}"
)
set_source_files_properties(Resources/P2ProViewer.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
elseif(WIN32)
Expand All @@ -119,6 +133,13 @@ elseif(WIN32)
list(APPEND WIN32_SOURCES src/VideoRecorder_win.cpp)
endif()

configure_file(
"${CMAKE_SOURCE_DIR}/src/P2ProViewer.rc.in"
"${CMAKE_BINARY_DIR}/P2ProViewer.rc"
@ONLY
)
list(APPEND WIN32_SOURCES "${CMAKE_BINARY_DIR}/P2ProViewer.rc")

add_executable(P2ProViewer ${WIN32_SOURCES})

target_link_libraries(P2ProViewer
Expand Down Expand Up @@ -261,7 +282,7 @@ endif()
set(CPACK_PACKAGE_NAME "P2ProViewer")
set(CPACK_PACKAGE_VENDOR "P2Pro")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Viewer for P2 Pro thermal camera")
set(CPACK_PACKAGE_VERSION "1.0.0") # Will be overridden by semantic-release if needed, but good to have a default
set(CPACK_PACKAGE_VERSION "${APP_VERSION}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "P2Pro Maintainer")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl2-2.0-0, libsdl2-ttf-2.0-0, libusb-1.0-0, libavcodec58 | libavcodec59 | libavcodec60, libavformat58 | libavformat59 | libavformat60, libswscale5 | libswscale6 | libswscale7, libavutil56 | libavutil57 | libavutil58")
set(CPACK_GENERATOR "DEB")
Expand Down
4 changes: 4 additions & 0 deletions bundle_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ cat <<EOF > "$TARGET.app/Contents/Info.plist"
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>${APP_VERSION:-0.0.0}</string>
<key>CFBundleVersion</key>
<string>${APP_VERSION:-0.0.0}</string>
</dict>
</plist>
EOF
Expand Down
30 changes: 30 additions & 0 deletions src/P2ProViewer.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <winver.h>

IDI_APPICON ICON "@CMAKE_SOURCE_DIR@/Resources/P2ProViewer.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION @APP_VERSION_MAJOR@,@APP_VERSION_MINOR@,@APP_VERSION_PATCH@,0
PRODUCTVERSION @APP_VERSION_MAJOR@,@APP_VERSION_MINOR@,@APP_VERSION_PATCH@,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "P2Pro Thermal Camera Viewer\0"
VALUE "FileVersion", "@APP_VERSION@\0"
VALUE "InternalName", "P2ProViewer\0"
VALUE "OriginalFilename", "P2ProViewer.exe\0"
VALUE "ProductName", "P2ProViewer\0"
VALUE "ProductVersion", "@APP_VERSION@\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
Loading