Test matrix #882
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build workertools base image | |
on: | |
push: | |
branches: [ arm64-support ] | |
workflow_dispatch: | |
env: | |
REGISTRY_IMAGE: ${{ secrets.TESTING_DOCKER_HUB_USER }}/workertools | |
jobs: | |
get-version-number: | |
runs-on: windows-latest | |
outputs: | |
VERSION: ${{ steps.check-version.outputs.VERSION }} | |
MAJOR_VERSION: ${{ steps.check-version.outputs.MAJOR_VERSION }} | |
WIN2022_VERSION: ${{ steps.check-version.outputs.WIN2022_VERSION }} | |
CONTINUE: ${{ steps.check-version.outputs.CONTINUE }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: check-version | |
name: Compare latest version with container | |
run: | | |
$chocoInformationRaw = choco info powershell-core --limitoutput | |
$versionOutput = ($chocoInformationRaw.Split("|"))[1] | |
[System.Version]$version = $null | |
$versionParsed = [System.Version]::TryParse($versionOutput, [ref]$version) | |
if(-not $versionParsed) { | |
Write-Host "Unable to parse '$versionOutput' as a valid version. Won't continue" | |
echo "CONTINUE=No" >> $env:GITHUB_OUTPUT | |
} | |
else { | |
$versionToCompare = "$($version.Major).$($version.Minor).$($version.Build)" | |
Write-Host "Parsed version as $versionToCompare" | |
$workerToolsTags = Invoke-RestMethod "https://registry.hub.docker.com/v2/repositories/${{ env.REGISTRY_IMAGE }}/tags?page_size=50" | |
$matchingTag = $workerToolsTags.results | Where-Object { $_.name -eq $versionToCompare } | |
echo "VERSION=$versionToCompare" >> $env:GITHUB_OUTPUT | |
echo "MAJOR_VERSION=$($version.Major)" >> $env:GITHUB_OUTPUT | |
Write-Host "VERSION: $versionToCompare" | |
Write-Host "MAJOR_VERSION: $version.Major" | |
if ($null -ne $matchingTag) | |
{ | |
Write-Host "Docker container already has latest version" | |
echo "CONTINUE=No" >> $env:GITHUB_OUTPUT | |
} | |
else | |
{ | |
Write-Host "We need to upgrade the container to $versionToCompare" | |
Write-Host "Getting OS versions for windows 2022" | |
$win2022_manifest = (docker manifest inspect --verbose "mcr.microsoft.com/dotnet/framework/runtime:4.8.1-windowsservercore-ltsc2022" | ConvertFrom-Json) | |
$WIN2022_VERSION = $win2022_manifest.Descriptor.Platform.'os.version' | |
Write-Host "WIN2022_VERSION: $WIN2022_VERSION" | |
if([string]::IsNullOrWhiteSpace($WIN2022_VERSION)) { | |
throw "Could not establish OS versions for windows 2022 needed for docker manifest" | |
} | |
echo "WIN2022_VERSION=$WIN2022_VERSION" >> $env:GITHUB_OUTPUT | |
Write-Host "We have everything we need, continuing." | |
echo "CONTINUE=Yes" >> $env:GITHUB_OUTPUT | |
} | |
} | |
shell: powershell | |
build-linux: | |
needs: [get-version-number] | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_CONTEXT=${platform//\//_}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.TESTING_DOCKER_HUB_USER }} | |
password: ${{ secrets.TESTING_DOCKER_HUB_PAT }} | |
- name: Build and push by digest | |
env: | |
VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
MAJOR_VERSION: ${{ needs.get-version-number.outputs.MAJOR_VERSION }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: base/${{ env.PLATFORM_CONTEXT }} | |
# push: true | |
# load: false | |
platforms: ${{ matrix.platform }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
build-args: | | |
PS_VERSION=${{env.VERSION_NUMBER}} | |
PS_MAJOR_VERSION=${{env.MAJOR_VERSION}} | |
# - name: Build linux/arm64 image | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# MAJOR_VERSION: ${{ needs.get-version-number.outputs.MAJOR_VERSION }} | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: base/linux_arm64 | |
# push: true | |
# load: false | |
# platforms: linux/arm64 | |
# tags: harrisonmeister/workertools:${{env.VERSION_NUMBER}} | |
# build-args: | | |
# PS_VERSION=${{env.VERSION_NUMBER}} | |
# PS_MAJOR_VERSION=${{env.MAJOR_VERSION}} | |
# build-win-2022: | |
# needs: [get-version-number] | |
# runs-on: windows-2022 | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: DockerHub Login | |
# env: | |
# USERNAME: ${{ secrets.TESTING_DOCKER_HUB_USER }} | |
# PASSWORD: ${{ secrets.TESTING_DOCKER_HUB_PAT }} | |
# run: docker login --username ${env:USERNAME} --password "${env:PASSWORD}" | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Build the win2022 image | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# run: docker build ./windows-2022 --tag harrisonmeister/workertools:${env:VERSION_NUMBER}-windows.2022 --tag harrisonmeister/workertools:latest-windows.2022 | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Push the win2022 version-specific image | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# run: docker push harrisonmeister/workertools:${env:VERSION_NUMBER}-windows.2022 | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Push the win2022 latest image | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# run: docker push harrisonmeister/workertools:latest-windows.2022 | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# build-docker-manifest: | |
# needs: [get-version-number, build-linux, build-win-2022] | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Dockerhub Login | |
# env: | |
# USERNAME: ${{ secrets.TESTING_DOCKER_HUB_USER }} | |
# PASSWORD: ${{ secrets.TESTING_DOCKER_HUB_PAT }} | |
# run: docker login --username $USERNAME --password "$PASSWORD" | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Create docker manifest for latest tag | |
# run: docker manifest create harrisonmeister/workertools:latest harrisonmeister/workertools:latest-windows.2022 harrisonmeister/workertools:latest-ubuntu.2204 | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Annotate docker manifest for latest tag | |
# env: | |
# WIN2022_VERSION: ${{ needs.get-version-number.outputs.WIN2022_VERSION }} | |
# run: | | |
# docker manifest annotate --os "windows" --os-version "$WIN2022_VERSION" --arch "amd64" "harrisonmeister/workertools:latest" "harrisonmeister/workertools:latest-windows.2022" | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Push docker manifest for latest tag | |
# run: docker manifest push harrisonmeister/workertools:latest | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Create docker manifest for version-specific tag | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# run: docker manifest create harrisonmeister/workertools:$VERSION_NUMBER harrisonmeister/workertools:$VERSION_NUMBER-windows.2022 harrisonmeister/workertools:$VERSION_NUMBER-ubuntu.2204 | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Annotate docker manifest for version-specific tag | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# WIN2022_VERSION: ${{ needs.get-version-number.outputs.WIN2022_VERSION }} | |
# run: | | |
# docker manifest annotate --os "windows" --os-version "$WIN2022_VERSION" --arch "amd64" "harrisonmeister/workertools:$VERSION_NUMBER" "harrisonmeister/workertools:$VERSION_NUMBER-windows.2022" | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
# - name: Push docker manifest for version-specific tag | |
# env: | |
# VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} | |
# run: docker manifest push harrisonmeister/workertools:$VERSION_NUMBER | |
# if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} |