infrastructure/machines/compute01/ds-fr/package/update.sh
Tom Hubrecht d307727947
All checks were successful
build configuration / build_compute01 (push) Successful in 56s
build configuration / build_storage01 (push) Successful in 1m3s
build configuration / build_vault01 (push) Successful in 45s
build configuration / build_web01 (push) Successful in 1m6s
build configuration / build_web02 (push) Successful in 46s
lint / check (push) Successful in 21s
npins update / npins_update (push) Successful in 1m19s
fix(workflows/ds-fr): Format the new files, as to not open spurious PRs
2024-02-07 18:47:45 +01:00

72 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
version=
gitArgs=
while [ "$#" -gt 0 ]; do
i="$1"
shift 1
case "$i" in
--version | -v)
version="$1"
shift 1
;;
--git-args)
gitArgs="$gitArgs $1"
shift 1
;;
*)
echo "$0: unknown option \`$i'"
exit 1
;;
esac
done
# Create a working environment
CWD=$(pwd)
TMP=$(mktemp -d)
cd "$TMP"
# Fetch the latest source or the required version
gitUrl="https://github.com/demarches-simplifiees/demarches-simplifiees.fr.git"
if [ -n "$version" ]; then
git clone --depth 1 --branch $version $gitUrl .
else
git clone --depth 1 $gitUrl .
version="$(git rev-parse HEAD)"
fi
echo "[+] ds-fr version:"
echo "- $version"
# Generate gemset.nix
echo "[+] Updating gem files"
nix-shell -p bundix --run "bundix -l" >/dev/null
# Copy the new files
cp gemset.nix Gemfile Gemfile.lock "$CWD/rubyEnv/"
# Print the new source details
echo "[+] New hash:"
SRC_HASH=$(nix-shell -p nurl --run "nurl --hash $gitUrl $version")
# Print Yarn deps hash
echo "[+] New dependencies hash:"
hash=$(nix-shell -p prefetch-yarn-deps --run "prefetch-yarn-deps yarn.lock")
DEPS_HASH=$(nix-hash --to-sri --type sha256 "$hash")
cat <<EOF >"$CWD/meta.nix"
{
version = "$version";
src-hash = "$SRC_HASH";
deps-hash = "$DEPS_HASH";
}
EOF
nixfmt .
rm -rf "$TMP"