Skip to content

Commit

Permalink
multiplatform test
Browse files Browse the repository at this point in the history
  • Loading branch information
josevcm committed Jan 27, 2025
1 parent 9e987f6 commit b3c6488
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 2 deletions.
185 changes: 185 additions & 0 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: CMake for Ubuntu platform

on:
push:
tags:
- '*' # any tag
branches:
- develop

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
build_type: [ Release ]

steps:

#
# Common steps
#
- name: 'Check out code'
uses: actions/checkout@v4

#
# Ubuntu steps
#
- name: 'Set reusable strings (Ubuntu)'
id: strings
if: runner.os == 'Linux'
shell: bash
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "build-version=${{ github.ref_name == 'master' && '0.0.0' || github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "cpu-count=$(nproc)" >> "$GITHUB_OUTPUT"
- name: 'Install dependencies (Ubuntu)'
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y build-essential debhelper-compat cmake qt6-base-dev libusb-1.0-0-dev zlib1g-dev libgl1-mesa-dev libairspy-dev librtlsdr-dev
- name: 'Build project (Ubuntu)'
if: runner.os == 'Linux'
run: |
dpkg-buildpackage -us -uc -j${{ steps.strings.outputs.cpu-count }}
#
# Window steps
#
- name: 'Set reusable strings (Windows)'
id: strings
if: runner.os == 'Windows'
shell: bash
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "build-version=${{ github.ref_name == 'master' && '0.0.0' || github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "build-name=${{ github.ref_name == 'master' && 'latest' || github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "qt-dir=${{ github.workspace }}/qt/6.7.2/mingw_64" >> "$GITHUB_OUTPUT"
echo "ninja-dir=${{ github.workspace }}/tools/ninja" >> "$GITHUB_OUTPUT"
echo "cmake-dir=${{ github.workspace }}/tools/cmake_64" >> "$GITHUB_OUTPUT"
echo "mingw-dir=${{ github.workspace }}/tools/mingw1310_64" >> "$GITHUB_OUTPUT"
echo "installer-dir=${{ github.workspace }}/tools/QtInstallerFramework/4.7" >> "$GITHUB_OUTPUT"
echo "package-dir=${{ github.workspace }}/build/installer/package" >> "$GITHUB_OUTPUT"
echo "package-data-dir=${{ github.workspace }}/build/installer/package/org.josevcm.nfc-lab/data" >> "$GITHUB_OUTPUT"
echo "package-meta-dir=${{ github.workspace }}/build/installer/package/org.josevcm.nfc-lab/meta" >> "$GITHUB_OUTPUT"
echo "cpu-count=4" >> "$GITHUB_OUTPUT"
- name: 'Cache dependencies (Windows)'
id: cache-dependencies
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
key: ${{ runner.os }}-qt-dependencies
path: |
${{ github.workspace }}/qt
${{ github.workspace }}/tools
- name: 'Install dependencies (Windows)'
if: runner.os == 'Windows' && steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
choco install aqt -y --no-progress -r
aqt install-qt windows desktop 6.7.2 win64_mingw --outputdir ${{ github.workspace }}/qt
aqt install-tool windows desktop tools_mingw1310 qt.tools.win64_mingw1310 --outputdir ${{ github.workspace }}
aqt install-tool windows desktop tools_cmake qt.tools.cmake --outputdir ${{ github.workspace }}
aqt install-tool windows desktop tools_ninja qt.tools.ninja --outputdir ${{ github.workspace }}
aqt install-tool windows desktop tools_ifw qt.tools.ifw.47 --outputdir ${{ github.workspace }}
- name: 'Configure project (Windows)'
if: runner.os == 'Windows'
run: |
${{ steps.strings.outputs.cmake-dir }}/bin/cmake `
-S ${{ github.workspace }} `
-B ${{ steps.strings.outputs.build-dir }} `
-G Ninja `
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-DCMAKE_PREFIX_PATH=${{ steps.strings.outputs.qt-dir }} `
-DCMAKE_C_COMPILER=${{ steps.strings.outputs.mingw-dir }}/bin/gcc.exe `
-DCMAKE_CXX_COMPILER=${{ steps.strings.outputs.mingw-dir }}/bin/g++.exe `
-DCMAKE_MAKE_PROGRAM=${{ steps.strings.outputs.ninja-dir }}/ninja.exe `
-DBUILD_PROJECT_VERSION="${{ steps.strings.outputs.build-version }}"
- name: 'Build project (Windows)'
if: runner.os == 'Windows'
run: |
${{ steps.strings.outputs.cmake-dir }}/bin/cmake `
--build ${{ steps.strings.outputs.build-dir }} `
--target nfc-lab --parallel ${{ steps.strings.outputs.cpu-count }}
- name: 'Create installer (Windows)'
if: runner.os == 'Windows'
run: |
# create installer folders
New-Item -Force -ItemType "directory" -Path ${{ steps.strings.outputs.package-data-dir }}
New-Item -Force -ItemType "directory" -Path ${{ steps.strings.outputs.package-meta-dir }}
# copy executable and libraries
Copy-Item -Force ${{ steps.strings.outputs.build-dir }}/src/nfc-app/app-qt/nfc-lab.exe ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force ${{ steps.strings.outputs.mingw-dir }}/bin/*.dll ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force ${{ github.workspace }}/dll/airspy/x86_64/bin/*.dll ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force ${{ github.workspace }}/dll/openssl/x86_64/bin/*.dll ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force ${{ github.workspace }}/dll/rtlsdr/x86_64/bin/*.dll ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force ${{ github.workspace }}/dll/usb/x86_64/bin/*.dll ${{ steps.strings.outputs.package-data-dir }}
# copy drivers and firmware
Copy-Item -Force -Recurse ${{ github.workspace }}/dat/config ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force -Recurse ${{ github.workspace }}/dat/drivers ${{ steps.strings.outputs.package-data-dir }}
Copy-Item -Force -Recurse ${{ github.workspace }}/dat/firmware ${{ steps.strings.outputs.package-data-dir }}
# copy installer resources
Copy-Item -Force ${{ steps.strings.outputs.build-dir }}/installer/config/*.* ${{ steps.strings.outputs.package-meta-dir }}
# create deployment
${{ steps.strings.outputs.qt-dir }}/bin/windeployqt `
--verbose 1 `
--compiler-runtime `
--no-translations `
--no-system-d3d-compiler `
--no-opengl-sw `
${{ steps.strings.outputs.package-data-dir }}/nfc-lab.exe
# create installer
${{ steps.strings.outputs.installer-dir }}/bin/binarycreator `
--verbose `
-c ${{ steps.strings.outputs.build-dir }}/installer/config/config.xml `
-p ${{ steps.strings.outputs.package-dir }} `
${{ steps.strings.outputs.build-dir }}/nfc-lab-${{ steps.strings.outputs.build-name }}-installer-x86_64.exe
- name: 'Upload artifact (Windows)'
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: nfc-lab-${{ steps.strings.outputs.build-name }}-installer-x86_64.exe
path: ${{ steps.strings.outputs.build-dir }}/nfc-lab-${{ steps.strings.outputs.build-name }}-installer-x86_64.exe

#
# Final steps
#
- name: 'Create release'
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
id: create-release
with:
draft: false
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
body: |
This is the release for version ${{ github.ref }}.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Upload release (Windows)'
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_name: nfc-lab-${{ steps.strings.outputs.build-name }}-installer-x86_64.exe
asset_path: ${{ steps.strings.outputs.build-dir }}/nfc-lab-${{ steps.strings.outputs.build-name }}-installer-x86_64.exe
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/cmake-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
tags:
- '*' # any tag
branches:
- develop
# branches:
# - master

jobs:
build:
Expand Down

0 comments on commit b3c6488

Please sign in to comment.