From 2e1f67fed643264694f4385f41a5730dee1f3c99 Mon Sep 17 00:00:00 2001 From: Tho Ho Date: Fri, 22 Mar 2024 18:27:14 +0800 Subject: [PATCH] Add .NET 9.0 --- .github/workflows/aspnet-core.yml | 64 ++++++++++++++++++++++------ Common.props | 20 ++++++++- Directory.Build.override.targets | 3 +- Directory.Build.targets | 27 +++++++----- EchoServiceApi/EchoServiceApi.csproj | 8 ++-- 5 files changed, 90 insertions(+), 32 deletions(-) diff --git a/.github/workflows/aspnet-core.yml b/.github/workflows/aspnet-core.yml index 65446a0..3224a63 100644 --- a/.github/workflows/aspnet-core.yml +++ b/.github/workflows/aspnet-core.yml @@ -16,18 +16,24 @@ jobs: name: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup .NET Core 8.0.x, 7.0.x, and 6.0.x - uses: actions/setup-dotnet@v3 + - name: Setup .NET 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 + - name: Setup .NET 9.0.x Preview + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + dotnet-quality: "preview" + - name: dotnet info run: dotnet --info @@ -50,7 +56,7 @@ jobs: - name: Docker meta 6.0 if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} id: meta60 - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: | ${{ secrets.DOCKER_HUB_REPOS }} @@ -76,7 +82,7 @@ jobs: - name: Docker meta 7.0 if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} id: meta70 - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: | ${{ secrets.DOCKER_HUB_REPOS }} @@ -98,7 +104,7 @@ jobs: - name: Docker meta 8.0 if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} id: meta80 - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: | ${{ secrets.DOCKER_HUB_REPOS }} @@ -117,6 +123,28 @@ jobs: type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1 type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1 + - 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 }} + netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }} + flavor: | + latest=auto + suffix=${{ env.TAG_SUFFIX }} + prefix=9.0- + 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=9.0-pr- + type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=9.0-sha-,format=short + type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=600,pattern=^(\d+\.\d+(\.\d+)?(-.+)?)$,group=1 + type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=590,pattern=^(\d+\.\d+(\.\d+)?)(-.+)?$,group=1 + type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1 + type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1 + - name: Install dependencies run: dotnet restore @@ -127,18 +155,19 @@ jobs: run: dotnet test -c Release --no-build --verbosity normal - name: Publish + shell: pwsh run: | - dotnet publish EchoServiceApi -c Release -f net6.0 --no-build -o artifacts/net6.0/app - dotnet publish EchoServiceApi -c Release -f net7.0 --no-build -o artifacts/net7.0/app - dotnet publish EchoServiceApi -c Release -f net8.0 --no-build -o artifacts/net8.0/app + foreach ($framework in @('net6.0', 'net7.0', 'net8.0', 'net9.0')) { + dotnet publish EchoServiceApi -c Release -f $framework --no-build -o "artifacts/$($framework)/app" + } - name: Copy Dockerfile if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} shell: pwsh run: | - Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net6.0/ -ErrorAction Stop -Verbose - Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net7.0/ -ErrorAction Stop -Verbose - Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net8.0/ -ErrorAction Stop -Verbose + foreach ($framework in @('net6.0', 'net7.0', 'net8.0', 'net9.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' }} @@ -152,11 +181,11 @@ jobs: - name: Set up Docker Buildx if: ${{ success() && (runner.os == 'Linux') }} - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -179,3 +208,10 @@ jobs: 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 9.0 + if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} + shell: pwsh + run: | + $aspnetImageTag90 = if ($Env:RUNNER_OS -eq 'Linux') { '9.0-alpine' } else { '9.0-preview-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" diff --git a/Common.props b/Common.props index 4c62c09..20c33a4 100644 --- a/Common.props +++ b/Common.props @@ -1,7 +1,7 @@ - 6.0.26;7.0.15;8.0.1 + 6.0.28;7.0.17;8.0.3 True $([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework))) @@ -31,38 +31,54 @@ True False + False False + False False False False False False False + False + False True + True True + True True True True True True True - + True + True + False + False False + False False False False False False False + False + False True + True True + True True True True True True True + True + True diff --git a/Directory.Build.override.targets b/Directory.Build.override.targets index c99c11f..58feb35 100644 --- a/Directory.Build.override.targets +++ b/Directory.Build.override.targets @@ -1,7 +1,6 @@ - - + diff --git a/Directory.Build.targets b/Directory.Build.targets index 4251110..1f072aa 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -5,13 +5,13 @@ - 9.*-* + 10.*-* - 3.* - 5.* - 8.* + 7.* + 8.* + 9.*-* $(LatestDevFrameworkVersion) @@ -21,6 +21,7 @@ 6.* 7.* 8.* + 9.*-* $(LatestDevFrameworkVersion) @@ -28,13 +29,18 @@ 5.* 7.* 8.* + 9.*-* $(LatestDevFrameworkVersion) + 4.* + 8.* + $(EFCoreFrameworkVersion) 8.* $(FrameworkVersion) - 6.3.* + + 6.3.1 6.4.* 6.* @@ -86,8 +92,8 @@ - - + + @@ -271,8 +277,9 @@ - - + + + @@ -387,7 +394,7 @@ - + diff --git a/EchoServiceApi/EchoServiceApi.csproj b/EchoServiceApi/EchoServiceApi.csproj index 1d0ef6b..fbd0a33 100644 --- a/EchoServiceApi/EchoServiceApi.csproj +++ b/EchoServiceApi/EchoServiceApi.csproj @@ -1,7 +1,7 @@  - net8.0;net7.0;net6.0 + net9.0;net8.0;net7.0;net6.0 netlah-echoserviceapi-bf38 Linux @@ -13,7 +13,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -162,7 +162,7 @@ - +