Skip to content

Commit

Permalink
Build Linux releases via Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed Dec 8, 2023
1 parent f3e4c1a commit 89ce5aa
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 11 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Linux packages

on:
workflow_dispatch:
push:
tags:
- '*'
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: "linux/amd64"
name: "amd64"
- platform: "linux/arm64"
name: "aarch64"
- platform: "linux/arm/v7"
name: "armhf"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Compile
run: |
docker buildx build \
-f Dockerfile \
--platform ${{ matrix.platform }} \
-o ${{ github.workspace }}/build \
.
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: gcfflasher-${{ matrix.name }}
# path: build/src/*.deb

- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: ${{ github.ref_name }}
file: build/src/*_linux_*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
33 changes: 22 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
cmake_minimum_required (VERSION 3.5)
project (GCFFlasher VERSION 4.3.0)

add_executable(${PROJECT_NAME})
target_compile_definitions(${PROJECT_NAME}
PUBLIC
APP_VERSION="\"\"${PROJECT_VERSION}-beta\"\"")

option(USE_FTD2XX "Use FTDI ftd2xx library on Windows" ON)

set(COMMON_SRCS
gcf.c
buffer_helper.c
Expand All @@ -18,8 +11,15 @@ set(COMMON_SRCS
u_mem.c
)

add_executable(${PROJECT_NAME} ${COMMON_SRCS})
target_compile_definitions(${PROJECT_NAME}
PUBLIC
APP_VERSION="\"\"${PROJECT_VERSION}-beta\"\"")

option(USE_FTD2XX "Use FTDI ftd2xx library on Windows" ON)

if (UNIX)
target_sources(${PROJECT_NAME} PRIVATE ${COMMON_SRCS} main_posix.c)
target_sources(${PROJECT_NAME} PRIVATE main_posix.c)

#----------------------------------------------------------------------
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
Expand Down Expand Up @@ -49,7 +49,7 @@ endif()

#----------------------------------------------------------------------
if (WIN32)
target_sources(${PROJECT_NAME} PRIVATE ${COMMON_SRCS} main_windows.c)
target_sources(${PROJECT_NAME} PRIVATE main_windows.c)

if (MSVC)
target_link_options(${PROJECT_NAME} PUBLIC "/NODEFAULTLIB:libcmt")
Expand Down Expand Up @@ -93,12 +93,23 @@ install(TARGETS ${PROJECT_NAME}
# Debian .deb specifics
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Manuel Pietschmann <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SECTION "non-free / misc")
set(CPACK_DEBIAN_PACKAGE_)

# keep arch names as used in the past
set(PKG_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if (${PKG_ARCH} MATCHES "aarch64")
set(PKG_ARCH "arm64")
endif()
if (${PKG_ARCH} MATCHES "armv7l")
set(PKG_ARCH "armhf")
endif()
if (${PKG_ARCH} MATCHES "x86_64")
set(PKG_ARCH "amd64")
endif()

string(TOLOWER "${CMAKE_SYSTEM_NAME}" LOWERCASE_SYSTEM_NAME)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/dresden-elektronik/gcfflasher")
set(CPACK_PACKAGE_DESCRIPTION "Tool to flash firmware of RaspBee and ConBee.")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}_${LOWERCASE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_PACKAGE_FILE_NAME "gcfflasher_${PROJECT_VERSION}_${LOWERCASE_SYSTEM_NAME}_${PKG_ARCH}")

include(CPack)
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ubuntu:18.04 as builder

RUN apt-get update && \
apt-get install --no-install-recommends -y \
lsb-release \
ca-certificates \
build-essential \
pkg-config \
libgpiod-dev \
dpkg-dev \
fakeroot \
cmake

WORKDIR /src

COPY . /src/gcfflasher/

RUN mkdir /src/build && cd /src/build \
&& cmake -DCMAKE_BUILD_TYPE=Release ../gcfflasher \
&& cmake --build . \
&& cpack -G "DEB;TGZ" .

FROM scratch
WORKDIR /src
COPY --from=builder /src/build ./

0 comments on commit 89ce5aa

Please sign in to comment.