From 368b712d0dc61eaff3798827cd445faac844e7bc Mon Sep 17 00:00:00 2001 From: Philipp Schmid Date: Sun, 10 Aug 2025 18:34:37 -0700 Subject: [PATCH 1/2] initial version of create-archive for use with homebrew. This archives the source (using git archive) --- scripts/create-archive.sh | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 scripts/create-archive.sh diff --git a/scripts/create-archive.sh b/scripts/create-archive.sh new file mode 100755 index 000000000..4679ea643 --- /dev/null +++ b/scripts/create-archive.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# --- Script to Create and Tag a Release Archive for Homebrew --- +# This script should be run from the root of your mercersoft/cycod repository. +# It creates a gzipped tar archive, calculates its SHA-256 checksum, +# and creates a Git tag for a new release. + +# Exit immediately if a command exits with a non-zero status. +set -e + +# --- Configuration --- +# Set the desired version number as an argument to the script. +# Example usage: ./create_archive.sh 1.0.1 +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "Example: $0 1.0.1" + exit 1 +fi + +VERSION="v$1" +ARCHIVE_NAME="cycod-archive-${VERSION}.tar.gz" + +echo "--- Creating release for version: ${VERSION} ---" + +# --- Create the Tarball --- +# We use 'git archive' to create the tarball from the latest commit, +# which ensures we get a clean copy without any uncommitted changes or .git folder. +# We then pipe the output to 'gzip' to compress it. +echo "Creating archive file: ${ARCHIVE_NAME}..." +git archive --format=tar --prefix="cycod-${VERSION}/" HEAD | gzip > "${ARCHIVE_NAME}" + +# --- Calculate the SHA-256 Checksum --- +# This checksum is a critical component of the Homebrew formula for security +# and integrity verification. +echo "Calculating SHA-256 checksum..." +SHA256_CHECKSUM=$(shasum -a 256 "${ARCHIVE_NAME}" | awk '{print $1}') +echo "SHA-256: ${SHA256_CHECKSUM}" + +# --- Create and Push the Git Tag --- +# An annotated tag is best practice for releases as it contains a message. +echo "Creating and pushing Git tag: ${VERSION}..." +git tag -a "${VERSION}" -m "Release ${VERSION}" +git push origin "${VERSION}" + +# --- Clean up the local archive file --- +echo "Cleaning up local archive file..." +rm "${ARCHIVE_NAME}" + +# --- Provide Homebrew formula snippet --- +# This is the information you will need to add to your Homebrew formula. +echo "" +echo "-----------------------------------" +echo "✅ Done! Use the following in your Homebrew formula:" +echo "-----------------------------------" +echo " url \"https://github.com/robch/cycod/archive/refs/tags/${VERSION}.tar.gz\"" +echo " sha256 \"${SHA256_CHECKSUM}\"" +echo "" From 42ce1f391d044dfcde4166ab73b7e35294d5e28b Mon Sep 17 00:00:00 2001 From: mercersoft Date: Wed, 22 Oct 2025 11:59:52 -0700 Subject: [PATCH 2/2] added publish-homebrew.sh which uses the checksum from the github tar (so it matches with the server version that has a different timestamp). This replaces the older create-archive.sh script --- scripts/create-archive.sh | 57 ---------------------- scripts/publish-homebrew.sh | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 57 deletions(-) delete mode 100755 scripts/create-archive.sh create mode 100755 scripts/publish-homebrew.sh diff --git a/scripts/create-archive.sh b/scripts/create-archive.sh deleted file mode 100755 index 4679ea643..000000000 --- a/scripts/create-archive.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# --- Script to Create and Tag a Release Archive for Homebrew --- -# This script should be run from the root of your mercersoft/cycod repository. -# It creates a gzipped tar archive, calculates its SHA-256 checksum, -# and creates a Git tag for a new release. - -# Exit immediately if a command exits with a non-zero status. -set -e - -# --- Configuration --- -# Set the desired version number as an argument to the script. -# Example usage: ./create_archive.sh 1.0.1 -if [ -z "$1" ]; then - echo "Usage: $0 " - echo "Example: $0 1.0.1" - exit 1 -fi - -VERSION="v$1" -ARCHIVE_NAME="cycod-archive-${VERSION}.tar.gz" - -echo "--- Creating release for version: ${VERSION} ---" - -# --- Create the Tarball --- -# We use 'git archive' to create the tarball from the latest commit, -# which ensures we get a clean copy without any uncommitted changes or .git folder. -# We then pipe the output to 'gzip' to compress it. -echo "Creating archive file: ${ARCHIVE_NAME}..." -git archive --format=tar --prefix="cycod-${VERSION}/" HEAD | gzip > "${ARCHIVE_NAME}" - -# --- Calculate the SHA-256 Checksum --- -# This checksum is a critical component of the Homebrew formula for security -# and integrity verification. -echo "Calculating SHA-256 checksum..." -SHA256_CHECKSUM=$(shasum -a 256 "${ARCHIVE_NAME}" | awk '{print $1}') -echo "SHA-256: ${SHA256_CHECKSUM}" - -# --- Create and Push the Git Tag --- -# An annotated tag is best practice for releases as it contains a message. -echo "Creating and pushing Git tag: ${VERSION}..." -git tag -a "${VERSION}" -m "Release ${VERSION}" -git push origin "${VERSION}" - -# --- Clean up the local archive file --- -echo "Cleaning up local archive file..." -rm "${ARCHIVE_NAME}" - -# --- Provide Homebrew formula snippet --- -# This is the information you will need to add to your Homebrew formula. -echo "" -echo "-----------------------------------" -echo "✅ Done! Use the following in your Homebrew formula:" -echo "-----------------------------------" -echo " url \"https://github.com/robch/cycod/archive/refs/tags/${VERSION}.tar.gz\"" -echo " sha256 \"${SHA256_CHECKSUM}\"" -echo "" diff --git a/scripts/publish-homebrew.sh b/scripts/publish-homebrew.sh new file mode 100755 index 000000000..9b50fc93f --- /dev/null +++ b/scripts/publish-homebrew.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# --- Script to Create and Tag a Release Archive for Homebrew --- +# This script should be run from the root of your mercersoft/cycod repository. +# It creates a Git tag for a new release, downloads the GitHub-generated archive, +# and calculates its SHA-256 checksum. + +# Exit immediately if a command exits with a non-zero status. +set -e + +# --- Configuration --- +# Set the desired version number as an argument to the script. +# Example usage: ./publish-homebrew.sh 1.0.1 +# If no version is provided, the script will suggest the next version + +if [ -z "$1" ]; then + # Get the latest tag + LATEST_TAG=$(git tag -l --sort=-v:refname | head -n 1) + + if [ -z "$LATEST_TAG" ]; then + # No tags exist yet, suggest v1.0.0 + SUGGESTED_VERSION="1.0.0" + else + # Parse the latest tag (format: v1.0.X) and increment the patch version + if [[ $LATEST_TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + NEXT_PATCH=$((PATCH + 1)) + SUGGESTED_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" + else + echo "Error: Could not parse latest tag: ${LATEST_TAG}" + echo "Please provide a version number manually." + echo "Usage: $0 " + echo "Example: $0 1.0.1" + exit 1 + fi + fi + + # Prompt the user + echo "Latest tag: ${LATEST_TAG:-none}" + echo "Suggested next version: v${SUGGESTED_VERSION}" + read -p "Use v${SUGGESTED_VERSION}? (y/n): " -n 1 -r + echo + + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Release cancelled." + exit 0 + fi + + VERSION="v${SUGGESTED_VERSION}" +else + VERSION="v$1" +fi +ARCHIVE_NAME="cycod-archive-${VERSION}.tar.gz" +GITHUB_URL="https://github.com/robch/cycod/archive/refs/tags/${VERSION}.tar.gz" + +echo "--- Creating release for version: ${VERSION} ---" + +# --- Create and Push the Git Tag --- +# An annotated tag is best practice for releases as it contains a message. +echo "Creating and pushing Git tag: ${VERSION}..." +git tag -a "${VERSION}" -m "Release ${VERSION}" +git push origin "${VERSION}" + +# --- Wait a moment for GitHub to process the tag --- +echo "Waiting for GitHub to process the tag..." +sleep 5 + +# --- Download the Archive from GitHub --- +# This ensures we get the exact same archive that Homebrew will download +echo "Downloading archive from GitHub: ${GITHUB_URL}..." +curl -L "${GITHUB_URL}" -o "${ARCHIVE_NAME}" + +# --- Calculate the SHA-256 Checksum --- +# This checksum is a critical component of the Homebrew formula for security +# and integrity verification. +echo "Calculating SHA-256 checksum..." +SHA256_CHECKSUM=$(shasum -a 256 "${ARCHIVE_NAME}" | awk '{print $1}') +echo "SHA-256: ${SHA256_CHECKSUM}" + +# --- Clean up the local archive file --- +echo "Cleaning up local archive file..." +rm "${ARCHIVE_NAME}" + +# --- Provide Homebrew formula snippet --- +# This is the information you will need to add to your Homebrew formula. +echo "" +echo "-----------------------------------" +echo "✅ Done! Use the following in your Homebrew formula:" +echo "-----------------------------------" +echo " url \"${GITHUB_URL}\"" +echo " sha256 \"${SHA256_CHECKSUM}\"" +echo ""