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.
3
3
# 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.
6
4
7
- param ([Parameter (Mandatory )]$DockerfilePath )
5
+ param ([Parameter (Mandatory )]$DockerfilePath , [ Parameter ( Mandatory )] $NextVersion )
8
6
9
7
# 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 ) {
11
9
Write-Host " Updating $DockerfilePath with next ASP.NET Core version"
12
10
13
- $nextVersion = Get-NextASPNETVersion - DockerfilePath $DockerfilePath
11
+ $checksumFilePath = " ${NextVersion} -checksum.txt "
14
12
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"
18
14
Write-Host " Downloading checksums from $checksumUri "
19
15
20
16
Invoke-WebRequest - Uri $checksumUri - OutFile $checksumFilePath
21
17
22
18
$arch = Get-Architecture - DockerfilePath $DockerfilePath
23
19
24
- $artifact = " aspnetcore-runtime-${nextVersion } -linux-${arch} .tar.gz"
20
+ $artifact = " aspnetcore-runtime-${NextVersion } -linux-${arch} .tar.gz"
25
21
$checksum = Get-Checksum - Artifact $artifact - DockerfilePath $checksumFilePath
26
22
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
28
24
29
- Write-Host " Updated ${DockerfilePath} to ${nextVersion } ."
25
+ Write-Host " Updated ${DockerfilePath} to ${NextVersion } ."
30
26
31
27
# This allows checksumring the $DockerfilePath variable between steps
32
28
# 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} "
34
30
}
35
31
36
32
# Returns Checksum of given ASP.NET Core version from the give Checksum file
@@ -53,27 +49,4 @@ function Get-Architecture ([string]$DockerfilePath) {
53
49
}
54
50
}
55
51
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