Update release.yml #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| name: Verify Install | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| DOTNET_ROLL_FORWARD: Major | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0 | |
| - name: Restore tools | |
| run: dotnet tool restore | |
| - name: Begin Sonar scan | |
| if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' | |
| run: dotnet sonarscanner begin /o:"kaliumhexacyanoferrat" /k:"Kaliumhexacyanoferrat_GenHTTP.Templates" /d:sonar.token="$SONAR_TOKEN" /d:sonar.exclusions="**/bin/**/*,**/obj/**/*" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.branch.name="${GITHUB_REF##*/}" | |
| - name: Build templates project | |
| run: dotnet build GenHTTP.Templates.csproj -c Release | |
| - name: End Sonar scan | |
| if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' | |
| run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" | |
| - name: Install templates | |
| run: dotnet new install . | |
| try-templates: | |
| name: Try ${{ matrix.template.name }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| matrix: | |
| template: | |
| - { name: "webservice", short: "webservice", folder: "webservice", tag: "webservice" } | |
| - { name: "webservice-controllers", short: "controllers", folder: "controllers", tag: "controllers" } | |
| - { name: "webservice-minimal", short: "minimal", folder: "minimal", tag: "minimal" } | |
| - { name: "website-static", short: "website", folder: "website", tag: "website" } | |
| - { name: "websocket", short: "websockets", folder: "websockets", tag: "websocket" } | |
| - { name: "sse", short: "sse", folder: "sse", tag: "sse" } | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0 | |
| - name: Restore tools | |
| run: dotnet tool restore | |
| - name: Install templates | |
| run: dotnet new install . | |
| - name: Create and test ${{ matrix.template.name }} project | |
| run: | | |
| mkdir -p /tmp/genhttp/${{ matrix.template.folder }}/ | |
| cd /tmp/genhttp/${{ matrix.template.folder }}/ | |
| dotnet new genhttp-${{ matrix.template.name }} | |
| if [ -d "${{ matrix.template.short }}.Tests" ]; then | |
| cd ${{ matrix.template.short }}.Tests | |
| dotnet test | |
| cd .. | |
| fi | |
| rm -rf ./${{ matrix.template.short }}/bin/ | |
| rm -rf ./${{ matrix.template.short }}/obj/ | |
| docker build -t ${{ matrix.template.tag }} . | |