Skip to content

docs(changelog): add v1.1.0 release notes #10

docs(changelog): add v1.1.0 release notes

docs(changelog): add v1.1.0 release notes #10

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build and Release
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'
- name: Setup variables
run: |
# 获取版本号(移除 'v' 前缀)
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# 设置构建号(使用时间戳)
BUILD_NUMBER=$(date +%Y%m%d%H%M)
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
# 设置 DMG 文件名
DMG_NAME="Kettle-$VERSION.dmg"
echo "DMG_NAME=$DMG_NAME" >> $GITHUB_ENV
- name: Find Info.plist
run: |
# 查找项目中的所有 Info.plist 文件
PLIST_FILES=$(find . -name "Info.plist" | grep -v "build" || echo "")
echo "Found Info.plist files: $PLIST_FILES"
# 如果找到多个文件,选择 Kettle/Info.plist
if [[ -f "./Kettle/Info.plist" ]]; then
echo "PLIST_PATH=./Kettle/Info.plist" >> $GITHUB_ENV
echo "Found main Info.plist at ./Kettle/Info.plist"
elif [[ -n "$PLIST_FILES" ]]; then
# 使用找到的第一个 Info.plist
FIRST_PLIST=$(echo "$PLIST_FILES" | head -n 1)
echo "PLIST_PATH=$FIRST_PLIST" >> $GITHUB_ENV
echo "Using Info.plist at $FIRST_PLIST"
else
echo "No Info.plist found. Will create one."
mkdir -p Kettle
echo "PLIST_PATH=./Kettle/Info.plist" >> $GITHUB_ENV
fi
- name: Create Info.plist if needed
run: |
PLIST_PATH="${PLIST_PATH:-./Kettle/Info.plist}"
if [ ! -f "$PLIST_PATH" ]; then
echo "Creating new Info.plist at $PLIST_PATH"
mkdir -p $(dirname "$PLIST_PATH")
echo '<?xml version="1.0" encoding="UTF-8"?>' > "$PLIST_PATH"
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> "$PLIST_PATH"
echo '<plist version="1.0">' >> "$PLIST_PATH"
echo '<dict>' >> "$PLIST_PATH"
echo ' <key>CFBundleIconFile</key>' >> "$PLIST_PATH"
echo ' <string>AppIcon</string>' >> "$PLIST_PATH"
echo ' <key>CFBundleIconName</key>' >> "$PLIST_PATH"
echo ' <string>AppIcon</string>' >> "$PLIST_PATH"
echo ' <key>CFBundleShortVersionString</key>' >> "$PLIST_PATH"
echo ' <string>1.0.0</string>' >> "$PLIST_PATH"
echo ' <key>CFBundleVersion</key>' >> "$PLIST_PATH"
echo ' <string>1</string>' >> "$PLIST_PATH"
echo '</dict>' >> "$PLIST_PATH"
echo '</plist>' >> "$PLIST_PATH"
fi
- name: Check and add required keys
run: |
PLIST_PATH="${PLIST_PATH:-./Kettle/Info.plist}"
if ! /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$PLIST_PATH" &>/dev/null; then
echo "Adding CFBundleShortVersionString to Info.plist"
/usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string 1.0.0" "$PLIST_PATH"
fi
if ! /usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$PLIST_PATH" &>/dev/null; then
echo "Adding CFBundleVersion to Info.plist"
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 1" "$PLIST_PATH"
fi
- name: Update version and build number
run: |
PLIST_PATH="${PLIST_PATH:-./Kettle/Info.plist}"
# 确保使用标准格式的版本号和构建号
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$PLIST_PATH"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$PLIST_PATH"
echo "📱 App version updated to $VERSION (Build: $BUILD_NUMBER)"
echo "Info.plist content:"
cat "$PLIST_PATH"
# 确保构建前能看到更新后的 Info.plist
cp -f "$PLIST_PATH" "./Kettle/Info.plist" || echo "Already in the right place"
# 确认最终的 Info.plist 内容
echo "Final Info.plist content for build:"
cat "./Kettle/Info.plist"
- name: List available schemes
run: |
echo "Available schemes:"
xcodebuild -list -project "Kettle.xcodeproj" || echo "Failed to list schemes"
- name: Build app
run: |
# 尝试构建应用
xcodebuild clean archive \
-project "Kettle.xcodeproj" \
-scheme "Kettle" \
-archivePath "build/Kettle.xcarchive" \
CODE_SIGN_IDENTITY="-" \
CURRENT_PROJECT_VERSION=$BUILD_NUMBER \
MARKETING_VERSION=$VERSION || {
echo "Build failed. Trying alternate scheme..."
# 尝试构建第一个找到的 scheme
FIRST_SCHEME=$(xcodebuild -list -project "Kettle.xcodeproj" -json 2>/dev/null | grep -o '"name" : "[^"]*"' | head -1 | cut -d'"' -f4)
if [ -n "$FIRST_SCHEME" ]; then
echo "Trying to build with scheme: $FIRST_SCHEME"
xcodebuild clean archive \
-project "Kettle.xcodeproj" \
-scheme "$FIRST_SCHEME" \
-archivePath "build/Kettle.xcarchive" \
CODE_SIGN_IDENTITY="-" \
CURRENT_PROJECT_VERSION=$BUILD_NUMBER \
MARKETING_VERSION=$VERSION
else
echo "No schemes found. Build failed."
exit 1
fi
}
- name: Install create-dmg
run: |
brew install create-dmg
- name: Create DMG
run: |
# 创建临时目录
mkdir -p build/dmg
cp -R build/Kettle.xcarchive/Products/Applications/Kettle.app build/dmg/ || {
echo "Failed to copy app. Checking actual path..."
find build -name "*.app"
APP_PATH=$(find build -name "*.app" | head -1)
if [ -n "$APP_PATH" ]; then
echo "Found app at: $APP_PATH"
cp -R "$APP_PATH" build/dmg/
else
echo "No app found. Build failed."
exit 1
fi
}
# 创建带有 Applications 链接的 DMG
APP_NAME="Kettle"
DMG_DIR="build/dmg_final"
mkdir -p "$DMG_DIR"
cp -R "build/dmg/Kettle.app" "$DMG_DIR"
# 创建指向 Applications 的符号链接
ln -s /Applications "$DMG_DIR/Applications"
# 使用 create-dmg 创建美观的 DMG
DMG_PATH="build/$DMG_NAME"
# 检查是否有图标文件
ICON_OPTION=""
if [ -f "Kettle/Resources/AppIcon.icns" ]; then
ICON_OPTION="--volicon Kettle/Resources/AppIcon.icns"
fi
# 检查是否有背景图像
BG_OPTION=""
if [ -f "Kettle/Resources/dmg-background.png" ]; then
BG_OPTION="--background Kettle/Resources/dmg-background.png"
fi
create-dmg \
--volname "$APP_NAME" \
$ICON_OPTION \
$BG_OPTION \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "$APP_NAME.app" 150 190 \
--hide-extension "$APP_NAME.app" \
--app-drop-link 450 190 \
--no-internet-enable \
"$DMG_PATH" \
"$DMG_DIR" \
|| {
echo "Failed to create fancy DMG. Falling back to simple DMG with Applications link."
# 创建简单的 DMG 作为备选,但保留 Applications 链接
hdiutil create -volname "Kettle" -srcfolder "$DMG_DIR" -ov -format UDZO "$DMG_PATH"
}
echo "📦 App built and DMG created at build/$DMG_NAME"
- name: Upload DMG as artifact
uses: actions/upload-artifact@v4
with:
name: Kettle-${{ env.VERSION }}-${{ env.BUILD_NUMBER }}
path: build/${{ env.DMG_NAME }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/${{ env.DMG_NAME }}"
name: "Kettle ${{ env.VERSION }}"
body: |
# Kettle v${{ env.VERSION }} (Build ${{ env.BUILD_NUMBER }})
## 更新内容
- 自动从 Git tag 构建的版本
- 构建时间: ${{ env.BUILD_NUMBER }}
## 下载
- macOS: Kettle-${{ env.VERSION }}.dmg
allowUpdates: true
makeLatest: true