Skip to content

Commit 4dcf5cf

Browse files
authored
Merge pull request #1529 from aws/asmarp/specify-next-version-dockerfiles
ci: add ability to specify next .NET version for update-dockerfiles workflow
2 parents f188153 + f16bfb9 commit 4dcf5cf

File tree

2 files changed

+24
-43
lines changed

2 files changed

+24
-43
lines changed

.github/workflows/update-Dockerfiles.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Dockerfiles
1+
name: Update Lambda Dockerfiles
22

33
on:
44
# Allows to run this workflow manually from the Actions tab
@@ -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
Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
# This script allows to update Dockerfiles with next ASP.NET Core patch version.
2-
# It greps the current version from Dockerfile, increment the patch version and fetches checksum file from Microsoft server.
1+
# This script allows to update Dockerfiles to the next ASP.NET Core version.
2+
# It fetches the checksum file of the next .NET version from Microsoft server.
33
# If checksum file is available, it will update the Dockerfile next version and its checksum.
4-
# NOTE: This scripts only updates patch version by incrementing the next patch version.
5-
# If Microsoft ever releases a minor version, this needs to updated accordingly to include minor version.
64

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

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

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

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

2016
Invoke-WebRequest -Uri $checksumUri -OutFile $checksumFilePath
2117

2218
$arch = Get-Architecture -DockerfilePath $DockerfilePath
2319

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

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

29-
Write-Host "Updated ${DockerfilePath} to ${nextVersion}."
25+
Write-Host "Updated ${DockerfilePath} to ${NextVersion}."
3026

3127
# This allows checksumring the $DockerfilePath variable between steps
3228
# 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}"
29+
Write-Host "::set-output name=${DockerfilePath}::- Updated ${DockerfilePath} to ${NextVersion}<br> - Artifact: ${artifact}<br> - Checksum Source: ${checksumUri}"
3430
}
3531

3632
# Returns Checksum of given ASP.NET Core version from the give Checksum file
@@ -53,27 +49,4 @@ function Get-Architecture ([string]$DockerfilePath) {
5349
}
5450
}
5551

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
52+
Update-Dockerfile $DockerfilePath $NextVersion

0 commit comments

Comments
 (0)