C/C++ CI and Release #11
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: 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-2019, macos-latest] | |
include: | |
- os: ubuntu-latest | |
extension: .out | |
compiler: g++ | |
- os: windows-2019 | |
extension: .exe | |
compiler: mingw-g++ | |
- os: macos-latest | |
extension: .out | |
compiler: clang++ | |
steps: | |
- uses: actions/checkout@v4 | |
# Set up MSYS2 environment and install MinGW on Windows | |
- name: Set up MSYS2 with MinGW | |
if: ${{ matrix.os == 'windows-2019' }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
install: mingw-w64-x86_64-gcc | |
# Add MinGW to PATH on Windows | |
- name: Add MinGW to PATH | |
if: ${{ matrix.os == 'windows-2019' }} | |
run: echo "C:/msys64/mingw64/bin" >> $GITHUB_PATH | |
# Build step - uses appropriate compiler based on OS | |
- name: Build Project | |
run: | | |
if [ "${{ matrix.compiler }}" == "mingw-g++" ]; then | |
g++ -std=c++17 -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 | |
# Upload Release Asset for each OS build | |
- 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 |