2021-09-22 21:12:52 +01:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl gnugrep gnused jq
|
|
|
|
|
2021-10-14 18:59:33 +01:00
|
|
|
set -x -eu -o pipefail
|
2021-09-22 21:12:52 +01:00
|
|
|
|
|
|
|
cd $(dirname "${BASH_SOURCE[0]}")
|
|
|
|
|
|
|
|
TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/fluxcd/flux2/releases/latest | jq -r '.tag_name')
|
|
|
|
|
|
|
|
VERSION=$(echo ${TAG} | sed 's/^v//')
|
|
|
|
|
|
|
|
SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/archive/refs/tags/${TAG}.tar.gz)
|
|
|
|
|
|
|
|
SPEC_SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/releases/download/${TAG}/manifests.tar.gz)
|
|
|
|
|
|
|
|
setKV () {
|
2021-10-14 18:59:33 +01:00
|
|
|
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix
|
2021-09-22 21:12:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setKV version ${VERSION}
|
|
|
|
setKV sha256 ${SHA256}
|
|
|
|
setKV manifestsSha256 ${SPEC_SHA256}
|
|
|
|
setKV vendorSha256 ""
|
|
|
|
|
|
|
|
cd ../../../../../
|
|
|
|
set +e
|
2021-10-14 18:59:33 +01:00
|
|
|
VENDOR_SHA256=$(nix-build --no-out-link -A fluxcd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
|
2021-09-22 21:12:52 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
cd - > /dev/null
|
2021-10-14 18:59:33 +01:00
|
|
|
|
|
|
|
if [ -n "${VENDOR_SHA256:-}" ]; then
|
|
|
|
setKV vendorSha256 ${VENDOR_SHA256}
|
|
|
|
else
|
|
|
|
echo "Update failed. VENDOR_SHA256 is empty."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|