summaryrefslogtreecommitdiffhomepage
path: root/scripts/commit-relay-list
blob: 2050122f8a0a6974edfab2f8f6317f9881c40f67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash

# Downloads the latest relay list from the Mullvad API into
# dist-assets/relays/relays.json and, if the file changed, creates a signed
# commit. The relay list is bundled with both the desktop and Android
# release artifacts so the daemon has an offline copy on first launch.
#
# Usage: commit-relay-list <PRODUCT_VERSION>

set -eu

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR/.."

if [[ $# -ne 1 ]]; then
    echo "Usage: $0 <PRODUCT_VERSION>" >&2
    exit 1
fi

PRODUCT_VERSION="$1"

echo "### Generating relay list ###"
cargo run -q -p mullvad-api --bin relay_list > dist-assets/relays/relays.json
if [[ ! -s dist-assets/relays/relays.json ]]; then
    echo "Error: Relay list missing or empty." >&2
    exit 1
elif git diff -s --exit-code dist-assets/relays/relays.json; then
    echo "Relay list unchanged, skipping commit."
else
    git add dist-assets/relays/relays.json
    git commit -S -m "Add relay list to bundle with $PRODUCT_VERSION"
fi