|
| 1 | +name: Build Project |
| 2 | + |
| 3 | +env: |
| 4 | + DOTNET_NOLOGO: true |
| 5 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 6 | + BUILD_PATH: '${{github.workspace}}/artifacts' |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - develop |
| 13 | + tags: |
| 14 | + - 'v*' |
| 15 | + pull_request: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + - develop |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Install .NET Core |
| 32 | + uses: actions/setup-dotnet@v3 |
| 33 | + with: |
| 34 | + dotnet-version: 7.0.x |
| 35 | + |
| 36 | + - name: Calculate Version |
| 37 | + run: | |
| 38 | + dotnet tool update -g minver-cli |
| 39 | + echo "BUILD_VERSION=$(minver -v e -t v)" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + - name: Restore Dependencies |
| 42 | + run: dotnet restore |
| 43 | + |
| 44 | + - name: Build Solution |
| 45 | + run: 'dotnet build --no-restore --configuration Release -p:Version="${{env.BUILD_VERSION}}" -p:InformationalVersion="${{env.BUILD_VERSION}}+${{github.sha}}"' |
| 46 | + |
| 47 | + - name: Run Test |
| 48 | + run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings |
| 49 | + |
| 50 | + - name: Generate Coverage |
| 51 | + uses: danielpalme/[email protected] |
| 52 | + with: |
| 53 | + reports: '${{github.workspace}}/test/*/TestResults/*/coverage.info' |
| 54 | + targetdir: ${{env.BUILD_PATH}} |
| 55 | + reporttypes: lcov |
| 56 | + |
| 57 | + - name: Report Coverage |
| 58 | + if: success() |
| 59 | + uses: coverallsapp/github-action@v2 |
| 60 | + with: |
| 61 | + file: artifacts/lcov.info |
| 62 | + format: lcov |
| 63 | + |
| 64 | + - name: Create Packages |
| 65 | + if: success() && github.event_name != 'pull_request' |
| 66 | + run: dotnet pack --configuration Release --include-symbols --include-source --no-build --no-restore --output "${{env.BUILD_PATH}}" |
| 67 | + |
| 68 | + - name: Upload Packages |
| 69 | + if: success() && github.event_name != 'pull_request' |
| 70 | + uses: actions/upload-artifact@v3 |
| 71 | + with: |
| 72 | + name: packages |
| 73 | + path: '${{env.BUILD_PATH}}' |
| 74 | + |
| 75 | + deploy: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: build |
| 78 | + if: success() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Download Artifact |
| 82 | + uses: actions/download-artifact@v3 |
| 83 | + with: |
| 84 | + name: packages |
| 85 | + |
| 86 | + - name: Publish Packages GitHub |
| 87 | + run: | |
| 88 | + for package in $(find -name "*.nupkg"); do |
| 89 | + echo "${0##*/}": Pushing $package... |
| 90 | + dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate |
| 91 | + done |
| 92 | +
|
| 93 | + - name: Publish Packages feedz |
| 94 | + run: | |
| 95 | + for package in $(find -name "*.nupkg"); do |
| 96 | + echo "${0##*/}": Pushing $package... |
| 97 | + dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate |
| 98 | + done |
| 99 | +
|
| 100 | + - name: Publish Packages Nuget |
| 101 | + if: startsWith(github.ref, 'refs/tags/v') |
| 102 | + run: | |
| 103 | + for package in $(find -name "*.nupkg"); do |
| 104 | + echo "${0##*/}": Pushing $package... |
| 105 | + dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate |
| 106 | + done |
| 107 | +
|
0 commit comments