Update Test Package List #288
Workflow file for this run
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: ASP.NET Core | |
| on: | |
| push: | |
| branches: ["main", "dev*"] | |
| tags: ["*.*.*"] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| #runs-on: [macos-latest, ubuntu-22.04, windows-latest] disable | |
| runs-on: [ubuntu-latest, windows-latest] | |
| name: ${{ matrix.runs-on }} | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET 9.0.x, 8.0.x, 7.0.x and 6.0.x | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| 7.0.x | |
| 8.0.x | |
| 9.0.x | |
| - name: Setup .NET 10.0.x RC | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| dotnet-quality: "preview" | |
| - name: dotnet info | |
| run: dotnet --info | |
| - name: Install dotnet tool | |
| run: dotnet tool restore | |
| - name: MinVer | |
| shell: pwsh | |
| id: minver | |
| run: Write-Output "version=$(dotnet minver)" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| - name: Set UI Version | |
| shell: pwsh | |
| run: | | |
| $version = "$(dotnet minver)+$($Env:GITHUB_SHA.SubString(0,7))" | |
| $substitutionVersion = '${1} ' + $version | |
| $versionFilePath = 'src/WebApp/wwwroot/.version' | |
| $content = (Get-Content $versionFilePath -ErrorAction Stop) -replace '^(version:).*$', $substitutionVersion | |
| $substitutionBuildTime = '${1} ' + $(Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffZ') | |
| $content = $content -replace '^(buildTime:).*$', $substitutionBuildTime | |
| Set-Content -Path $versionFilePath -Value $content -ErrorAction Stop | |
| Write-Output "`n<!-- Build commit $($Env:GITHUB_SHA) / $($Env:GITHUB_REF_NAME) at $($(Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffZ')) -->" | Out-File -FilePath src/WebApp/wwwroot/index.html -Encoding utf8 -Append | |
| - name: Set Docker tag suffix | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| shell: pwsh | |
| run: | | |
| $tagSuffix = if ($Env:RUNNER_OS -eq 'Linux') { '-alpine' } else { if ($Env:RUNNER_OS -eq 'Windows') { '-nanoserver-1809' } } | |
| Write-Output "TAG_SUFFIX=$tagSuffix" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | |
| Write-Host "Set tag suffix to: $tagSuffix" | |
| - name: Docker meta 8.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta80 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_REPOS }} | |
| name=netlah/spa-host,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| suffix=-8.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Docker meta sample 8.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta_sample80 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_SAMPLE_REPOS }} | |
| name=netlah/spa-host-sample,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| suffix=-8.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Docker meta 9.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta90 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_REPOS }} | |
| name=netlah/spa-host,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=${{ runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') }} | |
| suffix=-9.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Docker meta sample 9.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta_sample90 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_SAMPLE_REPOS }} | |
| name=netlah/spa-host-sample,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=${{ runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') }} | |
| suffix=-9.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Docker meta 10.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta100 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_REPOS }} | |
| name=netlah/spa-host,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| suffix=-10.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Docker meta sample 10.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: meta_sample100 | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKER_HUB_SAMPLE_REPOS }} | |
| name=netlah/spa-host-sample,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| suffix=-10.0${{ env.TAG_SUFFIX }} | |
| prefix= | |
| tags: | | |
| type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }} | |
| type=ref,event=branch,priority=500 | |
| type=ref,event=pr,priority=500,prefix=pr- | |
| type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=sha-,format=short | |
| type=semver,enable=true,priority=600,pattern={{version}} | |
| type=semver,enable=true,priority=580,pattern={{major}}.{{minor}}.{{patch}} | |
| type=semver,enable=true,priority=570,pattern={{major}}.{{minor}} | |
| type=semver,enable=true,priority=560,pattern={{major}} | |
| - name: Install dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test | |
| run: dotnet test -c Release --no-build --verbosity normal | |
| - name: Generate package information | |
| run: | | |
| dotnet package list --project src/Hosting --include-transitive > src/WebApp/wwwroot/.package-hosting.txt | |
| dotnet package list --project src/Hosting --framework net8.0 --include-transitive > src/WebApp/wwwroot/.package-net8.0-hosting.txt | |
| dotnet package list --project src/Hosting --framework net9.0 --include-transitive > src/WebApp/wwwroot/.package-net9.0-hosting.txt | |
| dotnet package list --project src/Hosting --framework net10.0 --include-transitive > src/WebApp/wwwroot/.package-net10.0-hosting.txt | |
| dotnet package list --project src/Hosting --deprecated --include-transitive > src/WebApp/wwwroot/.package-hosting-deprecated.txt | |
| dotnet package list --project src/Hosting --outdated --include-transitive > src/WebApp/wwwroot/.package-hosting-outdated.txt | |
| dotnet package list --project src/Hosting --vulnerable --include-transitive > src/WebApp/wwwroot/.package-hosting-vulnerable.txt | |
| dotnet package list --project src/WebApp --include-transitive > src/WebApp/wwwroot/.package-webapp.txt | |
| dotnet package list --project src/WebApp --framework net8.0 --include-transitive > src/WebApp/wwwroot/.package-net8.0-webapp.txt | |
| dotnet package list --project src/WebApp --framework net9.0 --include-transitive > src/WebApp/wwwroot/.package-net9.0-webapp.txt | |
| dotnet package list --project src/WebApp --framework net10.0 --include-transitive > src/WebApp/wwwroot/.package-net10.0-webapp.txt | |
| dotnet package list --project src/WebApp --deprecated --include-transitive > src/WebApp/wwwroot/.package-webapp-deprecated.txt | |
| dotnet package list --project src/WebApp --framework net8.0 --deprecated --include-transitive > src/WebApp/wwwroot/.package-net8.0-webapp-deprecated.txt | |
| dotnet package list --project src/WebApp --framework net9.0 --deprecated --include-transitive > src/WebApp/wwwroot/.package-net9.0-webapp-deprecated.txt | |
| dotnet package list --project src/WebApp --framework net10.0 --deprecated --include-transitive > src/WebApp/wwwroot/.package-net10.0-webapp-deprecated.txt | |
| dotnet package list --project src/WebApp --outdated --include-transitive > src/WebApp/wwwroot/.package-webapp-outdated.txt | |
| dotnet package list --project src/WebApp --framework net8.0 --outdated --include-transitive > src/WebApp/wwwroot/.package-net8.0-webapp-outdated.txt | |
| dotnet package list --project src/WebApp --framework net9.0 --outdated --include-transitive > src/WebApp/wwwroot/.package-net9.0-webapp-outdated.txt | |
| dotnet package list --project src/WebApp --framework net10.0 --outdated --include-transitive > src/WebApp/wwwroot/.package-net10.0-webapp-outdated.txt | |
| dotnet package list --project src/WebApp --vulnerable --include-transitive > src/WebApp/wwwroot/.package-webapp-vulnerable.txt | |
| - name: Publish | |
| shell: pwsh | |
| run: | | |
| foreach ($framework in @('net8.0', 'net9.0', 'net10.0')) { | |
| dotnet publish src/WebApp -c Release -f $framework --no-build -o "artifacts/$($framework)/app" | |
| Copy-Item -Force -Path shared/appsettings.Development.json -Destination "artifacts/$($framework)/app/" -ErrorAction Stop -Verbose | |
| } | |
| - name: Split sample wwwroot | |
| shell: pwsh | |
| run: | | |
| foreach ($framework in @('net8.0', 'net9.0', 'net10.0')) { | |
| $webFolder = New-Item -Name "artifacts/$($framework)/wwwroot" -ItemType 'Directory' -ErrorAction Stop | |
| Move-Item -Force -Path "artifacts/$($framework)/app/wwwroot/*" -Destination "$webFolder/" -Exclude favicon.ico -ErrorAction Stop -Verbose | |
| } | |
| - name: Copy Dockerfile | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| shell: pwsh | |
| run: | | |
| foreach ($framework in @('net8.0', 'net9.0', 'net10.0')) { | |
| Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination "artifacts/$($framework)/" -ErrorAction Stop -Verbose | |
| } | |
| - name: Enabling Docker Daemon With experimental features | |
| if: ${{ success() && runner.os == 'Linux' }} | |
| shell: pwsh | |
| run: | | |
| if(Test-Path /etc/docker/daemon.json -PathType Leaf -ErrorAction SilentlyContinue) { | |
| echo 'Before update daemon.json' | |
| sudo cat /etc/docker/daemon.json | |
| sudo bash -c 'echo "{ "\""exec-opts"\"": ["\""native.cgroupdriver=cgroupfs"\""], "\""cgroup-parent"\"": "\""/actions_job"\"", "\""experimental"\"": true }" > /etc/docker/daemon.json' | |
| } else { | |
| sudo bash -c 'echo "{ "\""experimental"\"": true }" > /etc/docker/daemon.json' | |
| } | |
| echo 'After update daemon.json' | |
| sudo cat /etc/docker/daemon.json | |
| sudo systemctl restart docker.service | |
| - name: Set up Docker Buildx | |
| if: ${{ success() && (runner.os == 'Linux') }} | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build and Push 8.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: build80 | |
| shell: pwsh | |
| run: | | |
| $aspnetImageTag80 = if ($Env:RUNNER_OS -eq 'Linux') { '8.0-alpine' } else { '8.0-nanoserver-1809' } | |
| ./docker-build.ps1 -Context ./artifacts/net8.0 -Squash -Tags "${{ steps.meta80.outputs.tags }}" -Labels "${{ steps.meta80.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag80" | |
| - name: Build and Push Sample 8.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| shell: pwsh | |
| run: ./docker-build.ps1 -Context ./artifacts/net8.0 -NoPull -Dockerfile ./artifacts/net8.0/Dockerfile-sample -Tags "${{ steps.meta_sample80.outputs.tags }}" -Labels "${{ steps.meta_sample80.outputs.labels }}" -BuildArgs "SPAHOST_IMAGE=$Env:SPAHOST_IMAGE" | |
| env: | |
| SPAHOST_IMAGE: ${{ steps.build80.outputs.image }} | |
| - name: Build and Push 9.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: build90 | |
| shell: pwsh | |
| run: | | |
| $aspnetImageTag90 = if ($Env:RUNNER_OS -eq 'Linux') { '9.0-alpine' } else { '9.0-nanoserver-1809' } | |
| ./docker-build.ps1 -Context ./artifacts/net9.0 -Squash -Tags "${{ steps.meta90.outputs.tags }}" -Labels "${{ steps.meta90.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag90" | |
| - name: Build and Push Sample 9.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| shell: pwsh | |
| run: ./docker-build.ps1 -Context ./artifacts/net9.0 -NoPull -Dockerfile ./artifacts/net9.0/Dockerfile-sample -Tags "${{ steps.meta_sample90.outputs.tags }}" -Labels "${{ steps.meta_sample90.outputs.labels }}" -BuildArgs "SPAHOST_IMAGE=$Env:SPAHOST_IMAGE" | |
| env: | |
| SPAHOST_IMAGE: ${{ steps.build90.outputs.image }} | |
| - name: Build and Push 10.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| id: build100 | |
| shell: pwsh | |
| run: | | |
| $aspnetImageTag100 = if ($Env:RUNNER_OS -eq 'Linux') { '10.0-alpine' } else { '10.0-nanoserver-1809' } | |
| $aspnetImageRepo100 = if ($Env:RUNNER_OS -eq 'Linux') { 'netlah/aspnet-webssh' } else { 'netlah/dotnet-aspnet' } | |
| ./docker-build.ps1 -Context ./artifacts/net10.0 -Squash -Tags "${{ steps.meta100.outputs.tags }}" -Labels "${{ steps.meta100.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag100`nASPNET_IMAGE_REPO=$aspnetImageRepo100" | |
| - name: Build and Push Sample 10.0 | |
| if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
| shell: pwsh | |
| run: ./docker-build.ps1 -Context ./artifacts/net10.0 -NoPull -Dockerfile ./artifacts/net10.0/Dockerfile-sample -Tags "${{ steps.meta_sample100.outputs.tags }}" -Labels "${{ steps.meta_sample100.outputs.labels }}" -BuildArgs "SPAHOST_IMAGE=$Env:SPAHOST_IMAGE" | |
| env: | |
| SPAHOST_IMAGE: ${{ steps.build100.outputs.image }} | |
| - name: Pack | |
| run: dotnet pack src/Hosting/Hosting.csproj -c Release -o ./artifacts/packages/ --no-build --verbosity normal | |
| - name: Upload artifacts | |
| if: ${{ success() && runner.os == 'Windows' && github.event_name == 'push' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: NetLah.SpaServices | |
| path: artifacts/packages | |
| - if: ${{ success() && runner.os == 'Windows' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} | |
| name: Push MyGet, CloudSmith and GitHub registry | |
| run: | | |
| dotnet nuget push .\artifacts\packages\*.nupkg -s https://www.myget.org/F/netlah/api/v2/package -k ${{ secrets.MYGET }} | |
| dotnet nuget push .\artifacts\packages\*.nupkg -s https://nuget.pkg.github.com/NetLah/index.json --skip-duplicate -k ${{ secrets.PUSH_GITHUB_REGISTRY_TOKEN }} | |
| dotnet nuget push .\artifacts\packages\*.nupkg -s https://nuget.cloudsmith.io/netlah/net-main1/v3/index.json --skip-duplicate -k ${{ secrets.PUSH_CLOUDSMITH_TOKEN }} | |
| - name: Push CloudSmith and GitHub registry dev | |
| if: ${{ success() && runner.os == 'Windows' && (startsWith(github.ref, 'refs/heads/dev')) }} | |
| run: | | |
| dotnet nuget push .\artifacts\packages\*.nupkg -s https://nuget.pkg.github.com/NetLah/index.json --skip-duplicate -k ${{ secrets.PUSH_GITHUB_REGISTRY_TOKEN }} | |
| dotnet nuget push .\artifacts\packages\*.nupkg -s https://nuget.cloudsmith.io/netlah/net-dev1/v3/index.json --skip-duplicate -k ${{ secrets.PUSH_CLOUDSMITH_TOKEN }} |