Created
March 12, 2026 09:43
-
-
Save finsberg/2a42fb1a7ede21dae9468f0dbabb9cf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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}' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Finds the sha256 of a release on github. Usage e.g