load("@build_bazel_apple_support//xcode:xcode_config.bzl", "xcode_config")
load("@build_bazel_apple_support//xcode:xcode_version.bzl", "xcode_version")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

sh_test(
    name = "release_prep_test",
    srcs = ["workflows/release_prep_test.sh"],
    data = [
        "workflows/release_prep.sh",
        "@jq_toolchains//:resolved_toolchain",
    ],
    env = {
        "JQ_BIN": "$(JQ_BIN)",
    },
    target_compatible_with = select({
        "@platforms//os:windows": ["@platforms//:incompatible"],
        "//conditions:default": [],
    }),
    toolchains = ["@jq_toolchains//:resolved_toolchain"],
    deps = ["@bazel_tools//tools/bash/runfiles"],
)

# This information is extracted from the MacOS runner specs located at:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
#
# When updating, also ensure the "xcode_destination" entries in
# `.github/workflows/test_objectivec.yml` are supported for the given versions
# of Xcode.
xcode_version(
    name = "version16_0",
    aliases = [
        "160",
        "16.0",
    ],
    default_ios_sdk_version = "17.2",
    default_macos_sdk_version = "14.2",
    default_tvos_sdk_version = "17.2",
    default_watchos_sdk_version = "10.2",
    version = "16.0",
)

xcode_version(
    name = "version15_2_15C500b",
    aliases = [
        "15C500b",
        "15.2",
    ],
    default_ios_sdk_version = "17.2",
    default_macos_sdk_version = "14.2",
    default_tvos_sdk_version = "17.2",
    default_watchos_sdk_version = "10.2",
    version = "15.2.0.15C500b",
)

xcode_version(
    name = "version14_2_14C18",
    aliases = [
        "14C18",
        "14.2",
    ],
    default_ios_sdk_version = "16.2",
    default_macos_sdk_version = "13.1",
    default_tvos_sdk_version = "16.1",
    default_watchos_sdk_version = "9.1",
    version = "14.2.0.14C18",
)

xcode_version(
    name = "version14_1_0_14B47b",
    aliases = [
        "14B47b",
        "14.1",
    ],
    default_ios_sdk_version = "16.1",
    default_macos_sdk_version = "13.0",
    default_tvos_sdk_version = "16.1",
    default_watchos_sdk_version = "9.1",
    version = "14.1.0.14B47b",
)

xcode_config(
    name = "host_xcodes",
    default = ":version15_2_15C500b",
    versions = [
        ":version15_2_15C500b",
        ":version14_2_14C18",
        ":version14_1_0_14B47b",
    ],
)

# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
xcode_config(
    name = "host_xcodes_macos15",
    default = ":version16_0",
    versions = [":version16_0"],
)
