Skip to content

Instantly share code, notes, and snippets.

@finsberg
Created March 12, 2026 09:43
Show Gist options
  • Select an option

  • Save finsberg/2a42fb1a7ede21dae9468f0dbabb9cf8 to your computer and use it in GitHub Desktop.

Select an option

Save finsberg/2a42fb1a7ede21dae9468f0dbabb9cf8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check if both arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <owner/repo> <tag>"
echo "Example: $0 scientificcomputing/io4dolfinx v1.1.2"
exit 1
fi
REPO=$1
TAG=$2
URL="https://github.com/${REPO}/archive/refs/tags/${TAG}.tar.gz"
# Check for the available hashing command (Linux vs macOS)
if command -v sha256sum >/dev/null 2>&1; then
HASH_CMD="sha256sum"
elif command -v shasum >/dev/null 2>&1; then
HASH_CMD="shasum -a 256"
else
echo "Error: Neither 'sha256sum' nor 'shasum' was found on your system."
exit 1
fi
# Fetch the tarball, pipe it to the hash command, and use awk to return only the hash
curl -sL "$URL" | $HASH_CMD | awk '{print $1}'
@finsberg
Copy link
Author

Finds the sha256 of a release on github. Usage e.g

gh-256 finsberg/fenicsx-beat v0.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment