Build Software #181
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------ | |
# USB EPROM/Flash Programmer | |
# | |
# Copyright (2022) Robson Martins | |
# | |
# This work is licensed under a Creative Commons Attribution-NonCommercial- | |
# ShareAlike 4.0 International License. | |
# ------------------------------------------------------------------------------ | |
name: Build Software | |
on: | |
workflow_dispatch: | |
env: | |
BUILD_TYPE: Release | |
SOFTWARE_PROJECT_DIR: ${{github.workspace}}/software/usbflashprog | |
jobs: | |
build_software: | |
name: Build Software (Linux, Windows, MacOS) | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
arch: [x86_64, x86] | |
runs-on: ${{matrix.os}} | |
continue-on-error: true | |
steps: | |
# ------------------------------------------------------------------------ | |
# Checkout the sources | |
# ------------------------------------------------------------------------ | |
- name: Checkout the Sources | |
uses: actions/checkout@v3 | |
# ------------------------------------------------------------------------ | |
# Install MinGW (Windows) | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | |
name: Install MinGW64 (Windows 64-bits) | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: mingw64 | |
install: | |
mingw-w64-x86_64-toolchain | |
mingw-w64-x86_64-cmake | |
release: false | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86' | |
name: Install MinGW32 (Windows 32-bits) | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: mingw32 | |
install: | |
mingw-w64-i686-toolchain | |
mingw-w64-i686-cmake | |
release: false | |
# ------------------------------------------------------------------------ | |
# Install Inno Setup (Windows) | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' | |
name: Install Inno Setup (Windows) | |
env: | |
INNO_SETUP_DOWNLOAD_URL: "https://files.jrsoftware.org/is/6/innosetup-6.2.1.exe" | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}}/scripts | |
run: | | |
wget "${{env.INNO_SETUP_DOWNLOAD_URL}}" | |
./innosetup-6.2.1.exe //VERYSILENT //SUPPRESSMSGBOXES //SP //CURRENTUSER //LANG=en //NORESTART //NOICONS //DIR=".\is" | |
shell: msys2 {0} | |
# ------------------------------------------------------------------------ | |
# Install Qt (Windows/MacOS) | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | |
name: Cache Qt (Windows 64-bits) | |
id: cache-qt-win64 | |
uses: actions/cache@v3 | |
with: | |
path: ../QtCacheWin64 | |
key: ${{ runner.os }}-QtCacheWin64 | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | |
name: Install Qt (Windows 64-bits) | |
uses: jurplel/install-qt-action@v3 | |
with: | |
cache: 'true' | |
cache-key-prefix: ${{ steps.cache-qt-win64.outputs.cache-hit }} | |
version: '5.15.2' | |
host: 'windows' | |
target: 'desktop' | |
arch: 'win64_mingw81' | |
dir: '${{env.SOFTWARE_PROJECT_DIR}}/qt/' | |
install-deps: 'true' | |
extra: '--timeout 30' | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86' | |
name: Cache Qt (Windows 32-bits) | |
id: cache-qt-win32 | |
uses: actions/cache@v3 | |
with: | |
path: ../QtCacheWin32 | |
key: ${{ runner.os }}-QtCacheWin32 | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86' | |
name: Install Qt (Windows 32-bits) | |
uses: jurplel/install-qt-action@v3 | |
with: | |
cache: 'true' | |
cache-key-prefix: ${{ steps.cache-qt-win32.outputs.cache-hit }} | |
version: '5.15.2' | |
host: 'windows' | |
target: 'desktop' | |
arch: 'win32_mingw81' | |
dir: '${{env.SOFTWARE_PROJECT_DIR}}/qt/' | |
install-deps: 'true' | |
extra: '--timeout 30' | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'macos-latest' && matrix.arch == 'x86_64' | |
name: Install Qt (MacOS) | |
run: | | |
brew install qt5 | |
echo "Qt5_Dir=$(brew --prefix qt5)/lib/cmake/Qt5" >> $GITHUB_ENV | |
# ------------------------------------------------------------------------ | |
# Install Prerequisites (Linux) | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Install Prerequisites (Linux 64-bits) | |
run: | | |
sudo apt-get update | |
sudo apt-get install cmake build-essential libglu1-mesa-dev libpulse-dev libglib2.0-dev rpm sed | |
sudo apt-get --no-install-recommends install libqt*5-dev qt*5-dev libqt5waylandcompositor5-dev | |
# ------------------------------------------------------------------------ | |
# Configure CMake | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' | |
name: Configure CMake (Windows) | |
env: | |
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}} | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: cmake -G "MinGW Makefiles" -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
shell: msys2 {0} | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Configure CMake (Linux) | |
env: | |
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}} | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
- if: matrix.os == 'macos-latest' && matrix.arch == 'x86_64' | |
name: Configure CMake (MacOS) | |
env: | |
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}} | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: cmake -G Xcode -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
# ------------------------------------------------------------------------ | |
# Build | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' | |
name: Build (Windows) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
cmake --build build --config ${{env.BUILD_TYPE}} | |
echo "BUILD_VERSION=`cat VERSION`" >> $GITHUB_ENV | |
echo "BUILD_REVISION=`date +%y%m%d`" >> $GITHUB_ENV | |
shell: msys2 {0} | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Build (Linux) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
cmake --build build --config ${{env.BUILD_TYPE}} | |
echo "BUILD_VERSION=`cat VERSION`" >> $GITHUB_ENV | |
echo "BUILD_REVISION=`date +%y%m%d`" >> $GITHUB_ENV | |
- if: matrix.os == 'macos-latest' && matrix.arch == 'x86_64' | |
name: Build (MacOS) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
echo "BUILD_VERSION=`cat VERSION`" >> $GITHUB_ENV | |
echo "BUILD_REVISION=`date +%y%m%d`" >> $GITHUB_ENV | |
rm VERSION | |
cmake --build build --config ${{env.BUILD_TYPE}} | |
# ------------------------------------------------------------------------ | |
# Create the Installer | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | |
name: Create the Installer (Windows 64-bits) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}}/scripts | |
run: | | |
./is/iscc.exe //DARCH="Win64" //DQT_PATH="..\\qt\\Qt\\5.15.2\\mingw81_64" //Dversion="`cat ../VERSION`" ufprog.iss | |
mv "../build/ufprog-`cat ../VERSION`-0-win64-setup.exe" "../build/ufprog-${{env.BUILD_VERSION}}-${{env.BUILD_REVISION}}-win64-setup.exe" | |
shell: msys2 {0} | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86' | |
name: Create the Installer (Windows 32-bits) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}}/scripts | |
run: | | |
./is/iscc.exe //DARCH="Win32" //DQT_PATH="..\\qt\\Qt\\5.15.2\\mingw81_32" //Dversion="`cat ../VERSION`" ufprog.iss | |
mv "../build/ufprog-`cat ../VERSION`-0-win32-setup.exe" "../build/ufprog-${{env.BUILD_VERSION}}-${{env.BUILD_REVISION}}-win32-setup.exe" | |
shell: msys2 {0} | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Create DEB Package (Linux 64-bits) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
cp -Rf scripts/deb build/ | |
mkdir -p build/deb/ufprog/opt/ufprog | |
cp -f build/ufprog build/deb/ufprog/opt/ufprog/ | |
cp -Rf resources/linux/* build/deb/ufprog/ | |
chmod 775 build/deb/ufprog/DEBIAN/* | |
chmod +x build/deb/ufprog/opt/ufprog/ufprog | |
cd build/deb | |
dpkg -b ufprog | |
mv ufprog.deb "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-${{env.BUILD_VERSION}}-${{env.BUILD_REVISION}}-x86_64.deb" | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Create RPM Package (Linux 64-bits) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
cp -Rf scripts/rpm build/ | |
mkdir -p build/rpm/ufprog/{BUILD,BUILDROOT,RPMS,SRPMS,SOURCES} | |
mkdir -p build/rpm/ufprog/SOURCES/opt/ufprog | |
cp -f build/ufprog build/rpm/ufprog/SOURCES/opt/ufprog/ | |
cp -Rf resources/linux/usr build/rpm/ufprog/SOURCES/ | |
chmod 775 build/rpm/ufprog/SOURCES/* | |
chmod +x build/rpm/ufprog/SOURCES/opt/ufprog/ufprog | |
cd build/rpm/ufprog | |
sed -i "/^[[:space:]]*Version:/ s/:.*/: ${{env.BUILD_VERSION}}/" SPECS/ufprog.spec | |
sed -i "/^[[:space:]]*Release:/ s/:.*/: ${{env.BUILD_REVISION}}/" SPECS/ufprog.spec | |
rpmbuild -bb SPECS/ufprog.spec | |
mv RPMS/x86_64/ufprog*.rpm "${{env.SOFTWARE_PROJECT_DIR}}/build/" | |
- if: matrix.os == 'macos-latest' && matrix.arch == 'x86_64' | |
name: Create the Installer (MacOS) | |
working-directory: ${{env.SOFTWARE_PROJECT_DIR}} | |
run: | | |
cd build/Release | |
/usr/local/opt/qt@5/bin/macdeployqt "ufprog.app" -dmg | |
cp ufprog.dmg "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-${{env.BUILD_VERSION}}-${{env.BUILD_REVISION}}.dmg" | |
# ------------------------------------------------------------------------ | |
# Upload the Installer | |
# ------------------------------------------------------------------------ | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | |
name: Upload the Installer (Windows 64-bits) | |
uses: actions/upload-artifact@v3 | |
with: | |
path: "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-*setup.exe" | |
name: "ufprog-win64-installer" | |
- if: matrix.os == 'windows-latest' && matrix.arch == 'x86' | |
name: Upload the Installer (Windows 32-bits) | |
uses: actions/upload-artifact@v3 | |
with: | |
path: "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-*setup.exe" | |
name: "ufprog-win32-installer" | |
- if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | |
name: Upload the Packages (Linux 64-bits) | |
uses: actions/upload-artifact@v3 | |
with: | |
path: "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-*-*.*" | |
name: "ufprog-linux64-packages" | |
- if: matrix.os == 'macos-latest' && matrix.arch == 'x86_64' | |
name: Upload the Installer (MacOS) | |
uses: actions/upload-artifact@v3 | |
with: | |
path: "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-*.dmg" | |
name: "ufprog-macos-installer" | |
build_software_freebsd: | |
name: Build Software (FreeBSD) | |
runs-on: ubuntu-22.04 | |
steps: | |
# ------------------------------------------------------------------------ | |
# Checkout the sources | |
# ------------------------------------------------------------------------ | |
- uses: actions/checkout@v4 | |
- name: Build in FreeBSD | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
release: 13.2 | |
usesh: true | |
mem: 8192 | |
# ------------------------------------------------------------------------ | |
# Install Prerequisites | |
# ------------------------------------------------------------------------ | |
prepare: | | |
pkg install -y curl bash cmake devel/qt5 | |
run: | | |
# ------------------------------------------------------------------------ | |
# Configure CMake | |
# ------------------------------------------------------------------------ | |
cd software/usbflashprog | |
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
# ------------------------------------------------------------------------ | |
# Build | |
# ------------------------------------------------------------------------ | |
cmake --build build --config ${{env.BUILD_TYPE}} | |
export BUILD_VERSION=`cat VERSION` | |
export BUILD_REVISION=`date +%y%m%d` | |
# ------------------------------------------------------------------------ | |
# Create the Installer | |
# ------------------------------------------------------------------------ | |
cp -Rf scripts/freebsd build/ | |
mkdir -p build/freebsd/ufprog/opt/ufprog | |
cp -f build/ufprog build/freebsd/ufprog/opt/ufprog/ | |
mkdir -p build/freebsd/ufprog/usr/local | |
cp -Rf resources/linux/usr/share build/freebsd/ufprog/usr/local/ | |
chmod +x build/freebsd/ufprog/opt/ufprog/ufprog | |
cd build/freebsd/ufprog | |
sed -i '' -e "/^[[:space:]]*version:/ s/:.*/: \"$BUILD_VERSION\"/" "+MANIFEST" | |
cat "+MANIFEST" | |
pkg create -v -m `pwd`/ -r `pwd`/ -p `pwd`/plist -o . | |
mv ufprog-$BUILD_VERSION.pkg "../../ufprog-$BUILD_VERSION-$BUILD_REVISION-x86_64.pkg" | |
# ------------------------------------------------------------------------ | |
# Upload the Installer | |
# ------------------------------------------------------------------------ | |
- name: Upload the Package (FreeBSD) | |
uses: actions/upload-artifact@v3 | |
with: | |
path: "${{env.SOFTWARE_PROJECT_DIR}}/build/ufprog-*-*.*" | |
name: "ufprog-freebsd_amd64-package" |