Update dotnet.yml #2
Workflow file for this run
This file contains 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 Release | |
on: | |
push: | |
tags: | |
- 'v*' # Trigger on version tags like v1.0.0 | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest # GitHub runner for Linux | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build self-contained executable for Linux | |
run: | | |
dotnet publish -c Release -r linux-x64 --self-contained -o out/linux-x64 | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-linux | |
path: out/linux-x64 | |
build-windows: | |
runs-on: windows-latest # GitHub runner for Windows | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build self-contained executable for Windows | |
run: | | |
dotnet publish -c Release -r win-x64 --self-contained -o out/win-x64 | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-windows | |
path: out/win-x64 | |
release: | |
needs: [build-linux, build-windows] | |
runs-on: ubuntu-latest # Release job runs on Linux runner | |
steps: | |
- name: Download Linux Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: app-linux | |
path: out | |
- name: Download Windows Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: app-windows | |
path: out | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
- name: Upload Linux Release Assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: out/linux-x64/* | |
asset_name: linux-app-${{ github.ref_name }}.zip | |
asset_content_type: application/zip | |
- name: Upload Windows Release Assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: out/win-x64/* | |
asset_name: windows-app-${{ github.ref_name }}.zip | |
asset_content_type: application/zip |