Skip to content

fix: correct YAML heredoc formatting in GitHub Actions workflow #29

fix: correct YAML heredoc formatting in GitHub Actions workflow

fix: correct YAML heredoc formatting in GitHub Actions workflow #29

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build Universal App
run: |
# 创建目录结构
mkdir -p dist/MacVimSwitch.app/Contents/{MacOS,Resources}
# 复制 Info.plist 和应用图标
cp Info.plist dist/MacVimSwitch.app/Contents/
if [ -f "AppIcon.icns" ]; then
cp AppIcon.icns dist/MacVimSwitch.app/Contents/Resources/
echo "已复制应用图标到资源文件夹"
else
echo "警告:未找到 AppIcon.icns 文件,将使用默认图标"
fi
# 构建 ARM64 版本
echo "构建 ARM64 版本..."
swiftc -o dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-arm64 \
inputsource.swift \
main.swift \
AppDelegate.swift \
StatusBarManager.swift \
InputMethodManager.swift \
UserPreferences.swift \
LaunchManager.swift \
-framework Cocoa \
-framework Carbon \
-target arm64-apple-macos11 \
-sdk $(xcrun --show-sdk-path) \
-O \
-whole-module-optimization \
-Xlinker -rpath \
-Xlinker @executable_path/../Frameworks
# 构建 x86_64 版本
echo "构建 x86_64 版本..."
swiftc -o dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-x86_64 \
inputsource.swift \
main.swift \
AppDelegate.swift \
StatusBarManager.swift \
InputMethodManager.swift \
UserPreferences.swift \
LaunchManager.swift \
-framework Cocoa \
-framework Carbon \
-target x86_64-apple-macos11 \
-sdk $(xcrun --show-sdk-path) \
-O \
-whole-module-optimization \
-Xlinker -rpath \
-Xlinker @executable_path/../Frameworks
# 合并为通用二进制
echo "合并为通用二进制..."
lipo -create \
dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-arm64 \
dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-x86_64 \
-output dist/MacVimSwitch.app/Contents/MacOS/macvimswitch
# 清理临时文件
rm dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-arm64
rm dist/MacVimSwitch.app/Contents/MacOS/macvimswitch-x86_64
# 创建 Info.plist
cat > dist/MacVimSwitch.app/Contents/Info.plist << 'EOL'
<?xml version="1.0" encoding="UTF-8"?>

Check failure on line 85 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 85
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>macvimswitch</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>com.jackiexiao.macvimswitch</string>
<key>CFBundleName</key>
<string>MacVimSwitch</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${GITHUB_REF#refs/tags/v}</string>
<key>CFBundleVersion</key>
<string>${GITHUB_REF#refs/tags/v}</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSAppleEventsUsageDescription</key>
<string>MacVimSwitch needs to control system events to manage input sources.</string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSAccessibilityUsageDescription</key>
<string>MacVimSwitch needs accessibility access to monitor keyboard events.</string>
</dict>
</plist>
EOL
# 创建 entitlements.plist
cat > entitlements.plist << 'EOL'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.systemevents</string>
</array>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
EOL
# 设置执行权限
chmod +x dist/MacVimSwitch.app/Contents/MacOS/macvimswitch
# 使用自签名
codesign --force --deep --sign - --entitlements entitlements.plist dist/MacVimSwitch.app
- name: Create DMG with Installation Guide
run: |
# 创建临时挂载点
mkdir -p /tmp/dmg
# 创建应用程序文件夹符号链接
ln -s /Applications /tmp/dmg/Applications
# 复制应用
cp -r dist/MacVimSwitch.app /tmp/dmg/
# 创建 DMG
hdiutil create -volname "MacVimSwitch" -srcfolder /tmp/dmg -ov -format UDZO MacVimSwitch.dmg
# 清理
rm -rf /tmp/dmg
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./MacVimSwitch.dmg
asset_name: MacVimSwitch.dmg
asset_content_type: application/x-apple-diskimage
- name: Get Tag Message
id: tag
run: |
# 获取当前 tag 的注释内容
echo "message=$(git tag -l --format='%(contents)' ${{ github.ref_name }})" >> $GITHUB_OUTPUT
- name: Calculate SHA256
run: |
echo "DMG_SHA256=$(shasum -a 256 MacVimSwitch.dmg | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Add SHA256 to Release
uses: softprops/action-gh-release@v1
with:
files: MacVimSwitch.dmg
body: |
${{ steps.tag.outputs.message }}
Universal Binary (支持 Intel 和 Apple Silicon Mac)
安装方法:
1. 双击打开 DMG 文件
2. 将 MacVimSwitch 拖入 Applications 文件夹
3. 从 Applications 文件夹打开 MacVimSwitch
使用说明:
1. 在系统偏好设置中授予必要权限(如果你从 v0.6.3 之前老版本升级到新版本,你需要先删除原来的应用权限,再重新授权)
SHA256: ${{ env.DMG_SHA256 }}
You can verify the SHA256 checksum of the DMG file using:
```bash
shasum -a 256 MacVimSwitch.dmg
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}