Skip to content

Commit a6132ee

Browse files
committed
ci: add ability to specify next .NET version for update-dockerfiles workflow
1 parent f188153 commit a6132ee

File tree

2 files changed

+21
-38
lines changed

2 files changed

+21
-38
lines changed

.github/workflows/update-Dockerfiles.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
type: boolean
1515
required: true
1616
default: "true"
17+
NET_6_NEXT_VERSION:
18+
description: ".NET 6 Next Version"
19+
type: string
20+
required: true
1721
NET_7_AMD64:
1822
description: ".NET 7 AMD64"
1923
type: boolean
@@ -24,6 +28,10 @@ on:
2428
type: boolean
2529
required: true
2630
default: "true"
31+
NET_7_NEXT_VERSION:
32+
description: ".NET 7 Next Version"
33+
type: string
34+
required: true
2735

2836
jobs:
2937
build:
@@ -43,28 +51,28 @@ jobs:
4351
id: update-net6-amd64
4452
shell: pwsh
4553
run: |
46-
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -Dockerfile ${{ env.NET_6_AMD64_Dockerfile }}
54+
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -DockerfilePath ${{ env.NET_6_AMD64_Dockerfile }} -NextVersion ${{ github.event.inputs.NET_6_NEXT_VERSION }}
4755
if: ${{ github.event.inputs.NET_6_AMD64 == 'true' }}
4856

4957
- name: Update .NET 6 ARM64
5058
id: update-net6-arm64
5159
shell: pwsh
5260
run: |
53-
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -Dockerfile ${{ env.NET_6_ARM64_Dockerfile }}
61+
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -DockerfilePath ${{ env.NET_6_ARM64_Dockerfile }} -NextVersion ${{ github.event.inputs.NET_6_NEXT_VERSION }}
5462
if: ${{ github.event.inputs.NET_6_ARM64 == 'true' }}
5563

5664
- name: Update .NET 7 AMD64
5765
id: update-net7-amd64
5866
shell: pwsh
5967
run: |
60-
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -Dockerfile ${{ env.NET_7_AMD64_Dockerfile }}
68+
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -DockerfilePath ${{ env.NET_7_AMD64_Dockerfile }} -NextVersion ${{ github.event.inputs.NET_7_NEXT_VERSION }}
6169
if: ${{ github.event.inputs.NET_7_AMD64 == 'true' }}
6270

6371
- name: Update .NET 7 ARM64
6472
id: update-net7-arm64
6573
shell: pwsh
6674
run: |
67-
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -Dockerfile ${{ env.NET_7_ARM64_Dockerfile }}
75+
.\LambdaRuntimeDockerfiles/update-dockerfile.ps1 -DockerfilePath ${{ env.NET_7_ARM64_Dockerfile }} -NextVersion ${{ github.event.inputs.NET_7_NEXT_VERSION }}
6876
if: ${{ github.event.inputs.NET_7_ARM64 == 'true' }}
6977

7078
# Update Dockerfiles if newer version of ASP.NET Core is available

LambdaRuntimeDockerfiles/update-dockerfile.ps1

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,31 @@
44
# NOTE: This scripts only updates patch version by incrementing the next patch version.
55
# If Microsoft ever releases a minor version, this needs to updated accordingly to include minor version.
66

7-
param ([Parameter(Mandatory)]$DockerfilePath)
7+
param ([Parameter(Mandatory)]$DockerfilePath, [Parameter(Mandatory)]$NextVersion)
88

99
# Updates the Dockerfile with next ASP.NET Core version and checksum512 hash if available
10-
function Update-Dockerfile ([string]$DockerfilePath) {
10+
function Update-Dockerfile ([string]$DockerfilePath, [string]$NextVersion) {
1111
Write-Host "Updating $DockerfilePath with next ASP.NET Core version"
1212

13-
$nextVersion = Get-NextASPNETVersion -DockerfilePath $DockerfilePath
13+
$checksumFilePath = "${NextVersion}-checksum.txt"
1414

15-
$checksumFilePath = "${nextVersion}-checksum.txt"
16-
17-
$checksumUri = "https://dotnetcli.blob.core.windows.net/dotnet/checksums/${nextVersion}-sha.txt"
15+
$checksumUri = "https://dotnetcli.blob.core.windows.net/dotnet/checksums/${NextVersion}-sha.txt"
1816
Write-Host "Downloading checksums from $checksumUri"
1917

2018
Invoke-WebRequest -Uri $checksumUri -OutFile $checksumFilePath
2119

2220
$arch = Get-Architecture -DockerfilePath $DockerfilePath
2321

24-
$artifact = "aspnetcore-runtime-${nextVersion}-linux-${arch}.tar.gz"
22+
$artifact = "aspnetcore-runtime-${NextVersion}-linux-${arch}.tar.gz"
2523
$checksum = Get-Checksum -Artifact $artifact -DockerfilePath $checksumFilePath
2624

27-
(Get-Content $DockerfilePath) -replace 'ARG ASPNET_VERSION=.*', "ARG ASPNET_VERSION=${nextVersion}" -replace 'ARG ASPNET_SHA512=.*', "ARG ASPNET_SHA512=${checksum}" | Out-File $DockerfilePath
25+
(Get-Content $DockerfilePath) -replace 'ARG ASPNET_VERSION=.*', "ARG ASPNET_VERSION=${NextVersion}" -replace 'ARG ASPNET_SHA512=.*', "ARG ASPNET_SHA512=${checksum}" | Out-File $DockerfilePath
2826

29-
Write-Host "Updated ${DockerfilePath} to ${nextVersion}."
27+
Write-Host "Updated ${DockerfilePath} to ${NextVersion}."
3028

3129
# This allows checksumring the $DockerfilePath variable between steps
3230
# which is needed to update the description of the PR
33-
Write-Host "::set-output name=${DockerfilePath}::- Updated ${DockerfilePath} to ${nextVersion}<br> - Artifact: ${artifact}<br> - Checksum Source: ${checksumUri}"
31+
Write-Host "::set-output name=${DockerfilePath}::- Updated ${DockerfilePath} to ${NextVersion}<br> - Artifact: ${artifact}<br> - Checksum Source: ${checksumUri}"
3432
}
3533

3634
# Returns Checksum of given ASP.NET Core version from the give Checksum file
@@ -53,27 +51,4 @@ function Get-Architecture ([string]$DockerfilePath) {
5351
}
5452
}
5553

56-
# Returns the next ASP.NET version to be updated in the Dockerfile
57-
function Get-NextASPNETVersion ([string]$DockerfilePath) {
58-
$line = Select-String -Path $DockerfilePath -Pattern "ARG ASPNET_VERSION=" | Select-Object -Property Line -ExpandProperty Line
59-
$currentVersion = $line.Split("=")[1]
60-
Write-Host "Current ASPNET version: ${currentVersion}"
61-
62-
$nextVersion = Update-PatchVersion -Version $currentVersion
63-
Write-Host "Next ASPNET version: ${nextVersion}"
64-
65-
return $nextVersion
66-
}
67-
68-
# Returns the next patch version of the given version
69-
function Update-PatchVersion ([string]$version) {
70-
$components = $version.Split(".");
71-
$major = $components[0];
72-
$minor = $components[1];
73-
$patch = $components[2];
74-
$patch = [int]$patch + 1;
75-
$newVersion = $major + "." + $minor + "." + $patch;
76-
return $newVersion;
77-
}
78-
79-
Update-Dockerfile $DockerfilePath
54+
Update-Dockerfile $DockerfilePath $NextVersion

0 commit comments

Comments
 (0)