mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

Although very common, bash is not guaranteed to be located at `/bin/bash`. NixOS is an example of this. More commonly, `/bin/bash` can be quite out of date. An example of this is MacOS's version of `bash`. This realistically won't affect Playwright but it's worth noting. You can technically update MacOS's system version of bash but you need elevated permissions to do so. By using `/usr/bin/env bash` instead of `/bin/bash` we can execute Playwright's bash scripts in like NixOS and generally improve the selection behaviour for bash in other systems too. Some discussion of why it's worth favouring `/usr/bin/env bash` over `/bin/bash`: - Discusses `/bin/bash` missing in NixOS: https://discourse.nixos.org/t/add-bin-bash-to-avoid-unnecessary-pain/5673 - Some general commentary on why `/usr/bin/env bash` is favoured: https://askubuntu.com/a/1402721 - Points out how old bash is in MacOS: https://itnext.io/upgrading-bash-on-macos-7138bd1066ba Improves situation at #5501
125 lines
3.1 KiB
Bash
Executable File
125 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
set +x
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
|
cd "$(dirname "$0")"
|
|
|
|
MCR_IMAGE_NAME="playwright"
|
|
PW_VERSION=$(node ../../utils/workspace.js --get-version)
|
|
|
|
RELEASE_CHANNEL="$1"
|
|
if [[ "${RELEASE_CHANNEL}" == "stable" ]]; then
|
|
if [[ "${PW_VERSION}" == *-* ]]; then
|
|
echo "ERROR: cannot publish stable docker with Playwright version '${PW_VERSION}'"
|
|
exit 1
|
|
fi
|
|
elif [[ "${RELEASE_CHANNEL}" == "canary" ]]; then
|
|
if [[ "${PW_VERSION}" != *-* ]]; then
|
|
echo "ERROR: cannot publish canary docker with Playwright version '${PW_VERSION}'"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "ERROR: unknown release channel - ${RELEASE_CHANNEL}"
|
|
echo "Must be either 'stable' or 'canary'"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "${GITHUB_SHA}" ]]; then
|
|
echo "ERROR: GITHUB_SHA env variable must be specified"
|
|
exit 1
|
|
fi
|
|
|
|
FOCAL_TAGS=(
|
|
"next"
|
|
"sha-${GITHUB_SHA}"
|
|
"next-focal"
|
|
"v${PW_VERSION}-focal"
|
|
)
|
|
|
|
if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
|
|
FOCAL_TAGS+=("focal")
|
|
fi
|
|
|
|
JAMMY_TAGS=(
|
|
"next-jammy"
|
|
"v${PW_VERSION}-jammy"
|
|
"v${PW_VERSION}"
|
|
)
|
|
|
|
if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
|
|
FOCAL_TAGS+=("latest")
|
|
FOCAL_TAGS+=("jammy")
|
|
fi
|
|
|
|
tag_and_push() {
|
|
local source="$1"
|
|
local target="$2"
|
|
echo "-- tagging: $target"
|
|
docker tag $source $target
|
|
docker push $target
|
|
}
|
|
|
|
publish_docker_images_with_arch_suffix() {
|
|
local FLAVOR="$1"
|
|
local TAGS=()
|
|
if [[ "$FLAVOR" == "focal" ]]; then
|
|
TAGS=("${FOCAL_TAGS[@]}")
|
|
elif [[ "$FLAVOR" == "jammy" ]]; then
|
|
TAGS=("${JAMMY_TAGS[@]}")
|
|
else
|
|
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'"
|
|
exit 1
|
|
fi
|
|
local ARCH="$2"
|
|
if [[ "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then
|
|
echo "ERROR: unknown arch - $ARCH. Must be either 'amd64' or 'arm64'"
|
|
exit 1
|
|
fi
|
|
# Prune docker images to avoid platform conflicts
|
|
docker system prune -fa
|
|
./build.sh "--${ARCH}" "${FLAVOR}" playwright:localbuild
|
|
|
|
for ((i = 0; i < ${#TAGS[@]}; i++)) do
|
|
local TAG="${TAGS[$i]}"
|
|
tag_and_push playwright:localbuild "playwright.azurecr.io/public/${MCR_IMAGE_NAME}:${TAG}-${ARCH}"
|
|
done
|
|
}
|
|
|
|
publish_docker_manifest () {
|
|
local FLAVOR="$1"
|
|
local TAGS=()
|
|
if [[ "$FLAVOR" == "focal" ]]; then
|
|
TAGS=("${FOCAL_TAGS[@]}")
|
|
elif [[ "$FLAVOR" == "jammy" ]]; then
|
|
TAGS=("${JAMMY_TAGS[@]}")
|
|
else
|
|
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'"
|
|
exit 1
|
|
fi
|
|
|
|
for ((i = 0; i < ${#TAGS[@]}; i++)) do
|
|
local TAG="${TAGS[$i]}"
|
|
local BASE_IMAGE_TAG="playwright.azurecr.io/public/${MCR_IMAGE_NAME}:${TAG}"
|
|
local IMAGE_NAMES=""
|
|
if [[ "$2" == "arm64" || "$2" == "amd64" ]]; then
|
|
IMAGE_NAMES="${IMAGE_NAMES} ${BASE_IMAGE_TAG}-$2"
|
|
fi
|
|
if [[ "$3" == "arm64" || "$3" == "amd64" ]]; then
|
|
IMAGE_NAMES="${IMAGE_NAMES} ${BASE_IMAGE_TAG}-$3"
|
|
fi
|
|
docker manifest create "${BASE_IMAGE_TAG}" $IMAGE_NAMES
|
|
docker manifest push "${BASE_IMAGE_TAG}"
|
|
done
|
|
}
|
|
|
|
publish_docker_images_with_arch_suffix focal amd64
|
|
publish_docker_images_with_arch_suffix focal arm64
|
|
publish_docker_manifest focal amd64 arm64
|
|
|
|
publish_docker_images_with_arch_suffix jammy amd64
|
|
publish_docker_images_with_arch_suffix jammy arm64
|
|
publish_docker_manifest jammy amd64 arm64
|
|
|