Skip to content

Commit ca9c19d

Browse files
authored
Merge pull request #480 from opensensor/perf/native-arm-release-builds
Speed up ARM production release builds
2 parents 34b084c + df8ac18 commit ca9c19d

12 files changed

Lines changed: 275 additions & 84 deletions

‎.dockerignore‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Release workflows inject github.sha through the GIT_COMMIT build argument.
2+
.git
3+
.github
4+
.devcontainer
5+
6+
build
7+
build-*
8+
cmake-build-*
9+
**/CMakeFiles
10+
**/CMakeCache.txt
11+
**/cmake_install.cmake
12+
13+
**/node_modules
14+
web/dist
15+
playwright-report
16+
test-results
17+
18+
*.deb
19+
*.docx
20+
homeassistant

‎.github/workflows/container-scan.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
push: false
3535
load: true
3636
tags: lightnvr:scan
37+
build-args: |
38+
GIT_COMMIT=${{ github.sha }}
3739
3840
- name: Install Trivy
3941
run: |
@@ -77,4 +79,3 @@ jobs:
7779
name: trivy-scan-results
7880
path: trivy-results.sarif
7981
retention-days: 30
80-

‎.github/workflows/debian-package.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
build-args: |
7777
DEBIAN_SUITE=${{ matrix.debian_suite }}
7878
DEB_BUILD=true
79+
GIT_COMMIT=${{ github.sha }}
7980
8081
- name: Extract files and create .deb package
8182
run: |
@@ -333,4 +334,3 @@ jobs:
333334
fail_on_unmatched_files: true
334335
env:
335336
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
336-

‎.github/workflows/docker-publish.yml‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ env:
1818

1919
jobs:
2020
build:
21-
runs-on: ubuntu-latest
21+
runs-on: ${{ matrix.runner }}
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
platform:
26-
- linux/amd64
27-
- linux/arm64
28-
- linux/arm/v7
25+
include:
26+
- platform: linux/amd64
27+
runner: ubuntu-latest
28+
emulated: false
29+
- platform: linux/arm64
30+
runner: ubuntu-24.04-arm
31+
emulated: false
32+
- platform: linux/arm/v7
33+
runner: ubuntu-latest
34+
emulated: true
2935

3036
steps:
3137
- name: Checkout
@@ -61,6 +67,7 @@ jobs:
6167
password: ${{ secrets.GITHUB_TOKEN }}
6268

6369
- name: Set up QEMU
70+
if: matrix.emulated
6471
uses: docker/setup-qemu-action@v4
6572

6673
- name: Set up Buildx
@@ -75,6 +82,10 @@ jobs:
7582
platforms: ${{ matrix.platform }}
7683
pull: true
7784
labels: ${{ steps.meta.outputs.labels }}
85+
build-args: |
86+
GIT_COMMIT=${{ github.sha }}
87+
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
88+
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max
7889
outputs: type=image,push-by-digest=true,name=${{ env.REGISTRY_IMAGE }},name-canonical=true,push=true
7990

8091
- name: Save digest
@@ -161,4 +172,3 @@ jobs:
161172
- name: Inspect final image
162173
run: |
163174
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
164-

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CMakeFiles/
4848
cmake_install.cmake
4949
Makefile
5050
*.cmake
51+
!cmake/toolchains/*.cmake
5152
!CMakeLists.txt
5253

5354
# IDE files

‎CMakeLists.txt‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,27 @@ endif()
728728
729729
# Obtain git short commit hash for version stamping
730730
set(GIT_COMMIT "unknown")
731-
find_package(Git QUIET)
732-
if(GIT_FOUND)
733-
execute_process(
734-
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
735-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
736-
OUTPUT_VARIABLE GIT_COMMIT
737-
OUTPUT_STRIP_TRAILING_WHITESPACE
738-
ERROR_QUIET
739-
)
731+
if(DEFINED ENV{LIGHTNVR_GIT_COMMIT} AND NOT "$ENV{LIGHTNVR_GIT_COMMIT}" STREQUAL "")
732+
set(GIT_COMMIT_INPUT "$ENV{LIGHTNVR_GIT_COMMIT}")
733+
string(LENGTH "${GIT_COMMIT_INPUT}" GIT_COMMIT_LENGTH)
734+
if(NOT GIT_COMMIT_INPUT MATCHES "^[0-9a-fA-F]+$" OR
735+
GIT_COMMIT_LENGTH LESS 7 OR GIT_COMMIT_LENGTH GREATER 40)
736+
message(FATAL_ERROR
737+
"Invalid LIGHTNVR_GIT_COMMIT: expected a 7-40 character hexadecimal commit")
738+
endif()
739+
string(SUBSTRING "${GIT_COMMIT_INPUT}" 0 7 GIT_COMMIT)
740+
string(TOLOWER "${GIT_COMMIT}" GIT_COMMIT)
741+
else()
742+
find_package(Git QUIET)
743+
if(GIT_FOUND)
744+
execute_process(
745+
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
746+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
747+
OUTPUT_VARIABLE GIT_COMMIT
748+
OUTPUT_STRIP_TRAILING_WHITESPACE
749+
ERROR_QUIET
750+
)
751+
endif()
740752
endif()
741753
742754
# Build date in ISO-8601

0 commit comments

Comments
 (0)