|
| 1 | + |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + create: |
| 6 | + branches: |
| 7 | + - release/** |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + - dev/** |
| 12 | + paths: |
| 13 | + - MemoryModule/** |
| 14 | + - MemoryModule.Tests/** |
| 15 | + - .github/workflows/ci.yml |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - master |
| 19 | + paths: |
| 20 | + - MemoryModule/** |
| 21 | + - MemoryModule.Tests/** |
| 22 | + - .github/workflows/ci.yml |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + |
| 27 | + env: |
| 28 | + BUILD_CONFIG: 'Release' |
| 29 | + SOLUTION: 'MemoryModule.sln' |
| 30 | + |
| 31 | + runs-on: windows-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v2 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Install GitVersion |
| 40 | + uses: gittools/actions/gitversion/setup@v0.9.10 |
| 41 | + with: |
| 42 | + versionSpec: '5.x' |
| 43 | + |
| 44 | + - name: Determine Version |
| 45 | + id: gitversion |
| 46 | + uses: gittools/actions/gitversion/execute@v0.9.10 |
| 47 | + |
| 48 | + - name: Setup NuGet |
| 49 | + uses: NuGet/setup-nuget@v1.0.5 |
| 50 | + |
| 51 | + - name: Restore dependencies |
| 52 | + run: nuget restore $SOLUTION |
| 53 | + |
| 54 | + - name: Setup .NET |
| 55 | + run: | |
| 56 | + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1' |
| 57 | + ./dotnet-install.ps1 -Channel Current |
| 58 | + shell: pwsh |
| 59 | + |
| 60 | + - name: Setup MSBuild |
| 61 | + uses: microsoft/setup-msbuild@v1.0.2 |
| 62 | + |
| 63 | + - name: Build |
| 64 | + run: msbuild $env:SOLUTION /p:Configuration=$env:BUILD_CONFIG /p:Platform="Any CPU" -p:Version=${{ steps.gitversion.outputs.assemblySemVer }} |
| 65 | + |
| 66 | + - name: Run tests |
| 67 | + run: dotnet test /p:Configuration=$env:BUILD_CONFIG /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --no-restore --no-build --verbosity normal |
| 68 | + |
| 69 | + - name: Build nuget packages |
| 70 | + run: msbuild -t:pack $env:SOLUTION -p:Configuration=$env:BUILD_CONFIG -p:PackageVersion=${{ steps.gitversion.outputs.semVer }} |
| 71 | + |
| 72 | + - name: Move nuget packages |
| 73 | + run: mkdir .nupkgs; get-childitem *.*nupkg -recurse | foreach-object {move-item $_ -destination .nupkgs} |
| 74 | + shell: pwsh |
| 75 | + |
| 76 | + - name: Publish nuget artifacts |
| 77 | + uses: actions/upload-artifact@v2 |
| 78 | + with: |
| 79 | + name: packages.${{ steps.gitversion.outputs.semVer }} |
| 80 | + path: .nupkgs/** |
| 81 | + |
| 82 | + - name: Publish dev |
| 83 | + if: github.ref == 'refs/heads/master' |
| 84 | + run: nuget push .nupkgs\** -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} |
| 85 | + |
| 86 | + - name: Publish |
| 87 | + if: startsWith(github.ref, 'refs/heads/release') |
| 88 | + run: nuget push .nupkgs\** -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} |
0 commit comments