dotnet: improve language coverage of passthru.tests for dotnet sdks (#370789)
[NixPkgs.git] / pkgs / by-name / at / attic-client / update.sh
blobe6ec0ab1296b392f5a7c2f36c236a858feafb1bf
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p wget nix-prefetch-github jq coreutils
4 # shellcheck shell=bash
6 if [ -n "$GITHUB_TOKEN" ]; then
7 TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
8 fi
10 if [[ $# -gt 1 || $1 == -* ]]; then
11 echo "Regenerates packaging data for attic."
12 echo "Usage: $0 [git commit]"
13 exit 1
16 set -x
18 cd "$(dirname "$0")"
19 rev="$1"
21 set -euo pipefail
23 if [ -z "$rev" ]; then
24 rev="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/zhaofengli/attic/commits?per_page=1" | jq -r '.[0].sha')"
27 date="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/zhaofengli/attic/commits/$rev" | jq -r '.commit.author.date' | cut -dT -f1)"
29 version="0-unstable-$date"
31 # Sources
32 src_hash=$(nix-prefetch-github zhaofengli attic --rev "$rev" | jq -r .hash)
34 # Cargo.lock
35 src="https://raw.githubusercontent.com/zhaofengli/attic/$rev"
36 wget "${TOKEN_ARGS[@]}" "$src/Cargo.lock" -O Cargo.lock
38 sed -i -E -e "s#version = \".*\"#version = \"$version\"#" package.nix
39 sed -i -E -e "s#rev = \".*\"#rev = \"$rev\"#" package.nix
40 sed -i -E -e "s#hash = \".*\"#hash = \"$src_hash\"#" package.nix