diff --git a/.github/workflows/auto-update-Dockerfiles.yml b/.github/workflows/auto-update-Dockerfiles.yml new file mode 100644 index 000000000..f7331f976 --- /dev/null +++ b/.github/workflows/auto-update-Dockerfiles.yml @@ -0,0 +1,195 @@ +name: Auto-Update Lambda Dockerfiles Monthly + +permissions: + contents: write + pull-requests: write + +on: + # Run monthly on the 1st day of each month at midnight UTC + schedule: + - cron: '0 0 1 * *' + # Allows to run this workflow manually from the Actions tab for testing + workflow_dispatch: + + + +jobs: + auto-update: + runs-on: ubuntu-latest + env: + NET_8_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile" + NET_8_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile" + NET_9_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile" + NET_9_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile" + NET_10_AMD64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile" + NET_10_ARM64_Dockerfile: "LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile" + + steps: + # Checks-out the repository under $GITHUB_WORKSPACE + - uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 #v4.2.2 + with: + ref: 'gcbeatty/runtime2' + + # Determine the latest ASP.NET Core versions for all .NET versions + - name: Determine Latest ASP.NET Core Versions + id: get-versions + shell: pwsh + run: | + $versions = .\LambdaRuntimeDockerfiles\get-latest-aspnet-versions.ps1 + foreach ($line in $versions) { + if ($line -match '(.+)=(.+)') { + echo "$($matches[1])=$($matches[2])" >> $env:GITHUB_OUTPUT + echo "Using $($matches[1])=$($matches[2])" + } + } + + # Update .NET 8 AMD64 Dockerfile + - name: Update .NET 8 AMD64 + id: update-net8-amd64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_8_AMD64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_8_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 8 AMD64 update - No version detected" + } + + # Update .NET 8 ARM64 Dockerfile + - name: Update .NET 8 ARM64 + id: update-net8-arm64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_8_ARM64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_8_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 8 ARM64 update - No version detected" + } + + # Update .NET 9 AMD64 Dockerfile + - name: Update .NET 9 AMD64 + id: update-net9-amd64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_9_AMD64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_9_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 9 AMD64 update - No version detected" + } + + # Update .NET 9 ARM64 Dockerfile + - name: Update .NET 9 ARM64 + id: update-net9-arm64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_9_ARM64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_9_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 9 ARM64 update - No version detected" + } + + # Update .NET 10 AMD64 Dockerfile + - name: Update .NET 10 AMD64 + id: update-net10-amd64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_10_AMD64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_10_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 10 AMD64 update - No version detected" + } + + # Update .NET 10 ARM64 Dockerfile + - name: Update .NET 10 ARM64 + id: update-net10-arm64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_10_ARM64_Dockerfile }} + NEXT_VERSION: ${{ steps.get-versions.outputs.NET_10_NEXT_VERSION }} + run: | + if (-not [string]::IsNullOrEmpty("${{ env.NEXT_VERSION }}")) { + .\LambdaRuntimeDockerfiles\update-dockerfile.ps1 -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion "${{ env.NEXT_VERSION }}" + } else { + Write-Host "Skipping .NET 10 ARM64 update - No version detected" + } + + # Commit changes and create a branch + - name: Commit and Push + id: commit-push + shell: pwsh + run: | + # Check if there are any changes to commit + if (git status --porcelain) { + git config --global user.email "github-aws-sdk-dotnet-automation@amazon.com" + git config --global user.name "aws-sdk-dotnet-automation" + $suffix=Get-Date -Format yyyy-MM-dd + $branch="chore/auto-update-Dockerfiles-${suffix}" + git checkout -b $branch + git add "**/*Dockerfile" + git commit -m "chore: Monthly ASP.NET Core version update in Dockerfiles" + git push origin $branch + + # Write the branch name to GITHUB_OUTPUT for use in the PR step + Add-Content -Path $env:GITHUB_OUTPUT -Value "BRANCH=$branch" + Add-Content -Path $env:GITHUB_OUTPUT -Value "CHANGES_MADE=true" + echo "Changes committed and pushed to branch $branch" + } else { + echo "No changes detected in Dockerfiles, skipping PR creation" + } + + # Create a Pull Request + - name: Create Pull Request + id: pull-request + if: ${{ steps.commit-push.outputs.CHANGES_MADE == 'true' }} + uses: repo-sync/pull-request@v2 + with: + source_branch: ${{ steps.commit-push.outputs.BRANCH }} + destination_branch: "dev" + pr_title: 'chore: Monthly ASP.NET Core version update in Dockerfiles' + pr_body: "This PR automatically updates the Dockerfiles to use the latest ASP.NET Core version. + + Verify that the Dockerfiles have correct versions and matching SHA512 checksums for ASP.NET Core runtime. + + All .NET versions: https://dotnet.microsoft.com/en-us/download/dotnet + + *Description of changes:* + \n${{ format + ( + '{0}\n{1}\n{2}\n{3}\n{4}\n{5}', + join(steps.update-net8-amd64.outputs.MESSAGE, '\n'), + join(steps.update-net8-arm64.outputs.MESSAGE, '\n'), + join(steps.update-net9-amd64.outputs.MESSAGE, '\n'), + join(steps.update-net9-arm64.outputs.MESSAGE, '\n'), + join(steps.update-net10-amd64.outputs.MESSAGE, '\n'), + join(steps.update-net10-arm64.outputs.MESSAGE, '\n') + ) + }}" + github_token: ${{ secrets.GITHUB_TOKEN }} + + # Add "Release Not Needed" label to the PR + - name: Add Release Not Needed label + if: ${{ steps.pull-request.outputs.pr_number }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ steps.pull-request.outputs.pr_number }}, + labels: ['Release Not Needed'] + }) diff --git a/.github/workflows/update-Dockerfiles.yml b/.github/workflows/update-Dockerfiles.yml index 9fbbd0690..87c1bd83c 100644 --- a/.github/workflows/update-Dockerfiles.yml +++ b/.github/workflows/update-Dockerfiles.yml @@ -1,5 +1,9 @@ name: Update Lambda Dockerfiles +permissions: + contents: write + pull-requests: write + on: # Allows to run this workflow manually from the Actions tab workflow_dispatch: @@ -8,12 +12,12 @@ on: description: ".NET 8 AMD64" type: boolean required: true - default: "true" + default: true NET_8_ARM64: description: ".NET 8 ARM64" type: boolean required: true - default: "true" + default: true NET_8_NEXT_VERSION: description: ".NET 8 Next Version" type: string @@ -22,12 +26,12 @@ on: description: ".NET 9 AMD64" type: boolean required: true - default: "true" + default: true NET_9_ARM64: description: ".NET 9 ARM64" type: boolean required: true - default: "true" + default: true NET_9_NEXT_VERSION: description: ".NET 9 Next Version" type: string @@ -36,12 +40,12 @@ on: description: ".NET 10 AMD64" type: boolean required: true - default: "true" + default: true NET_10_ARM64: description: ".NET 10 ARM64" type: boolean required: true - default: "true" + default: true NET_10_NEXT_VERSION: description: ".NET 10 Next Version" type: string @@ -165,4 +169,17 @@ jobs: ) }}" github_token: ${{ secrets.GITHUB_TOKEN }} - \ No newline at end of file + + # Add "Release Not Needed" label to the PR + - name: Add Release Not Needed label + if: ${{ steps.pull-request.outputs.pr_number }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ steps.pull-request.outputs.pr_number }}, + labels: ['Release Not Needed'] + }) diff --git a/LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile index 897d97f88..ae8e8142d 100644 --- a/LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net10/amd64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=10.0.0-preview.5.25277.114 -ARG ASPNET_SHA512=6E69A85F7E18B8EEBB5F99A7E8099DB2FA5DA34BCF078BECBB123C0863D4BE7B4252C7CFC6B21B9585F4F800C058A12CAE55EF2A63B9BEA886CA3D1D8A0EC113 +ARG ASPNET_VERSION=10.0.0-preview.6.25358.103 +ARG ASPNET_SHA512=15ccea434f5e33b4af872bda00d30d3fee4494113a1e5d7b1e8ce206ab0a2e09384fa5a223afdde4b94ea3b7e12b796c1a45138be833288bd68741ae843fb6c8 ARG LAMBDA_RUNTIME_NAME=dotnet10 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile index 846536c84..f6fa73967 100644 --- a/LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net10/arm64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=10.0.0-preview.5.25277.114 -ARG ASPNET_SHA512=AC99EBEC4E7ABD660A27317D37DA56AE1FA8E9EBDBF4A88FE5F9BE58E1F4D7E8F05BEC32D5E902C0FDD1E9D9E250CDB49448266682010E4CF7F4640F9699B9F1 +ARG ASPNET_VERSION=10.0.0-preview.6.25358.103 +ARG ASPNET_SHA512=88667d66d90aaba30649f84d10d057da7c0db479cdb36b76824dc8e0f02a44a6bf5d269d74daa0d6b78376f2dc66b60238558267555e2ced40cbd06aac745d6a ARG LAMBDA_RUNTIME_NAME=dotnet10 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile index 63ede4b5b..206096dbe 100644 --- a/LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net9/amd64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=9.0.6 -ARG ASPNET_SHA512=54c122c4c6127ce7e0f0ad0479a101db1455484c9e5bffa8fdc0dd72d2db028be86861f331f2c7c1cb2eaee9a92e741e4e5da567795533e46af27e4e481c0451 +ARG ASPNET_VERSION=9.0.7 +ARG ASPNET_SHA512=b175d4d0578f9f5d735d59def3f44459462ef36b4bd07d9ca0ed9853bf42d90c7bace195ff264a9dcf6dd4d6d452c87059085146268fce3540ed58eaf39629eb ARG LAMBDA_RUNTIME_NAME=dotnet9 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile index 2d9630e83..4d5a18318 100644 --- a/LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net9/arm64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=9.0.6 -ARG ASPNET_SHA512=8a7024bd144254f400c0758efd5c39854eba5d7e3187fbde2dc857cedd9012ae93aceeb1683bf6bf390cefba40c50f95cc3295a1a8eb83133a8e01b91289dfc5 +ARG ASPNET_VERSION=9.0.7 +ARG ASPNET_SHA512=79b28df2bc522d47bd0ea3f8b4aaa447102f92019d038670743fbbc1e6b31dd206499ff6dfc2d31623dedb64a9e2ca23608c7ea7225f1f071745de72c9f81bf4 ARG LAMBDA_RUNTIME_NAME=dotnet9 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1 b/LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1 new file mode 100644 index 000000000..d233c222a --- /dev/null +++ b/LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1 @@ -0,0 +1,147 @@ +# This script fetches the latest ASP.NET Core runtime versions for .NET 8, 9, and 10 +# It uses the NuGet API to query for Microsoft.AspNetCore.App.Runtime.linux-x64 package versions + +function Get-LatestAspNetVersion { + param ( + [string]$majorVersion + ) + + Write-Host "Fetching latest ASP.NET Core runtime version for .NET $majorVersion..." + + try { + # Use NuGet API to find latest version + $response = Invoke-RestMethod -Uri "https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.app.runtime.linux-x64/index.json" + + # Filter versions matching the major version + $versions = @() + foreach ($ver in $response.versions) { + if ($ver -like "$majorVersion.*") { + $versions += $ver + } + } + + if ($versions.Count -eq 0) { + Write-Error "No versions found for .NET $majorVersion" + return $null + } + + # Separate release and preview versions + $releaseVersions = @() + $previewVersions = @() + + foreach ($ver in $versions) { + if ($ver -match '-preview') { + $previewVersions += $ver + } else { + $releaseVersions += $ver + } + } + + # If we have release versions, get the latest + if ($releaseVersions.Count -gt 0) { + $verObjects = @() + + foreach ($ver in $releaseVersions) { + try { + $verObj = New-Object PSObject + Add-Member -InputObject $verObj -MemberType NoteProperty -Name "OriginalVersion" -Value $ver + + # Convert to Version object for proper comparison + $versionObj = [Version]$ver + Add-Member -InputObject $verObj -MemberType NoteProperty -Name "Version" -Value $versionObj + + $verObjects += $verObj + } catch { + Write-Host "Warning: Could not parse version $ver, skipping." + } + } + + # Sort by version (descending) and get the first one + $sortedVersions = $verObjects | Sort-Object -Property Version -Descending + + if ($sortedVersions.Count -gt 0) { + $latestVersion = $sortedVersions[0].OriginalVersion + } else { + $latestVersion = $null + } + } + # Otherwise get the latest preview version + elseif ($previewVersions.Count -gt 0) { + # For preview versions like "10.0.0-preview.5.25277.114" + $previewObjs = @() + + foreach ($ver in $previewVersions) { + if ($ver -match '(\d+)\.(\d+)\.(\d+)-preview\.(\d+)') { + $major = [int]$matches[1] + $minor = [int]$matches[2] + $patch = [int]$matches[3] + $preview = [int]$matches[4] + + $previewObj = New-Object PSObject + Add-Member -InputObject $previewObj -MemberType NoteProperty -Name "OriginalVersion" -Value $ver + Add-Member -InputObject $previewObj -MemberType NoteProperty -Name "Major" -Value $major + Add-Member -InputObject $previewObj -MemberType NoteProperty -Name "Minor" -Value $minor + Add-Member -InputObject $previewObj -MemberType NoteProperty -Name "Patch" -Value $patch + Add-Member -InputObject $previewObj -MemberType NoteProperty -Name "Preview" -Value $preview + + $previewObjs += $previewObj + } + } + + # Sort by version components + $sortedPreviews = $previewObjs | Sort-Object -Property Major, Minor, Patch, Preview -Descending + + if ($sortedPreviews.Count -gt 0) { + $latestVersion = $sortedPreviews[0].OriginalVersion + } else { + # Fallback - just take the last one alphabetically + $latestVersion = ($previewVersions | Sort-Object)[-1] + } + } + else { + $latestVersion = $null + } + + if ($latestVersion) { + Write-Host "Latest ASP.NET Core runtime version for .NET $majorVersion is $latestVersion" + return $latestVersion + } else { + Write-Error "Could not determine latest version for .NET $majorVersion" + return $null + } + } + catch { + $errorMessage = "Error fetching versions for .NET $majorVersion " + $_ + Write-Error $errorMessage + return $null + } +} + +# Get latest versions for each .NET version +$net8Version = Get-LatestAspNetVersion -majorVersion "8" +$net9Version = Get-LatestAspNetVersion -majorVersion "9" +$net10Version = Get-LatestAspNetVersion -majorVersion "10" + +# Verify we got valid versions +$allVersionsValid = $true +if (-not $net8Version) { + Write-Error "Failed to determine .NET 8 version" + $allVersionsValid = $false +} +if (-not $net9Version) { + Write-Error "Failed to determine .NET 9 version" + $allVersionsValid = $false +} +if (-not $net10Version) { + Write-Error "Failed to determine .NET 10 version" + $allVersionsValid = $false +} + +if (-not $allVersionsValid) { + exit 1 +} + +# Output as GitHub Actions environment variables +Write-Output "NET_8_NEXT_VERSION=$net8Version" +Write-Output "NET_9_NEXT_VERSION=$net9Version" +Write-Output "NET_10_NEXT_VERSION=$net10Version"