avalonia(104): v2.8 — bump version; gate the neural build behind an o… #32
This file contains hidden or 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: build-and-package | |
| # Builds and packages 3DSnickerStream (Avalonia) for Windows and Linux on their | |
| # native runners. A v* tag additionally drafts a GitHub Release with the packaged | |
| # artifacts. macOS is built locally on the maintainer's Mac (ad-hoc signing + the | |
| # "damaged" Gatekeeper fix are simplest there) and its asset is uploaded by hand. | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to stamp on artifacts (e.g. 2.0.0)' | |
| required: false | |
| default: '2.0.0' | |
| env: | |
| PROJECT: Snickerstream.Avalonia/Snickerstream.Avalonia.csproj | |
| DOTNET_NOLOGO: 'true' | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 'true' | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| rid: win-x64 | |
| kind: win | |
| - os: ubuntu-latest | |
| rid: linux-x64 | |
| kind: linux | |
| # macOS is built locally on the maintainer's Mac, not in CI (see header). | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # Version = tag (strip leading v) > workflow_dispatch input > 2.0.0 | |
| - name: Resolve version | |
| id: ver | |
| shell: bash | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then | |
| V="${GITHUB_REF#refs/tags/v}" | |
| else | |
| V="${{ github.event.inputs.version || '2.0.0' }}" | |
| fi | |
| echo "version=$V" >> "$GITHUB_OUTPUT" | |
| echo "Version: $V" | |
| # Windows: single-file self-contained exe (+ tessdata + x64 natives via the csproj target). | |
| - name: Publish (Windows) | |
| if: matrix.kind == 'win' | |
| shell: bash | |
| run: | | |
| dotnet publish "$PROJECT" -c Release -r ${{ matrix.rid }} --self-contained true \ | |
| -p:PublishSingleFile=true -p:Version=${{ steps.ver.outputs.version }} \ | |
| -o "publish/${{ matrix.rid }}" | |
| # Linux/macOS: self-contained folder (single-file complicates native asset loading). | |
| - name: Publish (Unix) | |
| if: matrix.kind != 'win' | |
| shell: bash | |
| run: | | |
| dotnet publish "$PROJECT" -c Release -r ${{ matrix.rid }} --self-contained true \ | |
| -p:Version=${{ steps.ver.outputs.version }} \ | |
| -o "publish/${{ matrix.rid }}" | |
| # ---- package ---- | |
| - name: Package (Windows zip) | |
| if: matrix.kind == 'win' | |
| shell: pwsh | |
| run: | | |
| $v = "${{ steps.ver.outputs.version }}" | |
| New-Item -ItemType Directory -Force dist | Out-Null | |
| Compress-Archive -Path "publish/${{ matrix.rid }}/*" ` | |
| -DestinationPath "dist/3DSnickerStream-v$v-${{ matrix.rid }}.zip" -Force | |
| - name: Package (macOS .app zip) | |
| if: matrix.kind == 'mac' | |
| shell: bash | |
| run: | | |
| v="${{ steps.ver.outputs.version }}" | |
| mkdir -p dist | |
| bash packaging/macos/make-app.sh "publish/${{ matrix.rid }}" "dist/3DSnickerStream.app" "$v" | |
| # ditto (not zip -r) preserves the code signature and bundle metadata inside the .app. | |
| ( cd dist && ditto -c -k --keepParent "3DSnickerStream.app" "3DSnickerStream-v$v-${{ matrix.rid }}.zip" && rm -rf "3DSnickerStream.app" ) | |
| - name: Package (Linux tar.gz) | |
| if: matrix.kind == 'linux' | |
| shell: bash | |
| run: | | |
| v="${{ steps.ver.outputs.version }}" | |
| mkdir -p dist | |
| tar -C "publish/${{ matrix.rid }}" -czf "dist/3DSnickerStream-v$v-${{ matrix.rid }}.tar.gz" . | |
| - name: Package (Linux AppImage, best effort) | |
| if: matrix.kind == 'linux' | |
| continue-on-error: true | |
| shell: bash | |
| env: | |
| APPIMAGE_EXTRACT_AND_RUN: '1' | |
| run: | | |
| v="${{ steps.ver.outputs.version }}" | |
| sudo apt-get update && sudo apt-get install -y imagemagick libfuse2 || true | |
| bash packaging/linux/make-appimage.sh "publish/${{ matrix.rid }}" \ | |
| "dist/3DSnickerStream-v$v-linux-x86_64.AppImage" "$v" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 3DSnickerStream-${{ matrix.rid }} | |
| path: dist/* | |
| if-no-files-found: error | |
| release: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| generate_release_notes: true | |
| files: artifacts/**/* |