Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "textstep"
version = "1.2.4"
version = "1.2.5"
edition = "2024"

[dependencies]
Expand Down
24 changes: 24 additions & 0 deletions Formula/textstep.rb
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions scripts/update-formula.sh
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod presets;
mod sequencer;
mod ui;

use std::env;
use std::io;
use std::sync::Arc;
use std::time::Duration;
Expand All @@ -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<String> = 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);
Expand Down
Loading