Skip to content

C/C++ CI and Release #7

C/C++ CI and Release

C/C++ CI and Release #7

name: C/C++ CI and Release
on:
push:
tags:
- 'v*.*.*' # Trigger only on tags like v1.0.0
workflow_dispatch: # Allow manual runs if needed
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create GitHub 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
build-and-release:
needs: create-release
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'macos-latest' }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
extension: .out
compiler: g++
- os: windows-latest
extension: .exe
compiler: mingw-g++
- os: macos-latest
extension: .out
compiler: clang++
steps:
- uses: actions/checkout@v4
# Conditional MinGW setup for Windows
- name: Set up MSYS2 and install MinGW
if: ${{ matrix.os == 'windows-latest' }}
run: |
pacman -Sy --noconfirm
pacman -S --noconfirm mingw-w64-x86_64-gcc
shell: bash
# Build step - uses appropriate compiler based on OS
- name: Build Project
run: |
if [ "${{ matrix.compiler }}" == "mingw-g++" ]; then
/mingw64/bin/g++ -I./src ./XanaduCLI/XanaduCLI.cpp ./src/XanaduXVD.cpp ./src/XVDTypes.cpp -o XanaduCLI${{ matrix.extension }}
else
${{ matrix.compiler }} -I./src ./XanaduCLI/XanaduCLI.cpp ./src/XanaduXVD.cpp ./src/XVDTypes.cpp -o XanaduCLI${{ matrix.extension }}
fi
shell: bash
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: XanaduCLI${{ matrix.extension }}
asset_name: XanaduCLI-${{ matrix.os }}${{ matrix.extension }}
asset_content_type: application/octet-stream