#!/bin/bash # Calculate dependency hash for Docker cache tag # This script calculates the hash used for the build cache image tag # Calculate hash of go.mod + go.sum # Use shasum on macOS, sha256sum on Linux if command -v sha256sum >/dev/null 2>&1; then DEPS_HASH=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1 | head -c 12) else DEPS_HASH=$(shasum -a 256 go.mod go.sum | shasum -a 256 | cut -d' ' -f1 | head -c 12) fi echo "Dependency hash: $DEPS_HASH" echo "$DEPS_HASH" # Export for use in other scripts if [ -n "$1" ]; then echo "DEPS_HASH=$DEPS_HASH" > "$1" echo "Exported to: $1" fi