trigger: none
pr: none
schedules:
- cron: "0 0 * * 1"  # weekly on Mondays at 00:00 UTC
  displayName: Weekly build
  branches:
    include:
    - main
  always: true
jobs:
- job: update_job
  displayName: Update Containers
  timeoutInMinutes: 720
  pool:
    name: PrAzureLinux3Docker
    os: linux
  steps:
  - checkout: self
  - task: AzureCLI@2
    displayName: Build and Tag Containers
    inputs:
      azureSubscription: 'containers-updater'
      scriptType: bash
      scriptLocation: 'inlineScript'
      inlineScript: |
        export BuildDate=$(date -u +"%Y-%m-%d")
        export EndDate=$(date -u -d "1 day" +"%Y-%m-%d")
        echo "BUILD_DATE=$BuildDate"
        echo "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate"
        az acr login --name vcpkgandroidwus
        # Note that this is marking the *previous* image as EOL, not the one we're building as it attaches
        # to the SHA to which the tag points, not the tag itself.
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-android:2026-02-10 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-android:2026-02-10"
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-android:2026-02-10 --platform linux/amd64 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-android:2026-02-10 linux/amd64"
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-linux:2026-04-20 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-linux:2026-01-20"
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-linux:2026-04-20 --platform linux/amd64 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-linux:2026-01-20 linux/amd64"
        # Note that this is an image for *targeting* arm64, it's still an amd64 image, hence linux/amd64
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-arm64-linux:2026-04-20 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-arm64-linux:2026-03-18"
        oras attach --artifact-type application/vnd.microsoft.artifact.lifecycle --annotation "vnd.microsoft.artifact.lifecycle.end-of-life.date=$EndDate" vcpkgandroidwus.azurecr.io/vcpkg-arm64-linux:2026-04-20 --platform linux/amd64 || echo "WARNING: Failed to attach lifecycle metadata to vcpkg-arm64-linux:2026-03-18 linux/amd64"
        cd scripts/azure-pipelines/android
        # to explain the ulimit thing, see https://github.com/docker/buildx/issues/379
        docker buildx build . -t vcpkgandroidwus.azurecr.io/vcpkg-android:2026-02-10 --build-arg BUILD_DATE=$BuildDate --ulimit nofile=1024:1024
        docker push vcpkgandroidwus.azurecr.io/vcpkg-android:2026-02-10
        cd ../linux
        docker buildx build . -t vcpkgandroidwus.azurecr.io/vcpkg-linux:2026-04-20 --build-arg BUILD_DATE=$BuildDate --ulimit nofile=1024:1024
        docker push vcpkgandroidwus.azurecr.io/vcpkg-linux:2026-04-20
        cd ../linux-arm64
        docker buildx build . -t vcpkgandroidwus.azurecr.io/vcpkg-arm64-linux:2026-04-20 --build-arg BUILD_DATE=$BuildDate --ulimit nofile=1024:1024
        docker push vcpkgandroidwus.azurecr.io/vcpkg-arm64-linux:2026-04-20
