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

on:
release:
types: [created]

jobs:
build-and-release:
runs-on: macos-15
env:
DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer"
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Run tests
run: make test

- name: Build universal binary
run: make build-universal

- name: Get release tag
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Create artifact bundle
run: ./Scripts/release-artifactbundle.sh "${{ env.TAG_NAME }}"

- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: |
xpbc-macos.artifactbundle.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
test:
runs-on: macos-15
env:
DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer"
steps:
- uses: actions/checkout@v6
- name: Run tests
run: make test
- name: Release build (universal)
run: make build-universal
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
PREFIX ?= /usr/local

.PHONY: build install test clean
.PHONY: build build-universal install test clean

build:
swift build -c release

build-universal:
swift build -c release --arch arm64 --arch x86_64

install: build
install -d $(PREFIX)/bin
install .build/release/xpbc $(PREFIX)/bin/xpbc
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# xpbc

[![Test](https://github.com/chigichan24/xpbc/actions/workflows/test.yml/badge.svg)](https://github.com/chigichan24/xpbc/actions/workflows/test.yml)

**eXtended PasteBoard Copy** — a drop-in enhancement for macOS `pbcopy` that supports images.

`pbcopy` only handles text. `xpbc` automatically detects whether stdin contains image data and copies it to the clipboard as an image. For plain text, it behaves exactly like `pbcopy`.
Expand All @@ -18,6 +20,19 @@ echo "hello" | xpbc

## Installation

### Pre-built binary

Download the latest universal binary (arm64 + x86_64) from [Releases](https://github.com/chigichan24/xpbc/releases):

```sh
# Download and extract
curl -LO https://github.com/chigichan24/xpbc/releases/latest/download/xpbc-macos.artifactbundle.zip
unzip xpbc-macos.artifactbundle.zip

# Copy to your PATH
cp xpbc.artifactbundle/xpbc-*/bin/xpbc /usr/local/bin/
```

### From source

Requires Swift 6.0+ and macOS 13+.
Expand All @@ -34,13 +49,6 @@ This installs the binary to `/usr/local/bin`. To change the install location:
make install PREFIX=~/.local
```

### Manual

```sh
swift build -c release
cp .build/release/xpbc /usr/local/bin/
```

## Usage

```
Expand Down Expand Up @@ -101,9 +109,10 @@ Anything that doesn't match a known image signature is copied as text.
## Building & Testing

```sh
make build # Release build
make test # Run tests
make clean # Clean build artifacts
make build # Release build (host architecture)
make build-universal # Release build (arm64 + x86_64)
make test # Run tests
make clean # Clean build artifacts
```

## Security
Expand Down
18 changes: 18 additions & 0 deletions Scripts/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"schemaVersion": "1.0",
"artifacts": {
"xpbc": {
"version": "__VERSION__",
"type": "executable",
"variants": [
{
"path": "xpbc-__VERSION__-macos/bin",
"supportedTriples": [
"arm64-apple-macosx",
"x86_64-apple-macosx"
]
}
]
}
}
}
12 changes: 12 additions & 0 deletions Scripts/release-artifactbundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail

VERSION_STRING="$1"

mkdir -p "xpbc.artifactbundle/xpbc-$VERSION_STRING-macos/bin"

sed "s/__VERSION__/$VERSION_STRING/g" ./Scripts/info.json > "xpbc.artifactbundle/info.json"

cp -f "./.build/apple/Products/Release/xpbc" "xpbc.artifactbundle/xpbc-$VERSION_STRING-macos/bin"

zip -yr - "xpbc.artifactbundle" > "./xpbc-macos.artifactbundle.zip"