Merge pull request #245835 from janvotava/master

This commit is contained in:
Janik 2023-09-18 10:05:11 +02:00 committed by GitHub
commit 48a3b243cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 0 deletions

View File

@ -23,6 +23,8 @@ buildGoModule rec {
# Some tests require running Kubernetes instance
doCheck = false;
passthru.updateScript = ./update.sh;
ldflags = [
"-s"
"-w"

View File

@ -0,0 +1,45 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix jq
set -euo pipefail
PKG_DIR=$(dirname "${BASH_SOURCE[@]}")
FILE="$PKG_DIR/default.nix"
NIXPKGS_ROOT=$(cd $PKG_DIR && git rev-parse --show-toplevel)
ATTR="timoni"
PREV_VERSION=$(nix eval --raw -f $NIXPKGS_ROOT/default.nix $ATTR.version)
LATEST_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/stefanprodan/timoni/releases/latest | jq -r '.tag_name')
NEXT_VERSION=$(echo ${LATEST_TAG} | sed 's/^v//')
# update version
sed -i "s|$PREV_VERSION|$NEXT_VERSION|" "$FILE"
# update hash
PREV_HASH=$(nix eval --raw -f $NIXPKGS_ROOT/default.nix $ATTR.src.outputHash)
NEXT_HASH=$(nix hash to-sri --type sha256 $(nix-prefetch-url --unpack --type sha256 $(nix eval --raw -f $NIXPKGS_ROOT/default.nix $ATTR.src.url)))
sed -i "s|$PREV_HASH|$NEXT_HASH|" "$FILE"
# update vendor hash
PREV_VENDOR_HASH=$(nix eval --raw -f $NIXPKGS_ROOT/default.nix $ATTR.vendorHash)
EMPTY_HASH="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
sed -i "s|$PREV_VENDOR_HASH|$EMPTY_HASH|" "$FILE"
set +e
NEXT_VENDOR_HASH=$(nix-build $NIXPKGS_ROOT --no-out-link -A $ATTR 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e
if [ -z "${NEXT_VENDOR_HASH:-}" ]; then
echo "Update failed. NEXT_VENDOR_HASH is empty." >&2
exit 1
fi
sed -i "s|$EMPTY_HASH|$NEXT_VENDOR_HASH|" "$FILE"
cat <<EOF
[{
"attrPath": "$ATTR",
"oldVersion": "$PREV_VERSION",
"newVersion": "$NEXT_VERSION",
"files": ["$PWD/default.nix.nix"]
}]
EOF