| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- name: Build and Test
- on:
- push:
- branches: [ main, master, develop ]
- pull_request:
- branches: [ main, master ]
- env:
- DOTNET_VERSION: '8.0.x'
- CONFIGURATION: Release
- jobs:
- build:
- runs-on: windows-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup .NET
- uses: actions/setup-dotnet@v4
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
- - name: Restore dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore
- - name: Test
- run: dotnet test --configuration ${{ env.CONFIGURATION }} --no-build --verbosity normal --collect:"XPlat Code Coverage"
- - name: Upload coverage reports
- uses: codecov/codecov-action@v4
- with:
- file: '**/coverage.cobertura.xml'
- fail_ci_if_error: false
- continue-on-error: true
- - name: Upload build artifacts
- uses: actions/upload-artifact@v4
- with:
- name: build-output
- path: |
- src/*/bin/${{ env.CONFIGURATION }}/
- !**/*.pdb
- publish-windows:
- needs: build
- runs-on: windows-latest
- if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup .NET
- uses: actions/setup-dotnet@v4
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
- - name: Publish Windows x64
- run: |
- dotnet publish src/YZWater.Avalonia -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/win-x64
- - name: Upload Windows artifact
- uses: actions/upload-artifact@v4
- with:
- name: YZWater-win-x64
- path: ./publish/win-x64/
- publish-linux:
- needs: build
- runs-on: ubuntu-latest
- if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup .NET
- uses: actions/setup-dotnet@v4
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
- - name: Publish Linux x64
- run: |
- dotnet publish src/YZWater.Avalonia -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/linux-x64
- - name: Upload Linux artifact
- uses: actions/upload-artifact@v4
- with:
- name: YZWater-linux-x64
- path: ./publish/linux-x64/
- publish-macos:
- needs: build
- runs-on: macos-latest
- if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup .NET
- uses: actions/setup-dotnet@v4
- with:
- dotnet-version: ${{ env.DOTNET_VERSION }}
- - name: Publish macOS x64
- run: |
- dotnet publish src/YZWater.Avalonia -c Release -r osx-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/osx-x64
- - name: Upload macOS artifact
- uses: actions/upload-artifact@v4
- with:
- name: YZWater-osx-x64
- path: ./publish/osx-x64/
- release:
- needs: [publish-windows, publish-linux, publish-macos]
- runs-on: ubuntu-latest
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- steps:
- - name: Download all artifacts
- uses: actions/download-artifact@v4
- with:
- path: ./artifacts
- - name: Create release archives
- run: |
- cd artifacts
- for dir in */; do
- dirname="${dir%/}"
- zip -r "../YZWater-${dirname}.zip" "$dirname"
- done
- - name: Create GitHub Release
- uses: softprops/action-gh-release@v2
- with:
- files: |
- YZWater-*.zip
- generate_release_notes: true
|