release #31 #294
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
name: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
artifact_extension: tar.gz | |
- os: macos-latest | |
artifact_extension: zip | |
- os: windows-latest | |
artifact_extension: zip | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Ubuntu Section | |
- name: Install dependencies (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ninja-build \ | |
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \ | |
qt6-l10n-tools libgl1-mesa-dev libglu1-mesa-dev rsync cmake | |
- name: Configure CMake (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cmake -B "${{ github.workspace }}/build" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-G "Ninja" \ | |
-S "${{ github.workspace }}" | |
shell: bash | |
- name: Build application (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cmake --build "${{ github.workspace }}/build" --config Release | |
shell: bash | |
- name: Package application (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
BUILD_DIR="${{ github.workspace }}/build" | |
TEMP_DIR="/tmp/build_copy" | |
rm -rf $TEMP_DIR | |
rsync -a "$BUILD_DIR/" "$TEMP_DIR/" | |
cd $TEMP_DIR | |
tar -czvf application.tar.gz ./* | |
# macOS Section | |
- name: Install dependencies (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install ninja qt cmake | |
- name: Configure CMake (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
cmake -B "${{ github.workspace }}/build" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-G "Ninja" \ | |
-S "${{ github.workspace }}" | |
shell: bash | |
- name: Build application (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
cmake --build "${{ github.workspace }}/build" --config Release | |
shell: bash | |
- name: Package application (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
cd "${{ github.workspace }}/build" | |
hdiutil create -volname Application -srcfolder . -ov -format UDZO application.dmg | |
zip application.zip application.dmg | |
# Windows Section | |
- name: Verify Visual Studio Installation | |
if: matrix.os == 'windows-latest' | |
run: | | |
echo "Checking for Visual Studio Build Tools..." | |
dir "C:\Program Files (x86)\Microsoft Visual Studio" /b | |
dir "C:\Program Files\Microsoft Visual Studio" /b | |
dir "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build" /b || exit 1 | |
shell: cmd | |
- name: Install dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
choco install qt --version=6.5.3 -y | |
choco install ninja -y | |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y | |
choco install visualstudio2022buildtools -y --install-arguments \ | |
'--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --norestart' | |
- name: Configure CMake (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && ^ | |
cmake -B D:\a\Notepad--\Notepad--\build ^ | |
-DCMAKE_BUILD_TYPE=Release ^ | |
-DCMAKE_PREFIX_PATH="C:\Qt\6.5.3\msvc2019_64\lib\cmake" ^ | |
-G Ninja ^ | |
-S D:\a\Notepad--\Notepad-- | |
shell: cmd | |
- name: Build application (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && ^ | |
cmake --build D:\a\Notepad--\Notepad--\build --config Release | |
shell: cmd | |
- name: Package application (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd D:\a\Notepad--\Notepad--\build | |
Compress-Archive -Path . -DestinationPath application.zip | |
shell: cmd | |
# Upload Artifacts | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: application-${{ matrix.os }} | |
path: | | |
${{ github.workspace }}/build/application.${{ matrix.artifact_extension }} | |
/tmp/build_copy/application.tar.gz |