diff --git a/.github/workflows/auto-update-Dockerfiles.yml b/.github/workflows/auto-update-Dockerfiles.yml new file mode 100644 index 000000000..6d890287f --- /dev/null +++ b/.github/workflows/auto-update-Dockerfiles.yml @@ -0,0 +1,193 @@ +name: Auto-Update Lambda Dockerfiles Daily + +permissions: + contents: write + pull-requests: write + +on: + # Run daily at midnight UTC + schedule: + - cron: '0 0 * * *' + # 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' + + + # Update .NET 8 AMD64 Dockerfile + - name: Update .NET 8 AMD64 + id: update-net8-amd64 + shell: pwsh + env: + DOCKERFILE_PATH: ${{ env.NET_8_AMD64_Dockerfile }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "8" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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 }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "8" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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 }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "9" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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 }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "9" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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 }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "10" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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 }} + run: | + $version = & "./LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1" -MajorVersion "10" + if (-not [string]::IsNullOrEmpty($version)) { + & "./LambdaRuntimeDockerfiles/update-dockerfile.ps1" -DockerfilePath "${{ env.DOCKERFILE_PATH }}" -NextVersion $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" + $branch="chore/auto-update-Dockerfiles-daily" + + # Check if the branch already exists remotely + $branchExists = git ls-remote --heads origin $branch + if ($branchExists) { + # Branch exists, check it out and update it + git fetch origin $branch + git checkout -B $branch origin/$branch + } else { + # Branch doesn't exist, create it + git checkout -b $branch + } + + git add "**/*Dockerfile" + git commit -m "chore: Daily ASP.NET Core version update in Dockerfiles" + git push --force-with-lease 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: Daily 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..1c9cb5285 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.7.25380.108 +ARG ASPNET_SHA512=f689f386f7fa56b9b53bd7d510abecf2b9c22358fb29367846c23fbba7b0a61a47d86dbceef96b73a728af076e55c346838497402e0cd80b8695d9dc1ea3c2b9 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..d77328fd3 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.7.25380.108 +ARG ASPNET_SHA512=81358ed46adffd1a4e2e095e3d23d67d1d289a6c4c50ab20e1e71161b2823c8c44dd5a6c241ac9b3fcd4a2af518dbffbccdb7b3acd07a42af9ff24c5fd62c6a3 ARG LAMBDA_RUNTIME_NAME=dotnet10 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile index 1690f3200..c731f586f 100644 --- a/LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net8/amd64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=8.0.18 -ARG ASPNET_SHA512=896e9cab7c3ea5384c174e7e2cffae3c7f8f9ed5d6d2b7434b5a2b0dc3f02b611ff8668f5d70c0b356a6a5d85a28fe40756cf356b168d0306370da11646b4b23 +ARG ASPNET_VERSION=8.0.19 +ARG ASPNET_SHA512=9503fe84627716cb9df02c648e34971c6ec4d44686f213bc6f6bd74bc54ffb41ef272fbd2c8aa3f0a309b20664796c12f9c77b137015f84581ac265af2f21687 ARG LAMBDA_RUNTIME_NAME=dotnet8 ARG AMAZON_LINUX=public.ecr.aws/lambda/provided:al2023 diff --git a/LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile b/LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile index a22262ccd..6d1d8023c 100644 --- a/LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile +++ b/LambdaRuntimeDockerfiles/Images/net8/arm64/Dockerfile @@ -1,7 +1,7 @@ # Based on Docker image from: https://github.com/dotnet/dotnet-docker/ -ARG ASPNET_VERSION=8.0.18 -ARG ASPNET_SHA512=997ce36180503fbd4dd86ed43b533f618be1db7cf170f500d0d12f899adff22e5b7714942aa2513eece6c12224761c143fbc91d6e97d83cccaed8a811ebcd835 +ARG ASPNET_VERSION=8.0.19 +ARG ASPNET_SHA512=cc14503e5c1d94a333fd8048f628760f6df2b2acd4e0d5ef465cbbfcc13517753d6fd5b1d5fe4b38b07704418a713e1338005453a7cbb8fb3f300760d00fc6e6 ARG LAMBDA_RUNTIME_NAME=dotnet8 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..4dc041c6b 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.8 +ARG ASPNET_SHA512=08afdf924d00f875b44cc4eff68b55fb9b63e4cc68e6b5cde873da2bce9c5b5f4120e869b6a1dfdea4ab104ab0ac8783ef1577b4d3275aae899a53cd88130f1d 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..28edaff80 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.8 +ARG ASPNET_SHA512=cf1e72f4b327b93c1ac3f2def9ca83bee27a408e5b5913f84ed954cfd6c4639da1664fe3f4e3925883db77ed29fa5364b9ca8af3796f33ca73a4cb7484e326bc 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..fd2a889a7 --- /dev/null +++ b/LambdaRuntimeDockerfiles/get-latest-aspnet-versions.ps1 @@ -0,0 +1,135 @@ +# This script fetches the latest ASP.NET Core runtime version for a specified .NET major version +# It uses the NuGet API to query for Microsoft.AspNetCore.App.Runtime.linux-x64 package versions + +param( + [Parameter(Mandatory=$true)] + [string]$MajorVersion +) + +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 version for the specified .NET major version +$version = Get-LatestAspNetVersion -majorVersion $MajorVersion + +# Verify we got a valid version +if (-not $version) { + Write-Error "Failed to determine .NET $MajorVersion version" + exit 1 +} + +# Output the version directly +Write-Output $version