|
| 1 | +name: Continuous Integration on new tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" |
| 8 | + - "v[0-9]+.[0-9]+.[0-9]+-preview.[0-9]+" |
| 9 | + |
| 10 | +env: |
| 11 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 |
| 12 | + DOTNET_NOLOGO: true |
| 13 | + ARTIFACTS_NAME: artifacts |
| 14 | + ARTIFACTS_FOLDER: ${{github.workspace}}/artifacts |
| 15 | + NUGET_URI: "https://api.nuget.org/v3/index.json" |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Build |
| 20 | + runs-on: ubuntu-22.04 |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout (all tree) |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + filter: tree:0 |
| 28 | + |
| 29 | + - name: Set up .NET Core (global.json) |
| 30 | + uses: actions/setup-dotnet@v4 |
| 31 | + |
| 32 | + - name: dotnet build (sources only) |
| 33 | + run: dotnet build src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj --configuration Release |
| 34 | + |
| 35 | + - name: dotnet build (tests only) |
| 36 | + run: | |
| 37 | + dotnet build test/Sotsera.Sources.Common.Tests.Unit/Sotsera.Sources.Common.Tests.Unit.csproj --configuration Release |
| 38 | + dotnet build test/Sotsera.Sources.Common.Tests.Integration/Sotsera.Sources.Common.Tests.Integration.csproj --configuration Release |
| 39 | +
|
| 40 | + - name: dotnet test |
| 41 | + run: dotnet test --configuration Release --no-build |
| 42 | + |
| 43 | + - name: Upload artifacts |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + if-no-files-found: error |
| 47 | + name: ${{ env.ARTIFACTS_NAME }} |
| 48 | + path: ${{ env.ARTIFACTS_FOLDER }} |
| 49 | + retention-days: 5 |
| 50 | + |
| 51 | + publish: |
| 52 | + name: Publish |
| 53 | + runs-on: ubuntu-22.04 |
| 54 | + needs: build |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Dowload artifacts |
| 58 | + uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + name: ${{ env.ARTIFACTS_NAME }} |
| 61 | + path: ${{ env.ARTIFACTS_FOLDER }} |
| 62 | + |
| 63 | + - name: Set up .NET Core (global.json) |
| 64 | + uses: actions/setup-dotnet@v4 |
| 65 | + |
| 66 | + - name: Publish NuGet packages |
| 67 | + shell: pwsh |
| 68 | + env: |
| 69 | + NUGET_APY_KEY: ${{ secrets.NUGET_APY_KEY }} |
| 70 | + run: | |
| 71 | + Write-Host "Current ref: $env:GITHUB_REF" |
| 72 | + Write-Host "Searching nupkg in folder: ${{ env.ARTIFACTS_FOLDER }}" |
| 73 | + $files = Get-ChildItem "${{ env.ARTIFACTS_FOLDER }}/*" -Include *.nupkg |
| 74 | + foreach($file in $files) { |
| 75 | + Write-Host "Pushing NuGet package: $($file.FullName)" |
| 76 | + & dotnet nuget push "$($file.FullName)" --api-key "$env:NUGET_APY_KEY" --source ${{ env.NUGET_URI }} --force-english-output --skip-duplicate |
| 77 | + } |
0 commit comments