Update .NET 8.0 image tag to 8.0-rc instead of 8.0-preview #131
This file contains 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-11, ubuntu-22.04, windows-latest] | |
name: ${{ matrix.runs-on }} | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET Core 8.0.x, 7.0.x, and 6.0.x | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x-x | |
- 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 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 6.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
id: meta60 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ secrets.DOCKER_HUB_REPOS }} | |
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
flavor: | | |
latest=auto | |
suffix=${{ env.TAG_SUFFIX }} | |
tags: | | |
type=raw,enable=${{ github.event_name != 'pull_request' }},priority=999,value=${{ steps.minver.outputs.version }} | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=900,pattern=^(\d+\.\d+(\.\d+)?(-.+)?)$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=880,pattern=^(\d+\.\d+(\.\d+)?)(-.+)?$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=870,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=860,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1 | |
type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,prefix=6.0-,value=${{ steps.minver.outputs.version }} | |
type=ref,event=branch,priority=500,prefix=6.0- | |
type=ref,event=pr,priority=500,prefix=6.0-pr- | |
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=6.0-sha-,format=short | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=600,prefix=6.0-,pattern=^(\d+\.\d+(\.\d+)?(-.+)?)$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=580,prefix=6.0-,pattern=^(\d+\.\d+(\.\d+)?)(-.+)?$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,prefix=6.0-,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1 | |
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,prefix=6.0-,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1 | |
- name: Docker meta 7.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
id: meta70 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ secrets.DOCKER_HUB_REPOS }} | |
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
flavor: | | |
latest=auto | |
suffix=${{ env.TAG_SUFFIX }} | |
prefix=7.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=7.0-pr- | |
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=7.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=580,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: Docker meta 8.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
id: meta80 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ secrets.DOCKER_HUB_REPOS }} | |
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
flavor: | | |
latest=auto | |
suffix=${{ env.TAG_SUFFIX }} | |
prefix=8.0-rc- | |
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=8.0-preview-pr- | |
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=8.0-preview-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=580,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 | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
- name: Test | |
run: dotnet test -c Release --no-build --verbosity normal | |
- name: Publish | |
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 | |
- 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 | |
- name: Enabling Docker Daemon With experimental features | |
if: ${{ success() && runner.os == 'Linux' }} | |
run: | | |
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' | |
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@v2 | |
- name: Login to Docker Hub | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and Push 6.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
shell: pwsh | |
run: ./docker-build.ps1 -Context ./artifacts/net6.0 -Squash -Tags "${{ steps.meta60.outputs.tags }}" -Labels "${{ steps.meta60.outputs.labels }}" | |
- name: Build and Push 7.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
shell: pwsh | |
run: | | |
$aspnetImageTag70 = if ($Env:RUNNER_OS -eq 'Linux') { '7.0-alpine' } else { '7.0-nanoserver-1809' } | |
./docker-build.ps1 -Context ./artifacts/net7.0 -Squash -Tags "${{ steps.meta70.outputs.tags }}" -Labels "${{ steps.meta70.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag70" | |
- name: Build and Push 8.0 | |
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }} | |
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" |