21 lines
945 B
Bash
Executable file
21 lines
945 B
Bash
Executable file
#!/usr/bin/env nix-shell
|
|
#!nix-shell -p nix-prefetch-git -p jq -i bash
|
|
|
|
set -euo pipefail
|
|
|
|
MYTMPDIR="$(mktemp -d)"
|
|
trap 'rm -rf -- "$MYTMPDIR"' EXIT
|
|
|
|
LATEST_VERSION="$(curl --silent -L https://raw.githubusercontent.com/RogueMaster/flipperzero-firmware-wPlugins/HEAD/ReadMe.md | grep -oP '(?<=Latest Release )[^\]]+')"
|
|
echo "Latest version $LATEST_VERSION" >&2
|
|
|
|
UPSTREAM_VERSION="$(echo "${LATEST_VERSION}" | grep -oP '^RM[^-]+-[^-]+-\K([^-]+)(?=-[0-9a-f]+)')"
|
|
echo "Upstream version $UPSTREAM_VERSION" >&2
|
|
|
|
GIT_HASH="$(echo "${LATEST_VERSION}" | grep -oP '^RM[^-]+-[^-]+-([^-]+)-\K[0-9a-f]+')"
|
|
echo "Git hash $GIT_HASH"
|
|
|
|
nix-prefetch-git --fetch-submodules --url "https://github.com/RogueMaster/flipperzero-firmware-wPlugins" --rev "${GIT_HASH}" > $MYTMPDIR/prefetch.json
|
|
jq . $MYTMPDIR/prefetch.json >&2
|
|
|
|
jq "{\"src\": ., \"version\": \"${LATEST_VERSION}\", \"upstreamVersion\": \"${UPSTREAM_VERSION}\"}" $MYTMPDIR/prefetch.json > version.json
|