Skip to content

Instantly share code, notes, and snippets.

@eduherminio
Created April 24, 2025 13:32
Show Gist options
  • Save eduherminio/94817d5d059c2b4dea4665e86fb7bd73 to your computer and use it in GitHub Desktop.
Save eduherminio/94817d5d059c2b4dea4665e86fb7bd73 to your computer and use it in GitHub Desktop.
GitHub Actions workflow for publish self-contained, single-file trimmed .NET apps
name: Release
on:
workflow_dispatch:
env:
DOTNET_VERSION: 8.0.x
jobs:
build-and-publish:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest, macos-14]
include:
- os: ubuntu-latest
runtime-identifier: linux-x64
- os: windows-latest
runtime-identifier: win-x64
- os: macOS-latest
runtime-identifier: osx-x64
- os: macos-14
runtime-identifier: osx-arm64
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Nuget cache
uses: actions/cache@v4
with:
path:
~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build
run: dotnet build -c Release
- name: Publish Engine
run: dotnet publish <csproj_path> -c Release --runtime ${{ matrix.runtime-identifier }} --self-contained /p:PublishSingleFile=true /p:PublishTrimmed=true -o artifacts/${{ matrix.runtime-identifier }}
- name: Upload <app_name>-${{ github.run_number }}-${{ matrix.runtime-identifier }} artifact
uses: actions/upload-artifact@v4
with:
name: <app_name>-${{ github.run_number }}-${{ matrix.runtime-identifier }}
path: |
artifacts/${{ matrix.runtime-identifier }}/
!artifacts/**/*.pdb
if-no-files-found: error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment