This repository was archived by the owner on Jul 6, 2025. It is now read-only.
Build, Publish, and Release .NET App #3
Workflow file for this run
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, Publish, and Release .NET App | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Trigger the action when you push a tag (e.g., v1.0.0) | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest # You can change this to windows-latest or macos-latest based on your needs | |
| strategy: | |
| matrix: | |
| os: [win-x64, linux-x64, linux-arm64, osx-x64, osx-arm64] # Matrix to build on all 3 platforms | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set up .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: '8.0' # Change this to the version of .NET you're using | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build the project | |
| run: dotnet build --configuration Release | |
| - name: Publish the application as a single file (self-contained) | |
| run: | | |
| dotnet publish -c Release -r ${{ matrix.os }} --self-contained true /p:PublishSingleFile=true -o ./publish/${{ matrix.os }} | |
| - name: Archive published files | |
| run: | | |
| cd ./publish/${{ matrix.os }} | |
| tar -czvf ../${{ matrix.os }}.tar.gz . | |
| release: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') # Ensures this job only runs when there is a tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Create a GitHub release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| publish/win-x64.tar.gz | |
| publish/linux-x64.tar.gz | |
| publish/linux-arm64.tar.gz | |
| publish/osx-x64.tar.gz | |
| publish/osx-arm64.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |