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
87 changes: 87 additions & 0 deletions .github/workflows/release-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Release Trigger

# UI-driven releases: pick a bump type, this workflow bumps the version in
# the codebase, commits it, pushes a vX.Y.Z tag — and the tag push runs the
# existing `Release` workflow, which builds, attaches assets, and publishes
# the release with auto-generated notes.

on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version bump'
type: choice
required: true
default: 'patch'
options:
- major
- minor
- patch
- none

permissions:
contents: write

jobs:
bump-and-tag:
name: Bump version & push tag
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Configure git (github-actions bot)
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Compute new version
id: version
run: |
chmod +x Scripts/bump_version.sh
NEW_VERSION="$(Scripts/bump_version.sh "${{ inputs.bump_type }}")"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "Releasing v$NEW_VERSION (bump: ${{ inputs.bump_type }})"

- name: Guard — tag must not already exist
run: |
if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ steps.version.outputs.tag }} already exists. Use bump type 'none' only for re-releases of a version whose tag was deleted."
exit 1
fi

- name: Commit version bump
run: |
git add Sources/ClapCLIKit/ClapCLI.swift \
Sources/ClapApp/SettingsView.swift \
Scripts/Info.plist
if git diff --cached --quiet; then
if [ "${{ inputs.bump_type }}" != "none" ]; then
echo "::error::Version bump changed nothing — unexpected."
exit 1
fi
echo "No version change for bump type 'none'."
else
git commit -m "Bump version to ${{ steps.version.outputs.tag }}"
fi

- name: Push commit and tag
run: |
git push origin "HEAD:${{ github.ref_name }}"
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"

- name: Summary
run: |
{
echo "## Release triggered 🚀"
echo "- Tag: \`${{ steps.version.outputs.tag }}\`"
echo "- Bump: \`${{ inputs.bump_type }}\`"
echo "- The \`Release\` workflow is now building assets; the GitHub"
echo " release will appear with auto-generated notes when it finishes."
} >> "$GITHUB_STEP_SUMMARY"
1 change: 1 addition & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ clap list [--images] [--limit N] [--offset N]
clap search <query> [--regex <pat>] [--type text|image] [--limit N]
clap get <id>
clap copy <id>
clap add <text> | - insert entry (- reads stdin); alias: clap in
clap delete <id> | --text <text> | --regex <pat>
clap out [<id> | <exact text>] alias of delete
clap pin <id> / clap unpin <id>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ clap search <query> [--type text|image|shell] # Full-text search
clap search --regex "^docker.*" # Regex search
clap get <id> # Show entry (pipe-friendly raw output)
clap copy <id> # Copy entry to pasteboard
clap add <text> | - # Insert an entry (alias: clap in; use - for stdin)
echo "piped" | clap add - # Insert from a pipe
clap delete <id> | --text <str> | --regex <pat> # Delete entries (alias: clap out)
clap pin <id> / clap unpin <id> # Pin/unpin entries
clap clear [--force] # Wipe history (preserves pinned)
Expand Down
37 changes: 37 additions & 0 deletions Scripts/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# Bumps the release version across every file that stores it and prints the
# new version. Usage: Scripts/bump_version.sh <major|minor|patch|none>
set -euo pipefail

BUMP="${1:-}"
if [[ ! "$BUMP" =~ ^(major|minor|patch|none)$ ]]; then
echo "usage: $0 <major|minor|patch|none>" >&2
exit 2
fi

CLI_FILE="Sources/ClapCLIKit/ClapCLI.swift"
CURRENT="$(sed -n 's/^ public static let version = "\([0-9]*\.[0-9]*\.[0-9]*\)"/\1/p' "$CLI_FILE")"
if [[ -z "$CURRENT" ]]; then
echo "error: could not read current version from $CLI_FILE" >&2
exit 1
fi

IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "$BUMP" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
none) ;;
esac
NEW="$MAJOR.$MINOR.$PATCH"

if [[ "$NEW" == "$CURRENT" && "$BUMP" != "none" ]]; then
echo "error: version unchanged" >&2
exit 1
fi

sed -i '' "s/public static let version = \"$CURRENT\"/public static let version = \"$NEW\"/" "$CLI_FILE"
sed -i '' "s/clipboard & shell history manager · v$CURRENT/clipboard \& shell history manager · v$NEW/" \
Sources/ClapApp/SettingsView.swift
sed -i '' "s/<string>$CURRENT<\/string>/<string>$NEW<\/string>/" Scripts/Info.plist
echo "$NEW"
13 changes: 11 additions & 2 deletions Scripts/make_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ if [ -d "$ROOT/Resources" ]; then
cp -R "$ROOT/Resources/"* "$APP/Contents/Resources/" 2>/dev/null || true
fi

# Ad-hoc sign so the hotkey/app behave under Gatekeeper locally.
codesign --force --deep -s - --identifier "com.spongycode.clap" "$APP"
# Sign with the first available Apple Development identity so macOS
# services that require stable signing (e.g. SMAppService login items)
# accept the bundle; ad-hoc only as last resort.
SIGN_IDENTITY="$(security find-identity -v -p codesigning 2>/dev/null \
| awk '/Apple Development/ { print $2; exit }')"
if [ -n "$SIGN_IDENTITY" ]; then
echo "Signing with identity $SIGN_IDENTITY"
codesign --force --deep -s "$SIGN_IDENTITY" --identifier "com.spongycode.clap" "$APP"
else
codesign --force --deep -s - --identifier "com.spongycode.clap" "$APP"
fi

mkdir -p "$OUT/bin"
cp "$BIN/clap" "$OUT/bin/clap"
Expand Down
14 changes: 11 additions & 3 deletions Sources/ClapApp/Panel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,15 @@ final class PanelController: NSObject, NSWindowDelegate {
guard let self else { return }
let hasEntry = (newID != nil)
if hasEntry {
self.appState.slideout.cancelCloseIfNoSelection()
if self.appState.slideout.state.isOpen {
// Already open: stays open, preview content updates live
} else if self.panel.isVisible {
self.appState.slideout.startAutoOpen()
}
} else {
self.appState.slideout.cancelAutoOpen()
if self.appState.slideout.state.isOpen {
self.appState.slideout.closePreview(animated: self.panel.isVisible)
}
self.appState.slideout.scheduleCloseIfNoSelection()
}
}

Expand Down Expand Up @@ -214,6 +213,15 @@ final class PanelController: NSObject, NSWindowDelegate {
rememberCurrentFrame()
}

func windowDidResize(_ notification: Notification) {
// Live-sync while dragging an edge with the preview open; the list
// absorbs the delta and the pane keeps its width.
guard appState.slideout.state == .open else { return }
appState.slideout.contentWidth = max(
appState.slideout.minimumContentWidth,
panel.frame.width - appState.slideout.slideoutWidth)
}

func windowDidEndLiveResize(_ notification: Notification) {
let width = panel.frame.width
let slideout = appState.slideout
Expand Down
Loading
Loading