2022-10-21 18:38:19 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2023-07-15 17:15:38 +00:00
|
|
|
#!nix-shell -i bash -p curl gnused nix-prefetch common-updater-scripts node2nix
|
2022-10-21 18:38:19 +00:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
root="$(dirname "$(readlink -f "$0")")"
|
2023-07-15 17:15:38 +00:00
|
|
|
driver_file="$root/../../web/playwright/driver.nix"
|
|
|
|
playwright_test="$root/../../web/playwright-test"
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
version=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -s https://api.github.com/repos/microsoft/playwright-python/releases/latest | jq -r '.tag_name | sub("^v"; "")')
|
|
|
|
|
|
|
|
# Most of the time, this should be the latest stable release of the Node-based
|
|
|
|
# Playwright version, but that isn't a guarantee, so this needs to be specified
|
|
|
|
# as well:
|
|
|
|
setup_py_url="https://github.com/microsoft/playwright-python/raw/v${version}/setup.py"
|
|
|
|
driver_version=$(curl -Ls "$setup_py_url" | grep '^driver_version =' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
|
|
|
|
|
|
|
fetch_driver_arch() {
|
2023-07-15 17:15:38 +00:00
|
|
|
nix-prefetch-url "https://playwright.azureedge.net/builds/driver/playwright-${driver_version}-${1}.zip"
|
2022-10-21 18:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
replace_sha() {
|
2023-07-15 17:15:38 +00:00
|
|
|
sed -i "s|$1 = \".\{44,52\}\"|$1 = \"$2\"|" "$driver_file"
|
2022-10-21 18:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Replace SHAs for the driver downloads
|
|
|
|
replace_sha "x86_64-linux" "$(fetch_driver_arch "linux")"
|
|
|
|
replace_sha "x86_64-darwin" "$(fetch_driver_arch "mac")"
|
|
|
|
replace_sha "aarch64-linux" "$(fetch_driver_arch "linux-arm64")"
|
|
|
|
replace_sha "aarch64-darwin" "$(fetch_driver_arch "mac-arm64")"
|
|
|
|
|
|
|
|
# Update the version stamps
|
2023-07-15 17:15:38 +00:00
|
|
|
sed -i "s/version =\s*\"[^\$]*\"/version = \"$driver_version\"/" "$driver_file"
|
|
|
|
sed -i "s/\"@playwright\/test\": \"[^\$]*\"/\"@playwright\/test\": \"$driver_version\"/" "$playwright_test/node-packages.json"
|
|
|
|
(cd "$playwright_test"; node2nix -i node-packages.json)
|
2022-10-21 18:38:19 +00:00
|
|
|
update-source-version playwright "$version" --rev="v$version"
|