Skip to content

C/C++ CI and Release #3

C/C++ CI and Release

C/C++ CI and Release #3

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:
build-and-release:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'macos-latest' }} # Continue on error only for macOS
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
extension: .out
- os: windows-latest
extension: .exe
- os: macos-latest
extension: .out
steps:
- uses: actions/checkout@v4
- name: Build Project
run: |
g++ -I./src ./XanaduCLI/XanaduCLI.cpp ./src/XanaduXVD.cpp ./src/XVDTypes.cpp -o XanaduCLI${{ matrix.extension }}
shell: bash # Ensures compatibility on all platforms
- name: Create GitHub Release
id: create_release
if: ${{ matrix.os == 'ubuntu-latest' }} # Only create the release once (on one OS)
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 Asset
if: ${{ steps.create_release.outputs.upload_url != '' }} # Only upload if the release was created
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: XanaduCLI${{ matrix.extension }}
asset_name: XanaduCLI-${{ matrix.os }}${{ matrix.extension }}
asset_content_type: application/octet-stream