diff --git a/.azure-pipelines/publish-docker.yml b/.azure-pipelines/publish-docker.yml new file mode 100644 index 000000000..53095d1b4 --- /dev/null +++ b/.azure-pipelines/publish-docker.yml @@ -0,0 +1,123 @@ +# Trigger: any `v*` release tag (e.g. v1.40.0). +# Can also be queued manually from the ADO UI. +trigger: + tags: + include: + - v* + exclude: + - v*-* + +pr: none + +parameters: +- name: releaseChannel + displayName: "IMPORTANT: set this to 'canary' when triggering manually" + type: string + default: stable + values: + - stable + - canary + +resources: + repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines + parameters: + pool: + name: DevDivPlaywrightAzurePipelinesUbuntu2204 + os: linux + sdl: + sourceAnalysisPool: + name: DevDivPlaywrightAzurePipelinesWindows2022 + # The image must be windows-based due to restrictions of the SDL tools. See: https://aka.ms/AAo6v8e + os: windows + suppression: + suppressionFile: $(Build.SourcesDirectory)\.azure-pipelines\guardian\SDL\.gdnsuppress + stages: + - stage: Publish + jobs: + - job: PublishDocker + displayName: "Publish Docker images to ACR" + # arm64 images are cross-built under QEMU emulation, which is slow. + timeoutInMinutes: 360 + steps: + - checkout: self + persistCredentials: false + displayName: "Checkout code" + + - task: UseNode@1 + inputs: + version: '26.x' + displayName: "Install Node.js" + + # Relocate the Docker data-root to the large /mnt volume: this job builds + # 6 images (jammy/noble/resolute x amd64/arm64) and `docker system prune`s + # between them, so the default disk fills up. + - task: Bash@3 + displayName: "Setup docker" + inputs: + targetType: "inline" + script: | + set -x + sudo service docker stop + sudo mkdir -p /etc/docker + echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json + sudo service docker start + + # Used by scripts/download_driver.sh on the host. The repository root is the + # Docker build context, so .dockerignore keeps this file out of the images. + - task: Bash@3 + displayName: "setup .npmrc" + inputs: + targetType: "inline" + script: | + echo "registry=https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/DevDiv_PublicPackages/npm/registry/" >> .npmrc + + - task: npmAuthenticate@0 + displayName: "authenticate the private npm registry" + inputs: + workingFile: .npmrc + + # Must run before MavenAuthenticate@0 so the credentials it injects into + # ~/.m2/settings.xml are not overwritten by the copy. + - bash: | + mkdir -p ~/.m2 + cp .azure-pipelines/settings.xml ~/.m2/settings.xml + displayName: 'Copy settings.xml (mirror Maven Central to DevDiv_PublicPackages)' + + - task: MavenAuthenticate@0 + displayName: 'Authenticate to DevDiv_PublicPackages feed' + inputs: + artifactsFeeds: DevDiv_PublicPackages + + - task: AzureCLI@2 + displayName: "Login to ACR via OIDC" + inputs: + azureSubscription: "Playwright-CDN" + scriptType: "bash" + scriptLocation: "inlineScript" + inlineScript: "az acr login --name playwright" + + - task: Bash@3 + displayName: "Register QEMU (binfmt) for arm64 cross-build" + inputs: + targetType: "inline" + script: "docker run --rm --privileged ${ACR_CACHE_PREFIX}tonistiigi/binfmt --install arm64" + env: + ACR_CACHE_PREFIX: "playwright.azurecr.io/cached/" + + - task: Bash@3 + displayName: "Build & publish Docker images" + inputs: + targetType: "inline" + # The authenticated settings.xml is passed to `docker build` as a secret so + # that Maven inside the image also resolves from DevDiv_PublicPackages. + script: MAVEN_SETTINGS_SECRET="$HOME/.m2/settings.xml" ./utils/docker/publish_docker.sh ${{ parameters.releaseChannel }} + env: + ACR_CACHE_PREFIX: "playwright.azurecr.io/cached/" + UBUNTU_MIRROR_PREFIX: "azure." diff --git a/.azure-pipelines/publish.yml b/.azure-pipelines/publish.yml index 4572d6cd8..c17cd96c3 100644 --- a/.azure-pipelines/publish.yml +++ b/.azure-pipelines/publish.yml @@ -36,6 +36,10 @@ extends: path: $(Build.ArtifactStagingDirectory)/esrp-build artifact: esrp-build steps: + - checkout: self + persistCredentials: false + displayName: "Checkout code" + - bash: | if [[ ! "$CURRENT_BRANCH" =~ ^v1\..* ]]; then echo "Can only publish from a release tag branch (v1.*)." diff --git a/.azure-pipelines/settings.xml b/.azure-pipelines/settings.xml index 34e9be56f..1617d36e9 100644 --- a/.azure-pipelines/settings.xml +++ b/.azure-pipelines/settings.xml @@ -1,6 +1,7 @@ + + org.codehaus.mojo + exec-maven-plugin + 3.6.4 + diff --git a/scripts/NODE_VERSION b/scripts/NODE_VERSION new file mode 100644 index 000000000..a45fd52cc --- /dev/null +++ b/scripts/NODE_VERSION @@ -0,0 +1 @@ +24 diff --git a/scripts/download_driver.sh b/scripts/download_driver.sh index 5e36f91e3..24a53de7f 100755 --- a/scripts/download_driver.sh +++ b/scripts/download_driver.sh @@ -10,10 +10,10 @@ if [[ ($1 == '-h') || ($1 == '--help') ]]; then echo "" echo "This script downloads and assembles the Playwright driver for all platforms." echo "The platform-independent 'playwright-core' npm package is assembled once into the driver" - echo "module ('driver/src/main/resources/driver/package'), and the matching Node.js binary from" - echo "https://nodejs.org for each platform goes into the driver-bundle module" - echo "('driver-bundle/src/main/resources/driver/'), the same way the upstream" - echo "Playwright build does it." + echo "module ('driver/src/main/resources/driver/package'), and the Node.js binary from" + echo "https://nodejs.org (major version pinned in scripts/NODE_VERSION) for each platform goes" + echo "into the driver-bundle module ('driver-bundle/src/main/resources/driver/'), the" + echo "same way the upstream Playwright build does it." echo "" echo "Usage: scripts/download_driver.sh [option]" echo "" @@ -46,13 +46,19 @@ npm_at_root() { (cd "$ROOT" && npm "$@") } -# The Node.js version used to be pinned in the upstream driver build script. The script was -# removed in microsoft/playwright#41518, so we follow the same policy it had: the latest -# Node.js LTS (see upstream utils/build/update-playwright-node.mjs). -NODE_VERSION=$(curl -fsSL "https://nodejs.org/dist/index.json" \ - | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log(JSON.parse(s).find(r=>r.lts).version.slice(1)))") +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT + +# scripts/NODE_VERSION pins the Node.js major version, like ARG NODE_VERSION in the upstream +# Docker images. Use the latest release of that major version. +NODE_MAJOR_VERSION=$(head -1 ./NODE_VERSION) +# The checksum list of the latest release names every file after the release, e.g. +# d38bd5e5... node-v26.13.0-darwin-arm64.tar.gz +SHASUMS="$TMP_DIR/SHASUMS256.txt" +download "https://nodejs.org/dist/latest-v$NODE_MAJOR_VERSION.x/SHASUMS256.txt" "$SHASUMS" +NODE_VERSION=$(sed -nE 's/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/p' "$SHASUMS" | head -1) if [[ -z "$NODE_VERSION" ]]; then - echo "Failed to determine the latest Node.js LTS version" + echo "Failed to determine the latest Node.js $NODE_MAJOR_VERSION.x version" exit 1 fi @@ -64,9 +70,6 @@ echo "Node.js version: $NODE_VERSION" CORE_DEST="$ROOT/driver/src/main/resources/driver" NODE_DEST="$ROOT/driver-bundle/src/main/resources/driver" -TMP_DIR="$(mktemp -d)" -trap 'rm -rf "$TMP_DIR"' EXIT - # 1. playwright-core package -> driver module (once, shared by every platform). echo "Assembling playwright-core package to $CORE_DEST/package" rm -rf "$CORE_DEST/package" diff --git a/scripts/roll_driver.sh b/scripts/roll_driver.sh index f8535e57f..4b45e85a2 100755 --- a/scripts/roll_driver.sh +++ b/scripts/roll_driver.sh @@ -24,12 +24,10 @@ fi CURRENT_VERSION=$(head -1 ./DRIVER_VERSION) echo "Rolling driver from $CURRENT_VERSION to $NEW_VERSION" -if [[ "$CURRENT_VERSION" == "$NEW_VERSION" ]]; then - echo "Current version is up to date. Skipping driver download."; -else - echo $NEW_VERSION > ./DRIVER_VERSION - ./download_driver.sh -fi; +echo $NEW_VERSION > ./DRIVER_VERSION +# Download even when the driver version is unchanged: the driver bundles the latest release +# of the Node.js major version pinned in NODE_VERSION. +./download_driver.sh ./generate_api.sh ./update_readme.sh diff --git a/tools/api-generator/pom.xml b/tools/api-generator/pom.xml index 2e75e4c4e..727f0bd74 100644 --- a/tools/api-generator/pom.xml +++ b/tools/api-generator/pom.xml @@ -6,7 +6,7 @@ com.microsoft.playwright api-generator - 1.50.0-SNAPSHOT + 1.63.0 Playwright - API Generator This is an internal module used to generate Java API from the upstream Playwright diff --git a/tools/test-cli-fatjar/pom.xml b/tools/test-cli-fatjar/pom.xml index 916e92187..8848c60eb 100644 --- a/tools/test-cli-fatjar/pom.xml +++ b/tools/test-cli-fatjar/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.microsoft.playwright test-cli-fatjar - 1.50.0-SNAPSHOT + 1.63.0 Test Playwright Command Line FatJar 1.8 diff --git a/tools/test-cli-version/pom.xml b/tools/test-cli-version/pom.xml index fcb8a842a..975b41e37 100644 --- a/tools/test-cli-version/pom.xml +++ b/tools/test-cli-version/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.microsoft.playwright test-cli-version - 1.50.0-SNAPSHOT + 1.63.0 Test Playwright Command Line Version 1.8 diff --git a/tools/test-local-installation/pom.xml b/tools/test-local-installation/pom.xml index 88fb2c63a..b3a330f9a 100644 --- a/tools/test-local-installation/pom.xml +++ b/tools/test-local-installation/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.microsoft.playwright test-local-installation - 1.50.0-SNAPSHOT + 1.63.0 Test local installation Runs Playwright test suite (copied from playwright module) against locally cached Playwright diff --git a/tools/test-spring-boot-starter/pom.xml b/tools/test-spring-boot-starter/pom.xml index 953e5afcc..52607b62d 100644 --- a/tools/test-spring-boot-starter/pom.xml +++ b/tools/test-spring-boot-starter/pom.xml @@ -9,7 +9,7 @@ com.microsoft.playwright test-spring-boot-starter - 1.50.0-SNAPSHOT + 1.63.0 Test Playwright With Spring Boot 2.4.3 diff --git a/tools/update-docs-version/pom.xml b/tools/update-docs-version/pom.xml index cf24731ad..18ef320f1 100644 --- a/tools/update-docs-version/pom.xml +++ b/tools/update-docs-version/pom.xml @@ -6,7 +6,7 @@ com.microsoft.playwright update-version - 1.50.0-SNAPSHOT + 1.63.0 Playwright - Update Version in Documentation This is an internal module used to update versions in the documentation based on diff --git a/utils/docker/Dockerfile.jammy b/utils/docker/Dockerfile.jammy index aa64ef493..316a95d4f 100644 --- a/utils/docker/Dockerfile.jammy +++ b/utils/docker/Dockerfile.jammy @@ -1,20 +1,26 @@ -FROM ubuntu:jammy +ARG ACR_CACHE_PREFIX +FROM ${ACR_CACHE_PREFIX}ubuntu:jammy ARG DEBIAN_FRONTEND=noninteractive ARG TZ=America/Los_Angeles ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-jammy" +ARG UBUNTU_MIRROR_PREFIX ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 # === INSTALL JDK and Maven === -RUN apt-get update && \ +RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ + -exec sed -i "s|http://archive.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}archive.ubuntu.com|g; s|http://ports.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}ports.ubuntu.com|g" {} + && \ + apt-get update && \ apt-get install -y --no-install-recommends openjdk-25-jdk \ # Install utilities required for downloading browsers wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \ @@ -22,10 +28,12 @@ RUN apt-get update && \ adduser pwuser # Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with -# Java 25, so we install latest Maven from Apache instead. -RUN VERSION=3.9.12 && \ - wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \ - ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/ +# Java 25, so we install latest Maven from Apache instead. build.sh +# downloads it into utils/docker/maven. +ARG MAVEN_VERSION +RUN --mount=type=bind,source=utils/docker/maven,target=/tmp/maven \ + tar zxf /tmp/maven/apache-maven-$MAVEN_VERSION-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-maven-$MAVEN_VERSION/bin/mvn /usr/local/bin/ ARG PW_TARGET_ARCH ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH} @@ -47,7 +55,10 @@ RUN mkdir /ms-playwright && \ COPY . /tmp/pw-java -RUN cd /tmp/pw-java && \ +# The optional Maven settings secret routes dependency resolution through a mirror +# (see .azure-pipelines/publish-docker.yml). +RUN --mount=type=secret,id=mavensettings,target=/root/.m2/settings.xml,required=false \ + cd /tmp/pw-java && \ mvn install -D skipTests --no-transfer-progress && \ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ -D exec.args="install-driver" -f playwright/pom.xml --no-transfer-progress && \ diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble index eafb59ba4..5ccd4d7bf 100644 --- a/utils/docker/Dockerfile.noble +++ b/utils/docker/Dockerfile.noble @@ -1,20 +1,26 @@ -FROM ubuntu:noble +ARG ACR_CACHE_PREFIX +FROM ${ACR_CACHE_PREFIX}ubuntu:noble ARG DEBIAN_FRONTEND=noninteractive ARG TZ=America/Los_Angeles ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-noble" +ARG UBUNTU_MIRROR_PREFIX ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 # === INSTALL JDK and Maven === -RUN apt-get update && \ +RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ + -exec sed -i "s|http://archive.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}archive.ubuntu.com|g; s|http://ports.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}ports.ubuntu.com|g" {} + && \ + apt-get update && \ apt-get install -y --no-install-recommends openjdk-25-jdk \ # Install utilities required for downloading browsers wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \ @@ -22,10 +28,12 @@ RUN apt-get update && \ adduser pwuser # Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with -# Java 25, so we install latest Maven from Apache instead. -RUN VERSION=3.9.12 && \ - wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \ - ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/ +# Java 25, so we install latest Maven from Apache instead. build.sh +# downloads it into utils/docker/maven. +ARG MAVEN_VERSION +RUN --mount=type=bind,source=utils/docker/maven,target=/tmp/maven \ + tar zxf /tmp/maven/apache-maven-$MAVEN_VERSION-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-maven-$MAVEN_VERSION/bin/mvn /usr/local/bin/ ARG PW_TARGET_ARCH ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH} @@ -47,7 +55,10 @@ RUN mkdir /ms-playwright && \ COPY . /tmp/pw-java -RUN cd /tmp/pw-java && \ +# The optional Maven settings secret routes dependency resolution through a mirror +# (see .azure-pipelines/publish-docker.yml). +RUN --mount=type=secret,id=mavensettings,target=/root/.m2/settings.xml,required=false \ + cd /tmp/pw-java && \ mvn install -D skipTests --no-transfer-progress && \ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ -D exec.args="install-driver" -f playwright/pom.xml --no-transfer-progress && \ diff --git a/utils/docker/Dockerfile.resolute b/utils/docker/Dockerfile.resolute index 64a68de4a..7dabf1f96 100644 --- a/utils/docker/Dockerfile.resolute +++ b/utils/docker/Dockerfile.resolute @@ -1,32 +1,34 @@ -FROM ubuntu:resolute +ARG ACR_CACHE_PREFIX +FROM ${ACR_CACHE_PREFIX}ubuntu:resolute ARG DEBIAN_FRONTEND=noninteractive ARG TZ=America/Los_Angeles ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-resolute" +ARG UBUNTU_MIRROR_PREFIX ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 # === INSTALL JDK and Maven === -RUN apt-get update && \ +RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ + -exec sed -i "s|http://archive.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}archive.ubuntu.com|g; s|http://ports.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}ports.ubuntu.com|g" {} + && \ + apt-get update && \ apt-get install -y --no-install-recommends openjdk-25-jdk \ + # Ubuntu 26.04 ships Maven 3.9.12 + maven \ # Install utilities required for downloading browsers wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \ # Create the pwuser useradd -m -s /bin/bash pwuser -# Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with -# Java 25, so we install latest Maven from Apache instead. -RUN VERSION=3.9.12 && \ - wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \ - ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/ - ARG PW_TARGET_ARCH ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH} @@ -47,7 +49,10 @@ RUN mkdir /ms-playwright && \ COPY . /tmp/pw-java -RUN cd /tmp/pw-java && \ +# The optional Maven settings secret routes dependency resolution through a mirror +# (see .azure-pipelines/publish-docker.yml). +RUN --mount=type=secret,id=mavensettings,target=/root/.m2/settings.xml,required=false \ + cd /tmp/pw-java && \ mvn install -D skipTests --no-transfer-progress && \ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ -D exec.args="install-driver" -f playwright/pom.xml --no-transfer-progress && \ diff --git a/utils/docker/build.sh b/utils/docker/build.sh index 649922f07..c1225245d 100755 --- a/utils/docker/build.sh +++ b/utils/docker/build.sh @@ -38,4 +38,44 @@ PW_TARGET_ARCH=$(echo $1 | cut -c3-) # it up via `COPY . /tmp/pw-java`. ../../scripts/download_driver.sh -docker build --platform "${PLATFORM}" --build-arg "PW_TARGET_ARCH=${PW_TARGET_ARCH}" -t "$3" -f "Dockerfile.$2" ../../ +# The jammy and noble images install this Maven (see the Dockerfiles). Fetch it with the +# host's Maven so that it resolves through the configured mirror: the release pipeline +# cannot reach Maven Central directly (see .azure-pipelines/settings.xml). +MAVEN_VERSION=3.9.12 +mvn dependency:copy -Dartifact="org.apache.maven:apache-maven:${MAVEN_VERSION}:tar.gz:bin" \ + -DoutputDirectory=maven --no-transfer-progress -q + +SECRET_ARGS=() +if [[ -n "${MAVEN_SETTINGS_SECRET:-}" ]]; then + SECRET_ARGS+=(--secret "id=mavensettings,src=${MAVEN_SETTINGS_SECRET}") +fi + +# Keep each arch image a plain single-platform manifest without the unknown/unknown platform entry. +export BUILDX_NO_DEFAULT_ATTESTATIONS=1 + +# arm64 images are cross-built under QEMU user-mode emulation, where Ubuntu 22.04's +# ldconfig segfaults intermittently at startup (tonistiigi/binfmt#298, every binfmt +# build since QEMU 8.1.4). apt's libc-bin trigger runs ldconfig, so a crash fails the +# whole `docker build`. Retry: BuildKit keeps the layers that already succeeded, so a +# retry re-runs only the failed RUN step. +MAX_ATTEMPTS=1 +if [[ "${PLATFORM}" == "linux/arm64" ]]; then + MAX_ATTEMPTS=3 +fi + +for ((attempt = 1; attempt <= MAX_ATTEMPTS; attempt++)); do + if docker build --platform "${PLATFORM}" \ + --build-arg "PW_TARGET_ARCH=${PW_TARGET_ARCH}" \ + --build-arg "MAVEN_VERSION=${MAVEN_VERSION}" \ + --build-arg ACR_CACHE_PREFIX="${ACR_CACHE_PREFIX}" \ + --build-arg UBUNTU_MIRROR_PREFIX="${UBUNTU_MIRROR_PREFIX}" \ + "${SECRET_ARGS[@]}" \ + -t "$3" -f "Dockerfile.$2" ../../; then + exit 0 + fi + if (( attempt < MAX_ATTEMPTS )); then + echo "docker build failed (attempt ${attempt}/${MAX_ATTEMPTS}), retrying..." >&2 + fi +done +echo "ERROR: docker build failed after ${MAX_ATTEMPTS} attempt(s)" >&2 +exit 1 diff --git a/utils/docker/publish_docker.sh b/utils/docker/publish_docker.sh index fb5ea2bb8..b1ab7f4de 100755 --- a/utils/docker/publish_docker.sh +++ b/utils/docker/publish_docker.sh @@ -8,41 +8,66 @@ cd "$(dirname "$0")" MCR_IMAGE_NAME="playwright/java" +RELEASE_CHANNEL="$1" +if [[ "${RELEASE_CHANNEL}" != "stable" && "${RELEASE_CHANNEL}" != "canary" ]]; then + echo "ERROR: unknown release channel - '${RELEASE_CHANNEL}'" + echo "Must be either 'stable' or 'canary'" + exit 1 +fi + POM_FILE=../../pom.xml if [[ ! -f ${POM_FILE} ]]; then echo "ERROR: pom.xml not found at ${POM_FILE}" exit 1; fi -PW_VERSION=$(mvn exec:exec -Dexec.executable='echo' -Dexec.args='${project.version}' -f ${POM_FILE} --non-recursive -q 2>/dev/null) - -RELEASE_CHANNEL="$1" -if [[ "${RELEASE_CHANNEL}" == "stable" ]]; then - if [[ ! "${PW_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "ERROR: cannot publish stable docker with Playwright version '${PW_VERSION}'" - exit 1 - fi -else - echo "ERROR: unknown release channel - ${RELEASE_CHANNEL}" - echo "Must be either 'stable' or 'canary'" +if ! PW_VERSION=$(mvn exec:exec -Dexec.executable='echo' -Dexec.args='${project.version}' -f ${POM_FILE} --non-recursive -q); then + # With -q Maven prints its errors to stdout, which was captured above. + echo "ERROR: failed to read the project version from ${POM_FILE}:" + echo "${PW_VERSION}" + exit 1 +fi +if [[ "${RELEASE_CHANNEL}" == "stable" && ! "${PW_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "ERROR: cannot publish stable docker with Playwright version '${PW_VERSION}'" exit 1 fi +VERSION_TAG="v${PW_VERSION}" +if [[ "${RELEASE_CHANNEL}" == "canary" ]]; then + VERSION_TAG="v${PW_VERSION}-canary-$(date -u +'%Y%m%d%H%M%S')" + echo "== CANARY build: publishing to ${VERSION_TAG}-* tags ==" +fi # Ubuntu 22.04 JAMMY_TAGS=( - "v${PW_VERSION}-jammy" + "${VERSION_TAG}-jammy" ) # Ubuntu 24.04 NOBLE_TAGS=( - "v${PW_VERSION}" - "v${PW_VERSION}-noble" + "${VERSION_TAG}-noble" ) +if [[ "${RELEASE_CHANNEL}" == "stable" ]]; then + NOBLE_TAGS+=("${VERSION_TAG}") +fi # Ubuntu 26.04 RESOLUTE_TAGS=( - "v${PW_VERSION}-resolute" + "${VERSION_TAG}-resolute" ) +tags_for_flavor() { + local FLAVOR="$1" + if [[ "$FLAVOR" == "jammy" ]]; then + echo "${JAMMY_TAGS[@]}" + elif [[ "$FLAVOR" == "noble" ]]; then + echo "${NOBLE_TAGS[@]}" + elif [[ "$FLAVOR" == "resolute" ]]; then + echo "${RESOLUTE_TAGS[@]}" + else + echo "ERROR: unknown flavor - $FLAVOR. Must be either 'jammy', 'noble', or 'resolute'" >&2 + exit 1 + fi +} + tag_and_push() { local source="$1" local target="$2" @@ -66,25 +91,19 @@ install_oras_if_needed() { return fi local version="1.1.0" - curl -sLO "https://github.com/oras-project/oras/releases/download/v${version}/oras_${version}_linux_amd64.tar.gz" + local arch="amd64" + if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then + arch="arm64" + fi + curl -sLO "https://github.com/oras-project/oras/releases/download/v${version}/oras_${version}_linux_${arch}.tar.gz" mkdir -p oras - tar -zxf oras_${version}_linux_amd64.tar.gz -C oras - rm oras_${version}_linux_amd64.tar.gz + tar -zxf oras_${version}_linux_${arch}.tar.gz -C oras + rm oras_${version}_linux_${arch}.tar.gz } publish_docker_images_with_arch_suffix() { local FLAVOR="$1" - local TAGS=() - if [[ "$FLAVOR" == "jammy" ]]; then - TAGS=("${JAMMY_TAGS[@]}") - elif [[ "$FLAVOR" == "noble" ]]; then - TAGS=("${NOBLE_TAGS[@]}") - elif [[ "$FLAVOR" == "resolute" ]]; then - TAGS=("${RESOLUTE_TAGS[@]}") - else - echo "ERROR: unknown flavor - $FLAVOR. Must be either 'jammy', 'noble', or 'resolute'" - exit 1 - fi + local TAGS=($(tags_for_flavor "$FLAVOR")) local ARCH="$2" if [[ "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then echo "ERROR: unknown arch - $ARCH. Must be either 'amd64' or 'arm64'" @@ -102,17 +121,7 @@ publish_docker_images_with_arch_suffix() { publish_docker_manifest () { local FLAVOR="$1" - local TAGS=() - if [[ "$FLAVOR" == "jammy" ]]; then - TAGS=("${JAMMY_TAGS[@]}") - elif [[ "$FLAVOR" == "noble" ]]; then - TAGS=("${NOBLE_TAGS[@]}") - elif [[ "$FLAVOR" == "resolute" ]]; then - TAGS=("${RESOLUTE_TAGS[@]}") - else - echo "ERROR: unknown flavor - $FLAVOR. Must be either 'jammy', 'noble', or 'resolute'" - exit 1 - fi + local TAGS=($(tags_for_flavor "$FLAVOR")) for ((i = 0; i < ${#TAGS[@]}; i++)) do local TAG="${TAGS[$i]}" @@ -129,14 +138,23 @@ publish_docker_manifest () { done } -publish_docker_images_with_arch_suffix jammy amd64 -publish_docker_images_with_arch_suffix jammy arm64 -publish_docker_manifest jammy amd64 arm64 +build_and_push_arch() { + local ARCH="$1" + publish_docker_images_with_arch_suffix jammy "${ARCH}" # Ubuntu 22.04 + publish_docker_images_with_arch_suffix noble "${ARCH}" # Ubuntu 24.04 + publish_docker_images_with_arch_suffix resolute "${ARCH}" # Ubuntu 26.04 +} -publish_docker_images_with_arch_suffix noble amd64 -publish_docker_images_with_arch_suffix noble arm64 -publish_docker_manifest noble amd64 arm64 +publish_manifests() { + publish_docker_manifest jammy amd64 arm64 # Ubuntu 22.04 + publish_docker_manifest noble amd64 arm64 # Ubuntu 24.04 + publish_docker_manifest resolute amd64 arm64 # Ubuntu 26.04 +} -publish_docker_images_with_arch_suffix resolute amd64 -publish_docker_images_with_arch_suffix resolute arm64 -publish_docker_manifest resolute amd64 arm64 +# arm64 first: its QEMU-emulated builds must run while the host is fresh. Running +# them after the native amd64 builds have churned the host triggers a qemu +# segfault in aarch64 ldconfig during libc-bin setup. amd64 is a native build and +# is unaffected by preceding work, so it goes second. +build_and_push_arch arm64 +build_and_push_arch amd64 +publish_manifests