|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +env: |
| 13 | + TERM: xterm |
| 14 | + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true |
| 15 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 16 | + DOTNET_NOLOGO: true |
| 17 | + MSBUILDTERMINALLOGGER: auto |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 30 |
| 23 | + outputs: |
| 24 | + version: ${{ steps.version.outputs.version }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Setup .NET Core |
| 33 | + uses: actions/setup-dotnet@v5 |
| 34 | + with: |
| 35 | + dotnet-version: | |
| 36 | + 8.0.x |
| 37 | + 9.0.x |
| 38 | + 10.0.x |
| 39 | +
|
| 40 | + - name: Version |
| 41 | + id: version |
| 42 | + run: | |
| 43 | + dotnet tool install --global minver-cli --version 7.0.0 |
| 44 | + version=$(minver --tag-prefix v) |
| 45 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 46 | + echo "MINVERVERSIONOVERRIDE=$version" >> $GITHUB_ENV |
| 47 | + echo "### Version: $version" >> $GITHUB_STEP_SUMMARY |
| 48 | +
|
| 49 | + - name: NuGet Restore |
| 50 | + run: dotnet restore Geocoding.slnx |
| 51 | + |
| 52 | + - name: Build |
| 53 | + run: dotnet build Geocoding.slnx --no-restore --configuration Release |
| 54 | + |
| 55 | + - name: Run Tests |
| 56 | + run: dotnet test --project test/Geocoding.Tests/Geocoding.Tests.csproj --no-build --configuration Release |
| 57 | + |
| 58 | + publish: |
| 59 | + if: github.event_name != 'pull_request' |
| 60 | + needs: build |
| 61 | + runs-on: ubuntu-latest |
| 62 | + timeout-minutes: 30 |
| 63 | + permissions: |
| 64 | + contents: read |
| 65 | + packages: write |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout |
| 69 | + uses: actions/checkout@v6 |
| 70 | + with: |
| 71 | + fetch-depth: 0 |
| 72 | + |
| 73 | + - name: Setup .NET Core |
| 74 | + uses: actions/setup-dotnet@v5 |
| 75 | + with: |
| 76 | + dotnet-version: | |
| 77 | + 8.0.x |
| 78 | + 9.0.x |
| 79 | + 10.0.x |
| 80 | +
|
| 81 | + - name: Set Version Override |
| 82 | + run: | |
| 83 | + echo "MINVERVERSIONOVERRIDE=${{ needs.build.outputs.version }}" >> $GITHUB_ENV |
| 84 | + echo "### Publish Version: ${{ needs.build.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 85 | +
|
| 86 | + - name: NuGet Restore |
| 87 | + run: dotnet restore Geocoding.slnx |
| 88 | + |
| 89 | + - name: Package |
| 90 | + run: dotnet pack Geocoding.slnx --no-restore --configuration Release |
| 91 | + |
| 92 | + - name: Publish CI Packages |
| 93 | + if: github.actor != 'dependabot[bot]' |
| 94 | + run: | |
| 95 | + for package in $(find . -name "*.nupkg" | grep -v "minver"); do |
| 96 | + if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then |
| 97 | + dotnet nuget push "$package" --source https://nuget.pkg.github.com/exceptionless/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate |
| 98 | + fi |
| 99 | +
|
| 100 | + if [ -n "${{ secrets.FEEDZ_KEY }}" ]; then |
| 101 | + dotnet nuget push "$package" --source https://f.feedz.io/exceptionless/geocoding/nuget --api-key ${{ secrets.FEEDZ_KEY }} --skip-duplicate |
| 102 | + fi |
| 103 | + done |
| 104 | +
|
| 105 | + - name: Publish Release Packages |
| 106 | + if: startsWith(github.ref, 'refs/tags/v') |
| 107 | + env: |
| 108 | + NUGET_KEY: ${{ secrets.NUGET_KEY }} |
| 109 | + run: | |
| 110 | + if [ -n "$NUGET_KEY" ]; then |
| 111 | + for package in $(find . -name "*.nupkg" | grep -v "minver"); do |
| 112 | + dotnet nuget push "$package" --source https://api.nuget.org/v3/index.json --api-key "$NUGET_KEY" --skip-duplicate |
| 113 | + done |
| 114 | + fi |
0 commit comments