...

Text file src/edge-infra.dev/hack/scripts/release/release-publish-binaries.sh

Documentation: edge-infra.dev/hack/scripts/release

     1#!/usr/bin/env bash
     2usage() { echo "Usage: $0 [-c <bazel config>] [-r <commit range>]" 1>&2; exit 0; }
     3[ $# -eq 0 ] && usage
     4
     5set -u
     6
     7config=""
     8config_release=""
     9commit_range=""
    10
    11while getopts ":c:r:Rh" opt; do
    12    case $opt in 
    13        c) config="--config=$OPTARG" ;;
    14        R) config_release="--config=release";;
    15        r) commit_range="$OPTARG" ;;
    16        h | *) usage ;;
    17    esac
    18done
    19
    20push_edge_tarballs=false
    21push_remotecli_tarballs=false
    22push_edgeadmin_tarballs=false
    23
    24if [[ -n $commit_range ]]
    25then
    26    diff_labels=()
    27    edge_tarball_labels=(
    28        "//hack/release:edge_linux_tarball"
    29        "//hack/release:edge_darwin_tarball"
    30    )
    31    remotecli_tarball_labels=(
    32        "//hack/sds/release:remotecliv1_darwin_tarball"
    33        "//hack/sds/release:remotecliv1_linux_tarball"
    34        "//hack/sds/release:remotecli_darwin_tarball"
    35        "//hack/sds/release:remotecli_linux_tarball"
    36    )
    37    edgeadmin_tarball_labels=(
    38        "//hack/release:edgeadmin_darwin_tarball"
    39        "//hack/release:edgeadmin_linux_tarball"
    40    )
    41
    42    diff_label_file=$(bazel run //hack/build/ci/leaf -- -f --exclude-manual-tags --bazel-configs=$config $commit_range)
    43    read -d '' -r -a diff_labels < "$diff_label_file"
    44
    45    for label in "${edge_tarball_labels[@]}"; do
    46        if [[ "${diff_labels[*]}" =~ $label ]]; then
    47            echo "Found $label"
    48            push_edge_tarballs=true
    49            break
    50        fi
    51    done
    52
    53    for label in "${remotecli_tarball_labels[@]}"; do
    54        if [[ "${diff_labels[*]}" =~ $label ]]; then
    55            echo "Found $label"
    56            push_remotecli_tarballs=true
    57            break
    58        fi
    59    done
    60
    61    for label in "${edgeadmin_tarball_labels[@]}"; do
    62        if [[ "${diff_labels[*]}" =~ $label ]]; then
    63            echo "Found $label"
    64            push_edgeadmin_tarballs=true
    65            break
    66        fi
    67    done
    68    
    69else
    70    echo "commit range not set, pushing all tarballs"
    71    push_edge_tarballs=true
    72    push_remotecli_tarballs=true
    73    push_edgeadmin_tarballs=true
    74fi
    75
    76if [[ $push_edge_tarballs == false && $push_remotecli_tarballs == false && $push_edgeadmin_tarballs == false ]]; then
    77    echo "Edge tarballs not affected by changes, exiting"
    78    exit 0
    79fi
    80
    81if [[ $push_edge_tarballs == true ]]; then
    82    echo "Pushing edge tarball"
    83    bazel run "$config" "$config_release" hack/release:push_edge_tarballs 
    84fi
    85
    86if [[ $push_edgeadmin_tarballs == true ]]; then
    87    echo "Pushing edgeadmin tarball"
    88    bazel run "$config" "$config_release" hack/release:push_edgeadmin_tarballs 
    89fi
    90
    91if [[ $push_remotecli_tarballs == true ]]; then
    92    echo "Pushing Remote CLI tarball"
    93    bazel run "$config" "$config_release" hack/sds/release:push_remotecli_tarballs
    94fi
    95
    96exit 0

View as plain text