diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..eb1d907 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4d19440 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/Makefile b/Makefile index 2a47c4d..f9dc823 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 04cfb83..70ed3bf 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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+. @@ -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 ``` @@ -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 diff --git a/Scripts/info.json b/Scripts/info.json new file mode 100644 index 0000000..38da179 --- /dev/null +++ b/Scripts/info.json @@ -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" + ] + } + ] + } + } +} diff --git a/Scripts/release-artifactbundle.sh b/Scripts/release-artifactbundle.sh new file mode 100755 index 0000000..b48f33c --- /dev/null +++ b/Scripts/release-artifactbundle.sh @@ -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"