Skip to content

Detect daemon version mismatch and transparently restart (#142) (#144) #20

Detect daemon version mismatch and transparently restart (#142) (#144)

Detect daemon version mismatch and transparently restart (#142) (#144) #20

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_26.3.app
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build release binary
run: swift build -c release
- name: Package binary
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
STAGING="previewsmcp-${VERSION}-darwin-arm64"
mkdir -p "$STAGING"
cp .build/release/previewsmcp "$STAGING/"
cp LICENSE "$STAGING/"
cp README.md "$STAGING/"
tar -czf "${STAGING}.tar.gz" "$STAGING"
shasum -a 256 "${STAGING}.tar.gz" > "${STAGING}.tar.gz.sha256"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
STAGING="previewsmcp-${VERSION}-darwin-arm64"
gh release create "v${VERSION}" \
"${STAGING}.tar.gz" \
"${STAGING}.tar.gz.sha256" \
--title "v${VERSION}" \
--generate-notes
- name: Update Homebrew tap
env:
VERSION: ${{ steps.version.outputs.VERSION }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -z "$HOMEBREW_TAP_TOKEN" ]; then
echo "HOMEBREW_TAP_TOKEN not set, skipping Homebrew tap update"
exit 0
fi
STAGING="previewsmcp-${VERSION}-darwin-arm64"
SHA256="$(awk '{print $1}' "${STAGING}.tar.gz.sha256")"
URL="https://github.com/obj-p/PreviewsMCP/releases/download/v${VERSION}/${STAGING}.tar.gz"
bash scripts/generate-formula.sh "$VERSION" "$URL" "$SHA256" > previewsmcp.rb
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/obj-p/homebrew-tap.git" tap-repo
mkdir -p tap-repo/Formula
cp previewsmcp.rb tap-repo/Formula/previewsmcp.rb
cd tap-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/previewsmcp.rb
if git diff --cached --quiet; then
echo "Formula already up to date"
exit 0
fi
git commit -m "previewsmcp ${VERSION}"
git push origin main