Skip to content

release #1

release #1 #264

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 # Wrap dmg in zip
- os: windows-latest
artifact_extension: zip
steps:
- name: Checkout code
uses: actions/checkout@v4
# Ubuntu Dependencies
- name: Set up 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
echo "CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt6" >> $GITHUB_ENV
# macOS Dependencies
- name: Set up dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install ninja qt
echo "CMAKE_PREFIX_PATH=$(brew --prefix qt)" >> $GITHUB_ENV
# Windows Dependencies
- name: Set up dependencies (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
choco install qt --version=6.5.3 -y
choco install ninja -y
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
echo "CMAKE_PREFIX_PATH=C:\Qt\6.5.3\msvc2019_64\lib\cmake" >> $env:GITHUB_ENV
# Configure CMake
- name: Configure CMake
run: |
cmake -B "${{ github.workspace }}/build" \
-DCMAKE_BUILD_TYPE=Release \
-G "Ninja" \
-S "${{ github.workspace }}"
# Build application
- name: Build application
run: cmake --build "${{ github.workspace }}/build" --config Release
# Package application
- name: Package application (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
cd "${{ github.workspace }}/build"
tar -czvf application.tar.gz .
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
shell: bash
- name: Package application (Windows)
if: matrix.os == 'windows-latest'
run: |
cd "${{ github.workspace }}/build"
zip -r application.zip .
# Upload built artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: application-${{ matrix.os }}
path: ${{ github.workspace }}/build/application.${{ matrix.artifact_extension }}
create-release:
needs: build-and-release
runs-on: ubuntu-latest
if: github.event_name == 'push' # Only create releases on push events
steps:
- name: Create a Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/application-*.*
asset_name: application-${{ matrix.os }}.${{ matrix.artifact_extension }}
asset_content_type: application/octet-stream