PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
#!/usr/bin/env bash
# 构建并打出可分发的发布包到 release/。
#
# PasteFerry-mac-apple-silicon.dmg macOS 客户端,Apple 芯片(M1 及更新)
# PasteFerry-mac-intel.dmg macOS 客户端,Intel 芯片
# PasteFerry.dmg macOS 客户端,两种芯片通用(体积约为单芯片版的两倍;
# 早期版本的下载链接指向它,一直保留)
# pasteferry-server-linux-amd64.tar.gz 信令服务器 + systemd / Docker 部署文件
# pasteferry-server-linux-arm64.tar.gz
# pasteferry-server-macos.tar.gz 把服务器放在其中一台 Mac 上时用(LaunchAgent 安装脚本)
# pasteferry-server-windows-amd64.zip 把服务器放在 Windows 电脑上时用(注册为系统服务)
#
# Windows 的安装程序与便携版(PasteFerry-Setup.exe、PasteFerry-windows-x64.zip)只能在 Windows 上
# 构建:由 CI 的 Windows 任务运行 scripts/build-windows.ps1 产出,发布时从构建产物里取。
# Linux 的 .deb 与 tar.gz 同理,由 CI 的 Linux 任务运行 scripts/package-linux.sh 产出。
#
# 文件名不带版本号:网站与 README 用 releases/latest/download/<文件名> 直链下载,
# 带版本号的话每发一版这些链接都会失效。版本号见 Release 标题与 pasteferry-server -version。
# SHA256SUMS
#
# 服务器是纯 Go,直接交叉编译;客户端依赖 cgo 与 Flutter,只能在 Mac 上构建。
set -euo pipefail
cd "$(dirname "$0")/.."
export VERSION=${VERSION:-2.10.1}
OUT=release
# 发布包一定要用 PasteFerry Code Signing 证书签名,没有就停下(见 scripts/sign.sh)
export REQUIRE_SIGNING=1
./scripts/build.sh
echo
# 拆出单一芯片的版本后重新签名,和 build.sh 用同一个签名身份
# shellcheck source=sign.sh
source scripts/sign.sh
rm -rf "$OUT" && mkdir -p "$OUT"
STAGE=$(mktemp -d)
trap 'rm -rf "$STAGE"' EXIT
# ─────────────────────────── DMG ───────────────────────────
# Finder 窗口的版式与 tools/dmg/background.swift 画的背景一一对应。
# 需要「自动化」权限去控制 Finder;拿不到就跳过,DMG 照样能装,只是图标排布是默认的。
layout_dmg() {
osascript >/dev/null <<EOF &
tell application "Finder"
tell disk "$1"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set bounds of container window to {200, 120, 840, 548}
set opts to icon view options of container window
set arrangement of opts to not arranged
set icon size of opts to 112
set text size of opts to 13
set background picture of opts to file ".background:background.tiff"
set position of item "PasteFerry.app" of container window to {160, 190}
set position of item "Applications" of container window to {480, 190}
update without registering applications
delay 1
close
end tell
end tell
EOF
local pid=$!
for _ in {1..60}; do
kill -0 "$pid" 2>/dev/null || { wait "$pid"; return $?; }
sleep 1
done
kill "$pid" 2>/dev/null
return 1
}
# thin_app 从通用 App 拆出单一芯片的版本:每个通用二进制只留一种架构,再由内向外重新签名
# (改了二进制,原来的签名就失效了,Apple 芯片上会拒绝运行)。
thin_app() { # <通用 App> <输出 App> <arm64 | x86_64>
local src=$1 dst=$2 arch=$3 f
ditto "$src" "$dst"
while IFS= read -r -d '' f; do
if lipo -archs "$f" 2>/dev/null | grep -qw arm64 && lipo -archs "$f" | grep -qw x86_64; then
lipo -thin "$arch" -output "$f.thin" "$f"
chmod "$(stat -f %Lp "$f")" "$f.thin"
mv "$f.thin" "$f"
fi
done < <(find "$dst" -type f -print0)
sign "$dst/Contents/Helpers/pasteferry-cli"
sign "$dst/Contents/Helpers/PasteFerryDaemon.app"
sign "$dst/Contents/Helpers/PasteFerryPicker.app"
sign "$dst/Contents/Frameworks/App.framework"
sign "$dst/Contents/Frameworks/FlutterMacOS.framework"
sign --preserve-metadata=entitlements,flags "$dst"
codesign --verify --deep --strict "$dst"
check_signed "$dst"
}
# 安装窗口的背景三个 DMG 共用
swift tools/dmg/background.swift "$STAGE/bg" >/dev/null
tiffutil -cathidpicheck "$STAGE/bg/background.png" "$STAGE/bg/[email protected]" \
-out "$STAGE/background.tiff" 2>/dev/null
make_dmg() { # <App> <输出文件名>
local app=$1 name=$2 vol=PasteFerry src="$STAGE/dmg-$2" mnt
mkdir -p "$src/.background"
ditto "$app" "$src/PasteFerry.app"
ln -s /Applications "$src/Applications"
cp "$STAGE/background.tiff" "$src/.background/background.tiff"
# 同名的卷还挂着的话,Finder 会把布局写到另一个窗口上
hdiutil detach "/Volumes/$vol" -quiet 2>/dev/null || true
hdiutil create -volname "$vol" -srcfolder "$src" -fs HFS+ -format UDRW -ov "$STAGE/rw.dmg" -quiet
mnt=$(hdiutil attach "$STAGE/rw.dmg" -readwrite -noverify -noautoopen | awk -F'\t' '/\/Volumes\//{print $NF}')
if layout_dmg "$vol"; then
echo " ✓ 安装窗口布局"
else
echo " ! 没能设置安装窗口布局(Finder 自动化权限未授予),DMG 仍可正常安装"
fi
# 卷图标放在布局之后:-srcfolder 不会带上 .VolumeIcon.icns,
# 而 Finder 保存布局时又会清掉卷的自定义图标标记
cp assets/brand/AppIcon.icns "$mnt/.VolumeIcon.icns"
SetFile -a C "$mnt"
rm -rf "$mnt/.fseventsd"
sync
hdiutil detach "$mnt" -quiet
hdiutil convert "$STAGE/rw.dmg" -format UDZO -imagekey zlib-level=9 -o "$OUT/$name" -quiet
rm -f "$STAGE/rw.dmg"
echo " ✓ ${name}(${VERSION})"
}
echo "▶ 打包 DMG"
check_signed dist/PasteFerry.app
thin_app dist/PasteFerry.app "$STAGE/arm64/PasteFerry.app" arm64
thin_app dist/PasteFerry.app "$STAGE/x86_64/PasteFerry.app" x86_64
make_dmg "$STAGE/arm64/PasteFerry.app" PasteFerry-mac-apple-silicon.dmg
make_dmg "$STAGE/x86_64/PasteFerry.app" PasteFerry-mac-intel.dmg
make_dmg dist/PasteFerry.app PasteFerry.dmg
# ─────────────────────────── 服务器 ───────────────────────────
echo "▶ 打包服务器"
for arch in amd64 arm64; do
name="pasteferry-server-linux-$arch"
d="$STAGE/$name"
mkdir -p "$d"
(cd server && CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -trimpath \
-ldflags "-s -w -X main.version=$VERSION" \
-o "$d/pasteferry-server" ./cmd/pasteferry-server)
cp server/deploy/{install.sh,pasteferry-server.service,Dockerfile,docker-compose.yml,env.example,README.md} "$d/"
tar -C "$STAGE" -czf "$OUT/$name.tar.gz" "$name"
echo " ✓ $name.tar.gz"
done
name="pasteferry-server-macos"
mkdir -p "$STAGE/$name"
cp dist/pasteferry-server server/deploy/README.md "$STAGE/$name/"
install -m 755 server/deploy/install-macos.sh "$STAGE/$name/install.sh"
tar -C "$STAGE" -czf "$OUT/$name.tar.gz" "$name"
echo " ✓ $name.tar.gz"
# Windows 用 zip:系统自带解压。install.ps1 与 .cmd 必须保持带 BOM 的 UTF-8 与 CRLF,原样拷贝
name="pasteferry-server-windows-amd64"
d="$STAGE/$name"
mkdir -p "$d"
(cd server && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath \
-ldflags "-s -w -X main.version=$VERSION" \
-o "$d/pasteferry-server.exe" ./cmd/pasteferry-server)
cp server/deploy/{install.ps1,install.cmd,uninstall.cmd,README.md} "$d/"
zip_out="$PWD/$OUT/$name.zip"
(cd "$STAGE" && zip -qr -X "$zip_out" "$name")
echo " ✓ $name.zip"
(cd "$OUT" && shasum -a 256 -- * > SHA256SUMS)
echo
echo "完成。发布包:"
ls -lh "$OUT" | tail -n +2