Skip to content

Workflow file for this run

name: Build for Ubuntu-x64 and Windows-x64
on:
workflow_dispatch:
inputs:
create_release:
description: "Should a release be created?"
required: true
default: "false"
type: choice
options:
- "true"
- "false"
push:
permissions:
contents: write
jobs:
build:
name: Build Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # Windows and Linux builds
outputs:
linuxx64_artifact: ${{ steps.prepare_linux_artifact.outputs.linuxx64_build }}
windowsx64_artifact: ${{ steps.prepare_windows_artifact.outputs.windowsx64_build }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: run build (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
- name: run build (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
- name: Prepare artifact (Linux)
id: prepare_linux_artifact
if: runner.os == 'Linux'
shell: bash
run: |
mkdir -p artifacts
name="MEXlibCZI-linux-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp build/MEXlibCZI/MEXlibCZI.mexa64 artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
#echo "::set-output name=linuxx64_build::${name}"
echo "linuxx64_build=${name}" >> $GITHUB_OUTPUT
- name: Prepare artifact (Windows)
id: prepare_windows_artifact
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifacts
name="MEXlibCZI-windows-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp build/MEXlibCZI/Release/MEXlibCZI.mexw64 artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
#echo "::set-output name=windowsx64_build::${name}"
echo "windowsx64_build=${name}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.artifactPath }}/
name: ${{ env.artifactName }}
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
if: inputs.create_release == 'true' # Only run if release is selected
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: "v1.0.${{ github.run_id }}"
release_name: "Release v1.0.${{ github.run_id }}"
body: |
Release for version v1.0.${{ github.run_id }}
draft: true
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download All Artifacts
if: needs.build.outputs.linuxx64_artifact != '' || needs.build.outputs.windowsx64_artifact != ''
uses: actions/download-artifact@v4
with:
path: ./artifacts # download to a specific folder
- name: Display structure of downloaded files
run: ls -R ./artifacts
- name: Upload Linux Build to Release
if: needs.build.outputs.linuxx64_artifact != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ needs.build.outputs.linuxx64_artifact }}/MEXlibCZI.mexa64
asset_name: "Linux x64"
asset_content_type: application/zip
- name: Upload Windows Build to Release
if: needs.build.outputs.windowsx64_artifact != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ needs.build.outputs.windowsx64_artifact }}/MEXlibCZI.mexw64
asset_name: "Windows x64"
asset_content_type: application/zip