1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p coreutils common-updater-scripts curl jq nix-update
3
4# This update script exists, because nix-update is unable to ignore various
5# bogus tags that exist on the upstream repo e.g.
6# - selectors-v0.18.0/v0.20.0/v0.21.0/v0.22.0
7# - homu-tmp
8#
9# Once https://github.com/Mic92/nix-update/issues/322 is resolved it can be
10# removed.
11
12set -exuo pipefail
13
14# Determine latest commit id and date
15TMP=$(mktemp)
16curl -o "$TMP" https://api.github.com/repos/servo/servo/commits/main
17COMMIT_ID=$(jq -r '.sha' "$TMP")
18COMMIT_TIMESTAMP=$(jq -r '.commit.author.date' "$TMP")
19COMMIT_DATE=$(date -d "$COMMIT_TIMESTAMP" +"%Y-%m-%d")
20rm $TMP
21
22cd "$(git rev-parse --show-toplevel)"
23
24# Update version, src
25update-source-version servo "0-unstable-${COMMIT_DATE}" --file=pkgs/by-name/se/servo/package.nix --rev="$COMMIT_ID"
26
27# Update cargoHash
28nix-update --version=skip servo