|
| 1 | +name: Build Project |
| 2 | + |
| 3 | +env: |
| 4 | + BUILD_PATH: '${{github.workspace}}/artifacts' |
| 5 | + BUILD_VERSION: '10.1.${{github.run_number}}' |
| 6 | + BUILD_INFORMATION: '10.1.${{github.run_number}}+Branch.${{github.ref_name}}.Sha.${{github.sha}}' |
| 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 | + |
| 22 | + build: |
| 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: | |
| 35 | + 6.0.x |
| 36 | + 7.0.x |
| 37 | +
|
| 38 | + - name: Restore Dependencies |
| 39 | + run: dotnet restore |
| 40 | + |
| 41 | + - name: Build Solution |
| 42 | + run: 'dotnet build --no-restore --configuration Release -p:Version="${{env.BUILD_VERSION}}" -p:InformationalVersion="${{env.BUILD_INFORMATION}}"' |
| 43 | + |
| 44 | + - name: Run Test |
| 45 | + run: dotnet test --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings |
| 46 | + |
| 47 | + - name: Create Packages |
| 48 | + if: success() && github.event_name != 'pull_request' |
| 49 | + run: 'dotnet pack --configuration Release --include-symbols --include-source --no-build --no-restore --output "${{env.BUILD_PATH}}" -p:PackageVersion="${{env.BUILD_VERSION}}"' |
| 50 | + |
| 51 | + - name: Upload Packages |
| 52 | + if: success() && github.event_name != 'pull_request' |
| 53 | + uses: actions/upload-artifact@v3 |
| 54 | + with: |
| 55 | + name: packages |
| 56 | + path: '${{env.BUILD_PATH}}' |
| 57 | + |
| 58 | + - name: Publish Packages |
| 59 | + if: success() && github.event_name != 'pull_request' |
| 60 | + run: | |
| 61 | + dotnet nuget add source --username pwelter34 --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/loresoft/index.json" |
| 62 | + for package in $(find -name "*.nupkg"); do |
| 63 | + echo "${0##*/}": Pushing $package... |
| 64 | + dotnet nuget push $package --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate |
| 65 | + done |
| 66 | +
|
| 67 | + - name: Publish Release Packages |
| 68 | + if: success() && startsWith(github.ref, 'refs/tags/v') |
| 69 | + run: | |
| 70 | + for package in $(find -name "*.nupkg"); do |
| 71 | + echo "${0##*/}": Pushing $package... |
| 72 | + dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate |
| 73 | + done |
0 commit comments