|
| 1 | +name: Build, test, pack, push (CI) |
| 2 | +on: |
| 3 | + |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + workflow_dispatch: |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: windows-latest |
| 14 | + env: |
| 15 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v1 |
| 18 | + name: Checkout Code |
| 19 | + |
| 20 | + - name: Setup MSBuild Ppth |
| 21 | + uses: microsoft/setup-msbuild@v1 |
| 22 | + |
| 23 | + - name: Setup NuGet |
| 24 | + |
| 25 | + |
| 26 | + - name: Restore NuGet Packages |
| 27 | + run: nuget restore QRCoder.sln |
| 28 | + |
| 29 | + - name: Build library |
| 30 | + run: msbuild QRCoder.sln /p:Configuration=Release /nr:false /t:Rebuild |
| 31 | + |
| 32 | + - name: Upload artifacts |
| 33 | + |
| 34 | + with: |
| 35 | + name: Compiled project |
| 36 | + path: D:\a\qrcoder\qrcoder |
| 37 | + |
| 38 | + test: |
| 39 | + needs: build |
| 40 | + runs-on: windows-latest |
| 41 | + steps: |
| 42 | + - name: Download artifacts |
| 43 | + |
| 44 | + with: |
| 45 | + name: Compiled project |
| 46 | + path: D:\a\qrcoder\qrcoder |
| 47 | + - name: Run test .NET 3.5 |
| 48 | + run: dotnet test -c Release -f net35 --nologo --no-build # No coverage for NET3.5 because of bug in combination with Coverlet+Stron naming |
| 49 | + - name: Run test .NET 4.52 |
| 50 | + run: dotnet test -c Release -f net452 --nologo --no-build # No coverage for NET4.5 because of bug in combination with Coverlet+Stron naming |
| 51 | +# Skip 1.1 test due to missing support on Github runner |
| 52 | +# - name: Run test .NET Core 1.1 |
| 53 | +# run: dotnet test -c Release -f netcoreapp1.1 --nologo |
| 54 | + - name: Run test .NET Core 2.0 |
| 55 | + run: dotnet test -c Release -f netcoreapp2.0 --nologo /p:CollectCoverage=true /p:CoverletOutputFormat=opencover |
| 56 | + - name: Run test .NET 5.0 |
| 57 | + run: dotnet test -c Release -f net5.0 --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover |
| 58 | + - name: Run test .NET 5.0 Windows |
| 59 | + run: dotnet test -c Release -f net5.0-windows --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover |
| 60 | + - name: Codecov update netcoreapp2.0 |
| 61 | + uses: codecov/codecov-action@v2 |
| 62 | + with: |
| 63 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 64 | + files: ./QRCoderTests/coverage.netcoreapp2.0.opencover.xml |
| 65 | + flags: netcoreapp2.0 |
| 66 | + - name: Codecov update net5.0 |
| 67 | + uses: codecov/codecov-action@v2 |
| 68 | + with: |
| 69 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 70 | + files: ./QRCoderTests/coverage.net5.0.opencover.xml |
| 71 | + flags: net5.0 |
| 72 | + - name: Codecov update net5.0-windows |
| 73 | + uses: codecov/codecov-action@v2 |
| 74 | + with: |
| 75 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 76 | + files: ./QRCoderTests/coverage.net5.0-windows.opencover.xml |
| 77 | + flags: net5.0-windows |
| 78 | + |
| 79 | + pack-push-ci: |
| 80 | + needs: test |
| 81 | + runs-on: windows-latest |
| 82 | + env: |
| 83 | + GH_PKG_SEC: ${{ secrets.GH_PKG_REPO }} |
| 84 | + steps: |
| 85 | + - name: Download artifacts |
| 86 | + |
| 87 | + with: |
| 88 | + name: Compiled project |
| 89 | + path: D:\a\qrcoder\qrcoder |
| 90 | + - name: Restore dependencies |
| 91 | + run: dotnet restore |
| 92 | + - name: Get assembly version |
| 93 | + run: echo "ASSEM_VER=$([Reflection.Assembly]::Loadfile( $(-join($pwd,"\QRCoder\bin\Release\net40\QRCoder.dll"))).GetName().version.ToString())" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append |
| 94 | + - name: Clean assembly version |
| 95 | + run: echo "ASSEM_VER_SHT=$($env:ASSEM_VER.substring(0, $env:ASSEM_VER.lastIndexOf(".")))" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append |
| 96 | + - name: Calculate ci suffix |
| 97 | + run: echo "CI_TAG=-ci-$([datetime]::now.tostring("yyyyMMddHHmmss"))" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append |
| 98 | + - name: Build NuGet package |
| 99 | + run: dotnet pack QRCoder\QRCoder.csproj -c Release --no-build /p:PackageVersion="$env:ASSEM_VER_SHT$env:CI_TAG" /p:PackageReleaseNotes="- This is an automatic CI build ($env:CI_TAG)`n- Please don't use it in productive environments!" |
| 100 | + - name: Publish to Github packages |
| 101 | + run: dotnet nuget push "**/*.nupkg" --no-symbols --skip-duplicate --api-key $env:GH_PKG_SEC --source https://nuget.pkg.github.com/codebude/index.json |
| 102 | + |
| 103 | + |
| 104 | + clean: |
| 105 | + needs: [build, test, pack-push-ci] |
| 106 | + if: always() |
| 107 | + runs-on: windows-latest |
| 108 | + steps: |
| 109 | + - name: Delete artifacts |
| 110 | + |
| 111 | + with: |
| 112 | + name: Compiled project |
0 commit comments