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")
10 if [[ $# -gt 1 ||
$1 == -* ]]; then
11 echo "Regenerates packaging data for attic."
12 echo "Usage: $0 [git commit]"
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"
32 src_hash
=$
(nix-prefetch-github zhaofengli attic
--rev "$rev" | jq
-r .
hash)
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