name: Build and release SeConv on: workflow_dispatch: inputs: build_configuration: description: 'Build configuration' required: true default: 'Release' type: choice options: - Release - Debug create_release: description: 'Upload seconv binaries to the GitHub release (uncheck to only build artifacts)' required: true default: true type: boolean is_prerelease: description: 'Pre-release flag — MUST match the build-ui.yml run for the same tag, otherwise the existing release will be flipped' required: true default: true type: boolean release_tag: description: 'Release tag, same value as build-ui.yml (e.g., v5.0.0-beta21). Seconv assets are added to that release; if it does not exist yet, an empty release is created and build-ui.yml will fill in the title/body when it runs.' required: false default: '' type: string workflow_call: inputs: build_configuration: required: true default: 'Release' type: string create_release: required: true default: true type: boolean is_prerelease: required: true default: true type: boolean release_tag: required: false default: '' type: string jobs: build-windows: runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '10.0.x' - name: Extract version from Se.cs shell: pwsh run: | $seContent = Get-Content "src/ui/Logic/Config/Se.cs" -Raw $m = [regex]::Match($seContent, 'public\s+static\s+string\s+Version\s*\{[^}]+\}\s*=\s*"v([^"]+)"') if (-not $m.Success) { throw "Could not find Version in Se.cs" } $versionString = $m.Groups[1].Value $parts = $versionString -split '-', 2 $numericFields = $parts[0].Split('.') $major = [int]$numericFields[0] $minor = if ($numericFields.Length -gt 1) { [int]$numericFields[1] } else { 0 } $build = if ($numericFields.Length -gt 2) { [int]$numericFields[2] } else { 0 } $revision = 0 if ($parts.Length -gt 1) { $rm = [regex]::Match($parts[1], '\d+$') if ($rm.Success) { $revision = [int]$rm.Value } } $appVerFull = "$major.$minor.$build.$revision" "APP_VER_DISPLAY=$versionString" >> $env:GITHUB_ENV "APP_VER_FULL=$appVerFull" >> $env:GITHUB_ENV Write-Host "APP_VER_DISPLAY=$versionString" Write-Host "APP_VER_FULL=$appVerFull" - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Publish Windows x64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r win-x64 --self-contained true ` -p:PublishSingleFile=true ` -p:Version=$env:APP_VER_FULL ` -p:FileVersion=$env:APP_VER_FULL ` -p:InformationalVersion=$env:APP_VER_DISPLAY ` -o ./publish/windows-x64 - name: Publish Windows ARM64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r win-arm64 --self-contained true ` -p:PublishSingleFile=true ` -p:Version=$env:APP_VER_FULL ` -p:FileVersion=$env:APP_VER_FULL ` -p:InformationalVersion=$env:APP_VER_DISPLAY ` -o ./publish/windows-arm64 - name: Remove PDB files run: | Get-ChildItem -Path "./publish/windows-x64/" -Recurse -Include *.pdb | Remove-Item -Force Get-ChildItem -Path "./publish/windows-arm64/" -Recurse -Include *.pdb | Remove-Item -Force - name: Create Windows ZIP packages run: | # Stage the repo LICENSE so the SeConv zip carries the MIT terms too (issue #11278). Copy-Item "./LICENSE" "./publish/windows-x64/LICENSE" Copy-Item "./LICENSE" "./publish/windows-arm64/LICENSE" Compress-Archive -Path "./publish/windows-x64/*" -DestinationPath "./SeConv-Windows-x64.zip" Compress-Archive -Path "./publish/windows-arm64/*" -DestinationPath "./SeConv-Windows-ARM64.zip" - name: Upload Windows ZIP packages uses: actions/upload-artifact@v4 with: name: windows-zip-packages path: | ./SeConv-Windows-x64.zip ./SeConv-Windows-ARM64.zip build-macos: runs-on: macos-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '10.0.x' - name: Extract version from Se.cs run: | set -e line=$(grep -E 'public[[:space:]]+static[[:space:]]+string[[:space:]]+Version[[:space:]]*\{' src/ui/Logic/Config/Se.cs) version_string=$(printf '%s' "$line" | sed -E 's/.*"v([^"]+)".*/\1/') numeric_part="${version_string%%-*}" suffix="" case "$version_string" in *-*) suffix="${version_string#*-}" ;; esac dot_count=$(printf '%s' "$numeric_part" | tr -cd '.' | wc -c | tr -d ' ') case "$dot_count" in 0) numeric_part="${numeric_part}.0.0" ;; 1) numeric_part="${numeric_part}.0" ;; esac revision=$(printf '%s' "$suffix" | grep -oE '[0-9]+$' || true) revision=${revision:-0} app_ver_full="${numeric_part}.${revision}" echo "APP_VER_DISPLAY=$version_string" >> "$GITHUB_ENV" echo "APP_VER_FULL=$app_ver_full" >> "$GITHUB_ENV" echo "APP_VER_DISPLAY=$version_string" echo "APP_VER_FULL=$app_ver_full" - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Publish macOS x64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r osx-x64 --self-contained true \ -p:PublishSingleFile=true \ -p:Version="$APP_VER_FULL" \ -p:FileVersion="$APP_VER_FULL" \ -p:InformationalVersion="$APP_VER_DISPLAY" \ -o ./publish/macos-x64 find "./publish/macos-x64/" -name "*.pdb" -type f -delete - name: Publish macOS ARM64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r osx-arm64 --self-contained true \ -p:PublishSingleFile=true \ -p:Version="$APP_VER_FULL" \ -p:FileVersion="$APP_VER_FULL" \ -p:InformationalVersion="$APP_VER_DISPLAY" \ -o ./publish/macos-arm64 find "./publish/macos-arm64/" -name "*.pdb" -type f -delete - name: Create macOS ZIP packages run: | # Stage the repo LICENSE so the SeConv zip carries the MIT terms too (issue #11278). cp ./LICENSE ./publish/macos-x64/LICENSE cp ./LICENSE ./publish/macos-arm64/LICENSE cd ./publish/macos-x64 && zip -r ../../SeConv-macOS-x64.zip . && cd ../.. cd ./publish/macos-arm64 && zip -r ../../SeConv-macOS-ARM64.zip . && cd ../.. - name: Upload macOS ZIP packages uses: actions/upload-artifact@v4 with: name: macos-zip-packages path: | ./SeConv-macOS-x64.zip ./SeConv-macOS-ARM64.zip build-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '10.0.x' - name: Extract version from Se.cs run: | set -e line=$(grep -E 'public[[:space:]]+static[[:space:]]+string[[:space:]]+Version[[:space:]]*\{' src/ui/Logic/Config/Se.cs) version_string=$(printf '%s' "$line" | sed -E 's/.*"v([^"]+)".*/\1/') numeric_part="${version_string%%-*}" suffix="" case "$version_string" in *-*) suffix="${version_string#*-}" ;; esac dot_count=$(printf '%s' "$numeric_part" | tr -cd '.' | wc -c | tr -d ' ') case "$dot_count" in 0) numeric_part="${numeric_part}.0.0" ;; 1) numeric_part="${numeric_part}.0" ;; esac revision=$(printf '%s' "$suffix" | grep -oE '[0-9]+$' || true) revision=${revision:-0} app_ver_full="${numeric_part}.${revision}" echo "APP_VER_DISPLAY=$version_string" >> "$GITHUB_ENV" echo "APP_VER_FULL=$app_ver_full" >> "$GITHUB_ENV" echo "APP_VER_DISPLAY=$version_string" echo "APP_VER_FULL=$app_ver_full" - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Publish Linux x64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r linux-x64 --self-contained true \ -p:PublishSingleFile=true \ -p:Version="$APP_VER_FULL" \ -p:FileVersion="$APP_VER_FULL" \ -p:InformationalVersion="$APP_VER_DISPLAY" \ -o ./publish/linux-x64 - name: Publish Linux ARM64 run: | dotnet publish src/seconv/SeConv.csproj -c ${{ inputs.build_configuration }} -r linux-arm64 --self-contained true \ -p:PublishSingleFile=true \ -p:Version="$APP_VER_FULL" \ -p:FileVersion="$APP_VER_FULL" \ -p:InformationalVersion="$APP_VER_DISPLAY" \ -o ./publish/linux-arm64 - name: Remove PDB files from Linux artifacts run: | find "./publish/linux-x64/" -name "*.pdb" -type f -delete find "./publish/linux-arm64/" -name "*.pdb" -type f -delete - name: Create Linux TAR packages run: | # Stage the repo LICENSE so the SeConv tarball carries the MIT terms too (issue #11278). cp ./LICENSE ./publish/linux-x64/LICENSE cp ./LICENSE ./publish/linux-arm64/LICENSE cd ./publish/linux-x64 && tar -czf ../../SeConv-Linux-x64.tar.gz . && cd ../.. cd ./publish/linux-arm64 && tar -czf ../../SeConv-Linux-ARM64.tar.gz . && cd ../.. - name: Upload Linux TAR packages uses: actions/upload-artifact@v4 with: name: linux-tar-packages path: | ./SeConv-Linux-x64.tar.gz ./SeConv-Linux-ARM64.tar.gz create-release: if: ${{ inputs.create_release }} needs: [build-windows, build-macos, build-linux] runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - name: Generate release tag id: tag run: | if [ -n "${{ inputs.release_tag }}" ]; then echo "tag=$(echo '${{ inputs.release_tag }}' | xargs)" >> $GITHUB_OUTPUT else timestamp=$(date +"%Y%m%d-%H%M%S") echo "tag=pre-release-${timestamp}" >> $GITHUB_OUTPUT fi - name: Download all artifacts uses: actions/download-artifact@v4 with: path: ./artifacts - name: Prepare release assets run: | mkdir -p ./release-assets # Copy ZIP/TAR packages to release assets cp ./artifacts/windows-zip-packages/*.zip ./release-assets/ cp ./artifacts/macos-zip-packages/*.zip ./release-assets/ cp ./artifacts/linux-tar-packages/*.tar.gz ./release-assets/ # List all files that will be uploaded echo "Release assets:" ls -la ./release-assets/ # Upload seconv assets to the release for this tag. # If the release already exists (created by build-ui.yml), assets are added without # overwriting the existing name/body — we deliberately omit `name:` and `body:` so the # action falls back to the existing release values. If the release does not exist yet, # one is created (with no body) so the seconv assets have somewhere to live; the # build-ui.yml run will then fill in the name and body when it runs against the same tag. - name: Upload seconv assets to release uses: softprops/action-gh-release@v2 id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.tag.outputs.tag }} draft: false prerelease: ${{ inputs.is_prerelease }} files: | ./release-assets/SeConv-Windows-x64.zip ./release-assets/SeConv-Windows-ARM64.zip ./release-assets/SeConv-macOS-ARM64.zip ./release-assets/SeConv-macOS-x64.zip ./release-assets/SeConv-Linux-x64.tar.gz ./release-assets/SeConv-Linux-ARM64.tar.gz