Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / tools / tailwindcss / update.sh
blobb3a9ccf37819fc23d5751b6a9edb7b3fb2321983
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused jq nix-prefetch
3 set -eou pipefail
5 ROOT="$(dirname "$(readlink -f "$0")")"
7 CURRENT_VERSION=$(nix-instantiate --eval --strict --json -A tailwindcss.version . | jq -r .)
8 LATEST_VERSION=$(curl --fail --silent https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | jq --raw-output .tag_name | sed 's/v//')
9 sed -i "s/version = \".*\"/version = \"${LATEST_VERSION}\"/" "$ROOT/default.nix"
11 if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
12 echo "tailwindcss already at latest version $CURRENT_VERSION, exiting"
13 exit 0
16 function updatePlatform() {
17 NIXPLAT=$1
18 TAILWINDPLAT=$2
19 echo "Updating tailwindcss for $NIXPLAT"
21 URL="https://github.com/tailwindlabs/tailwindcss/releases/download/v${LATEST_VERSION}/tailwindcss-${TAILWINDPLAT}"
22 HASH=$(nix hash to-sri --type sha256 "$(nix-prefetch-url --type sha256 "$URL")")
24 sed -i "s,$NIXPLAT = \"sha256.*\",$NIXPLAT = \"${HASH}\"," "$ROOT/default.nix"
27 updatePlatform aarch64-darwin macos-arm64
28 updatePlatform aarch64-linux linux-arm64
29 updatePlatform armv7l-linux linux-armv7
30 updatePlatform x86_64-darwin macos-x64
31 updatePlatform x86_64-linux linux-x64