Update README.md #3
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 Test | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| workflow_dispatch: | |
| env: | |
| SOLUTION_PATH: src/AirplaneSimulationTrajectory/AirplaneSimulationTrajectory.sln | |
| DOTNET_VERSION: '8.0.x' | |
| BUILD_CONFIGURATION: Release | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.configuration }}) | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| configuration: [ Debug, Release ] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET ${{ env.DOTNET_VERSION }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Setup NuGet | |
| uses: NuGet/setup-nuget@v2 | |
| with: | |
| nuget-version: 'latest' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: src/AirplaneSimulationTrajectory/packages | |
| key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.config') }} | |
| restore-keys: | | |
| nuget-${{ runner.os }}- | |
| # packages.config требует nuget restore, а не msbuild /t:Restore | |
| - name: Restore NuGet packages | |
| run: nuget restore ${{ env.SOLUTION_PATH }} | |
| - name: Build solution | |
| run: | | |
| msbuild ${{ env.SOLUTION_PATH }} ` | |
| /p:Configuration=${{ matrix.configuration }} ` | |
| /p:Platform="Any CPU" ` | |
| /p:TreatWarningsAsErrors=false ` | |
| /m ` | |
| /v:minimal | |
| publish: | |
| name: Publish Release Artifact | |
| runs-on: windows-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET ${{ env.DOTNET_VERSION }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Setup NuGet | |
| uses: NuGet/setup-nuget@v2 | |
| with: | |
| nuget-version: 'latest' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: src/AirplaneSimulationTrajectory/packages | |
| key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.config') }} | |
| restore-keys: | | |
| nuget-${{ runner.os }}- | |
| - name: Restore NuGet packages | |
| run: nuget restore ${{ env.SOLUTION_PATH }} | |
| - name: Build solution (Release) | |
| run: | | |
| msbuild ${{ env.SOLUTION_PATH }} ` | |
| /p:Configuration=${{ env.BUILD_CONFIGURATION }} ` | |
| /p:Platform="Any CPU" ` | |
| /m ` | |
| /v:minimal | |
| - name: Collect build output | |
| run: | | |
| New-Item -ItemType Directory -Force -Path ./publish/win-x64 | |
| Get-ChildItem -Recurse -Path src -Include "*.exe","*.dll","*.config","*.pdb" ` | |
| | Where-Object { $_.FullName -match "\\bin\\${{ env.BUILD_CONFIGURATION }}\\" } ` | |
| | Copy-Item -Destination ./publish/win-x64 -Force | |
| - name: Get short SHA | |
| id: vars | |
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AirplaneSimulationTrajectory-${{ steps.vars.outputs.sha_short }} | |
| path: ./publish/win-x64/ | |
| retention-days: 30 | |
| if-no-files-found: error |