From 102756979d60316b179aeddf3f24224884def2fd Mon Sep 17 00:00:00 2001 From: Kazuki Chigita Date: Sat, 21 Mar 2026 23:22:01 +0900 Subject: [PATCH 1/3] Add CI/CD workflows for testing and release - test.yml: runs tests and universal build on push/PR to main - release.yml: builds universal binary, creates artifact bundle, and uploads to GitHub release - Makefile: add build-universal target for arm64+x86_64 - Scripts: artifact bundle creation for Swift package distribution Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/release.yml | 34 +++++++++++++++++++++++++++++++ .github/workflows/test.yml | 19 +++++++++++++++++ Makefile | 5 ++++- Scripts/info.json | 18 ++++++++++++++++ Scripts/release-artifactbundle.sh | 12 +++++++++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 Scripts/info.json create mode 100755 Scripts/release-artifactbundle.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..49b958d --- /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@v4 + + - 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@v1 + 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..ea02d00 --- /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@v4 + - 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/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" From 07386678d3f337f96814629b280f7fd20ddec929 Mon Sep 17 00:00:00 2001 From: Kazuki Chigita Date: Sat, 21 Mar 2026 23:23:20 +0900 Subject: [PATCH 2/3] Bump actions/checkout to v6 and softprops/action-gh-release to v2 Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49b958d..eb1d907 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer" steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Run tests run: make test @@ -26,7 +26,7 @@ jobs: run: ./Scripts/release-artifactbundle.sh "${{ env.TAG_NAME }}" - name: Upload release assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | xpbc-macos.artifactbundle.zip diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea02d00..4d19440 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: env: DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Run tests run: make test - name: Release build (universal) From ff4886e833e9677d52853568a50ee58ed037fcba Mon Sep 17 00:00:00 2001 From: Kazuki Chigita Date: Sat, 21 Mar 2026 23:24:42 +0900 Subject: [PATCH 3/3] Update README with CI badge, pre-built binary install, and build-universal Co-Authored-By: Claude Opus 4.6 (1M context) --- README.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) 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