From c5a8e8ca057d03c3b47c3c5ebb315e64535727a4 Mon Sep 17 00:00:00 2001 From: lobo Date: Thu, 12 Mar 2026 14:07:37 +0100 Subject: [PATCH] feat: add --version flag + Homebrew distribution - Add --version / -V flag (before audio init) - Bump version to 1.2.5 - Add Homebrew formula (Formula/textstep.rb) - Add scripts/update-formula.sh for manual SHA updates - Add CI step to auto-update homebrew-textstep tap on release Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- Formula/textstep.rb | 24 +++++++++++++++++++++++ scripts/update-formula.sh | 39 +++++++++++++++++++++++++++++++++++++ src/main.rs | 8 ++++++++ 6 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 Formula/textstep.rb create mode 100755 scripts/update-formula.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4218c16..8d97007 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -151,3 +151,30 @@ jobs: name: TextStep ${{ steps.version.outputs.tag }} generate_release_notes: true files: artifacts/*.tar.gz + + - name: Update Homebrew formula + if: steps.check-label.outputs.should-release == 'true' + env: + HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} + run: | + VERSION="${{ steps.version.outputs.version }}" + MACOS_SHA=$(shasum -a 256 artifacts/textstep-universal-apple-darwin.tar.gz | cut -d' ' -f1) + LINUX_SHA=$(shasum -a 256 artifacts/textstep-x86_64-unknown-linux-gnu.tar.gz | cut -d' ' -f1) + + git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/illobo/homebrew-textstep.git /tmp/homebrew-tap + cd /tmp/homebrew-tap + + # Update version + sed -i "s/^ version \".*\"/ version \"${VERSION}\"/" Formula/textstep.rb + + # Update macOS SHA256 (first sha256 line) + sed -i "0,/sha256 \"[a-f0-9]*\"/s/sha256 \"[a-f0-9]*\"/sha256 \"${MACOS_SHA}\"/" Formula/textstep.rb + + # Update Linux SHA256 (second sha256 line) + sed -i ":a;N;\$!ba;s/\(sha256 \"[a-f0-9]*\".*\)sha256 \"[a-f0-9]*\"/\1sha256 \"${LINUX_SHA}\"/" Formula/textstep.rb + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Formula/textstep.rb + git commit -m "Update textstep to v${VERSION}" + git push diff --git a/Cargo.lock b/Cargo.lock index 97e02e3..e503207 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1000,7 +1000,7 @@ dependencies = [ [[package]] name = "textstep" -version = "1.2.3" +version = "1.2.5" dependencies = [ "cpal", "crossbeam-channel", diff --git a/Cargo.toml b/Cargo.toml index 8befc89..ede3c4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "textstep" -version = "1.2.4" +version = "1.2.5" edition = "2024" [dependencies] diff --git a/Formula/textstep.rb b/Formula/textstep.rb new file mode 100644 index 0000000..5ab9f4a --- /dev/null +++ b/Formula/textstep.rb @@ -0,0 +1,24 @@ +class Textstep < Formula + desc "TUI step sequencer, drum machine, and synthesizer" + homepage "https://github.com/illobo/textStep" + version "1.2.5" + license "MIT" + + on_macos do + url "https://github.com/illobo/textStep/releases/download/v#{version}/textstep-universal-apple-darwin.tar.gz" + sha256 "bc937273465ad760699bbaacac2071f93bbb84317fe3cf7ec82a1934e7ad6ea3" + end + + on_linux do + url "https://github.com/illobo/textStep/releases/download/v#{version}/textstep-x86_64-unknown-linux-gnu.tar.gz" + sha256 "64d0eb9aa1a79c3b419729c0de21b3182e65bc2791b4c1d96a11e26e35d75535" + end + + def install + bin.install "textstep" + end + + test do + assert_match "textstep #{version}", shell_output("#{bin}/textstep --version") + end +end diff --git a/scripts/update-formula.sh b/scripts/update-formula.sh new file mode 100755 index 0000000..3446989 --- /dev/null +++ b/scripts/update-formula.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Updates the Homebrew formula with correct SHA256 hashes after a GitHub release. +# Usage: ./scripts/update-formula.sh [version] +# If version is omitted, reads from Cargo.toml. + +set -euo pipefail + +REPO="illobo/textStep" +FORMULA="Formula/textstep.rb" + +VERSION="${1:-$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')}" +echo "Updating formula for v${VERSION}..." + +MACOS_URL="https://github.com/${REPO}/releases/download/v${VERSION}/textstep-universal-apple-darwin.tar.gz" +LINUX_URL="https://github.com/${REPO}/releases/download/v${VERSION}/textstep-x86_64-unknown-linux-gnu.tar.gz" + +echo "Downloading macOS tarball..." +MACOS_SHA=$(curl -sL "$MACOS_URL" | shasum -a 256 | cut -d' ' -f1) +echo " SHA256: ${MACOS_SHA}" + +echo "Downloading Linux tarball..." +LINUX_SHA=$(curl -sL "$LINUX_URL" | shasum -a 256 | cut -d' ' -f1) +echo " SHA256: ${LINUX_SHA}" + +# Update version +sed -i '' "s/^ version \".*\"/ version \"${VERSION}\"/" "$FORMULA" + +# Update SHA256 hashes +# macOS sha is the first sha256 line, Linux is the second +awk -v macos="$MACOS_SHA" -v linux="$LINUX_SHA" ' + /on_macos/ { in_macos=1 } + /on_linux/ { in_macos=0; in_linux=1 } + /sha256/ && in_macos { sub(/"[^"]*"/, "\"" macos "\""); in_macos=0 } + /sha256/ && in_linux { sub(/"[^"]*"/, "\"" linux "\""); in_linux=0 } + { print } +' "$FORMULA" > "${FORMULA}.tmp" && mv "${FORMULA}.tmp" "$FORMULA" + +echo "Formula updated:" +grep -E '(version|sha256|url)' "$FORMULA" diff --git a/src/main.rs b/src/main.rs index 0c2491a..ad489c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ mod presets; mod sequencer; mod ui; +use std::env; use std::io; use std::sync::Arc; use std::time::Duration; @@ -24,6 +25,13 @@ use ratatui::Terminal; /// terminal, and enters the main UI loop. The audio stream is kept alive /// until this function returns. fn main() -> io::Result<()> { + // Handle --version / -V flag + let args: Vec = env::args().collect(); + if args.iter().any(|a| a == "--version" || a == "-V") { + println!("textstep {}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + // Create channels for UI <-> Audio communication let (tx_to_audio, rx_from_ui) = crossbeam_channel::bounded(64); let (tx_to_ui, rx_from_audio) = crossbeam_channel::bounded(16);