Skip to content

Manual .NET Build

Manual .NET Build #4

name: Manual .NET Build
on:
workflow_dispatch:
inputs:
target_rids:
description: 'Target RIDs (comma separated). E.g: linux-x64, win-x64'
required: true
default: 'linux-x64, win-x64'
type: string
build_configs:
description: 'Configurations (comma separated). E.g: Release, Debug'
required: true
default: 'Release'
type: string
is_self_contained:
description: 'Self Contained?'
required: true
type: boolean
default: true
is_single_file:
description: 'Publish as Single File?'
required: true
type: boolean
default: false
env:
PROJECT_PATH: ./OpenBioCardServer/OpenBioCardServer.csproj
DOTNET_VERSION: '10.0.x'
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
name: Generate Build Matrix
shell: python
run: |
import json
import os
rids_input = "${{ inputs.target_rids }}"
configs_input = "${{ inputs.build_configs }}"
rids = [x.strip() for x in rids_input.split(',') if x.strip()]
configs = [x.strip() for x in configs_input.split(',') if x.strip()]
include_list = []
for r in rids:
for c in configs:
include_list.append({"rid": r, "config": c})
matrix_json = json.dumps({"include": include_list})
print(f"Generated Matrix: {matrix_json}")
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"matrix={matrix_json}")
build:
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
name: Build ${{ matrix.rid }} (${{ matrix.config }})
steps:
- name: Checkout Release Branch
uses: actions/checkout@v4
with:
ref: release
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore Dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: Publish & Zip
run: |
SELF_CONTAINED=""
if [ "${{ inputs.is_self_contained }}" == "true" ]; then
SELF_CONTAINED="--self-contained true"
else
SELF_CONTAINED="--self-contained false"
fi
SINGLE_FILE=""
if [ "${{ inputs.is_single_file }}" == "true" ]; then
SINGLE_FILE="-p:PublishSingleFile=true"
fi
OUT_NAME="OpenBioCardServer-${{ matrix.rid }}-${{ matrix.config }}"
PUBLISH_DIR="./publish_temp"
ARTIFACTS_DIR="./artifacts_output"
mkdir -p $ARTIFACTS_DIR
echo "🚀 Building: ${{ matrix.rid }} - ${{ matrix.config }}"
dotnet publish ${{ env.PROJECT_PATH }} \
-c ${{ matrix.config }} \
-r ${{ matrix.rid }} \
$SELF_CONTAINED \
$SINGLE_FILE \
-o $PUBLISH_DIR
echo "📦 Zipping to $ARTIFACTS_DIR/${OUT_NAME}.zip ..."
cd $PUBLISH_DIR
zip -r "../$ARTIFACTS_DIR/${OUT_NAME}.zip" .
echo "📂 Listing artifacts dir:"
ls -l "../$ARTIFACTS_DIR"
- name: Upload Artifact (Independent)
uses: actions/upload-artifact@v4
with:
name: OpenBioCardServer-${{ matrix.rid }}-${{ matrix.config }}
path: ./artifacts_output/*.zip
retention-days: 5