name: App Bundle
on:
workflow_run:
workflows: ["Release"]
types: [completed]
permissions:
contents: write
jobs:
bundle:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
strategy:
matrix:
include:
- runner: macos-14
arch: aarch64
target: aarch64-apple-darwin
- runner: macos-15-intel
arch: x86_64
target: x86_64-apple-darwin
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create .app bundle
run: |
version="${{ github.event.workflow_run.head_branch }}"
version="${version#v}"
mkdir -p mdiew.app/Contents/MacOS mdiew.app/Contents/Resources
cp target/${{ matrix.target }}/release/mdiew mdiew.app/Contents/MacOS/mdiew
cp bundle/Info.plist mdiew.app/Contents/Info.plist
cp assets/icon.icns mdiew.app/Contents/Resources/icon.icns
# Stamp version from tag into Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $version" mdiew.app/Contents/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" mdiew.app/Contents/Info.plist
codesign --force --sign - mdiew.app
- name: Zip and upload
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
zip -r mdiew-${{ matrix.arch }}-apple-darwin.app.zip mdiew.app
gh release upload "${{ github.event.workflow_run.head_branch }}" mdiew-${{ matrix.arch }}-apple-darwin.app.zip --clobber
update-cask:
needs: bundle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download zips and update Cask
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${{ github.event.workflow_run.head_branch }}"
version="${tag#v}"
gh release download "$tag" -p "mdiew-aarch64-apple-darwin.app.zip" -p "mdiew-x86_64-apple-darwin.app.zip"
sha_arm=$(sha256sum mdiew-aarch64-apple-darwin.app.zip | cut -d' ' -f1)
sha_intel=$(sha256sum mdiew-x86_64-apple-darwin.app.zip | cut -d' ' -f1)
cat > Casks/mdiew.rb << EOF
cask "mdiew" do
arch arm: "aarch64", intel: "x86_64"
version "${version}"
sha256 arm: "${sha_arm}",
intel: "${sha_intel}"
url "https://github.com/SeungheonOh/mdiew/releases/download/v#{version}/mdiew-#{arch}-apple-darwin.app.zip"
name "mdiew"
desc "A fast, native macOS markdown viewer"
homepage "https://github.com/SeungheonOh/mdiew"
livecheck do
url :url
strategy :github_latest
end
depends_on macos: ">= :monterey"
app "mdiew.app"
postflight do
system_command "/usr/bin/xattr", args: ["-cr", "#{appdir}/mdiew.app"]
end
end
EOF
# Remove leading whitespace from heredoc
sed -i 's/^ //' Casks/mdiew.rb
- name: Commit updated Cask
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/mdiew.rb
git diff --cached --quiet && exit 0
git commit -m "update cask to ${{ github.event.workflow_run.head_branch }}"
git push