版本号改为 0.2.0 (0003) 格式:每次构建号加一,发布时用 bump-patch / bump-minor 改营销版本

This commit is contained in:
gentpan committed 2026-09-14 23:24:09 +05:00
1 parent 11fc451fae
commit 92d09169fd
5 files changed
+68 -6

No files matched your search

+7
View File
@@ -37,6 +37,13 @@ make install # Release into /Applications
make test # swift test in the package
```
Versions read `0.2.0 (0003)`: `MARKETING_VERSION` changes only when releasing
(`make bump-patch` for small releases, `make bump-minor` for larger ones), and the four-digit
`CURRENT_PROJECT_VERSION` goes up by one on every `make build` (`BUMP=0` skips it). Build numbers
never reset, so every package has a larger `CFBundleVersion` than the one before. Build products are
unregistered from Launch Services so only `/Applications/OpenStats.app` shows up in Spotlight and the
widget gallery.
`project.yml` defaults to ad-hoc signing so the project opens anywhere. The Makefile passes
the first Developer ID Application identity from the keychain (and `--timestamp` for Release)
when there is one. `make release` runs `Scripts/release.sh`: build, verify team, timestamp and
+24 -4
View File
@@ -3,6 +3,7 @@ SCHEME := OpenStats
CONFIG ?= Debug
DERIVED := build/DerivedData
APP := $(DERIVED)/Build/Products/$(CONFIG)/OpenStats.app
LSREGISTER := /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
# 与 QuotaBar 相同:钥匙串里有 Developer ID 证书就自动用它签名,否则退回 ad-hoc(仅限本机)。
# 也可以用 SIGN_ID="..." 显式指定。
@@ -14,16 +15,22 @@ SIGN_FLAGS := CODE_SIGN_IDENTITY="$(SIGN_ID)" CODE_SIGN_STYLE=Manual DEVELOPMENT
$(if $(filter Release,$(CONFIG)),OTHER_CODE_SIGN_FLAGS=--timestamp CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO)
endif
.PHONY: generate build run install release stop test snapshot open clean
.PHONY: generate build compile run install release stop test snapshot open clean version bump-patch bump-minor bump-major
## 由 project.yml 生成 Xcode 工程
generate:
xcodegen generate --quiet
## 编译 App(含辅助工具)
build: generate
## 编译 App(含辅助工具);每次构建号加一,BUMP=0 时不加
build:
@if [ "$(BUMP)" != "0" ]; then ./Scripts/version.sh build; fi
@$(MAKE) --no-print-directory compile
compile: generate
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration $(CONFIG) \
-derivedDataPath $(DERIVED) -destination 'platform=macOS' -quiet $(SIGN_FLAGS) build
@# 编译产物不登记到启动服务,系统里只保留 /Applications 那一份(聚焦搜索、打开方式、小组件列表不重复)
@$(LSREGISTER) -u $(APP) >/dev/null 2>&1 || true
## 编译并启动(会先结束正在运行的 OpenStats)
run: build stop
@@ -35,7 +42,7 @@ install:
-pkill -x OpenStats
rm -rf /Applications/OpenStats.app
ditto $(DERIVED)/Build/Products/Release/OpenStats.app /Applications/OpenStats.app
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/OpenStats.app
$(LSREGISTER) -f /Applications/OpenStats.app
open /Applications/OpenStats.app
## 发布:签名、公证、装订、打包 DMG,生成 Homebrew cask(见 Scripts/release.sh)
@@ -45,6 +52,19 @@ release:
stop:
-pkill -x OpenStats
## 显示当前版本;发布前用 bump-patch(小改 0.2.0→0.2.1)或 bump-minor(大改 0.2.1→0.3.0)
version:
@./Scripts/version.sh
bump-patch:
@./Scripts/version.sh patch
bump-minor:
@./Scripts/version.sh minor
bump-major:
@./Scripts/version.sh major
## 单元测试
test:
cd Packages/OpenStatsKit && swift test
@@ -766,7 +766,7 @@ struct AboutSettings: View {
AppGlyph(size: DS.Space.s12)
VStack(alignment: .leading, spacing: DS.Space.s1) {
Text("OpenStats").dsFont(.lg, weight: .semibold).foregroundStyle(DS.Palette.textPrimary)
Text(verbatim: tr("版本 \(version)\(build.map { tr("(\($0))") } ?? "")"))
Text(verbatim: tr("版本 \(version)\(build.map { " (\($0))" } ?? "")"))
.dsFont(.sm)
.foregroundStyle(DS.Palette.textSecondary)
}
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# 版本号:营销版本 X.Y.Z 只在发布时改,构建号四位数字每次本地构建加一,显示为 “0.2.0 (0003)”。
#
# Scripts/version.sh # 显示当前版本
# Scripts/version.sh build # 构建号加一(make build 会自动调用)
# Scripts/version.sh patch # 小改发布:0.2.0 → 0.2.1
# Scripts/version.sh minor # 大改发布:0.2.1 → 0.3.0
# Scripts/version.sh major # 1.0.0 这类里程碑
#
# 构建号跨版本持续递增、不归零,保证每个安装包的 CFBundleVersion 都比之前的大。
set -euo pipefail
cd "$(dirname "$0")/.."
FILE=project.yml
version="$(sed -nE 's/^ *MARKETING_VERSION: *"?([0-9.]+)"?.*/\1/p' "$FILE" | head -1)"
build="$(sed -nE 's/^ *CURRENT_PROJECT_VERSION: *"?([0-9]+)"?.*/\1/p' "$FILE" | head -1)"
set_value() {
sed -i '' -E "s/^( *$1: *)\"?[0-9.]+\"?/\1\"$2\"/" "$FILE"
}
IFS=. read -r major minor patch <<< "$version"
case "${1:-show}" in
show) ;;
build)
build=$(printf "%04d" $((10#$build + 1)))
set_value CURRENT_PROJECT_VERSION "$build"
;;
patch) version="$major.$minor.$((patch + 1))"; set_value MARKETING_VERSION "$version" ;;
minor) version="$major.$((minor + 1)).0"; set_value MARKETING_VERSION "$version" ;;
major) version="$((major + 1)).0.0"; set_value MARKETING_VERSION "$version" ;;
*) echo "用法:Scripts/version.sh [show|build|patch|minor|major]" >&2; exit 1 ;;
esac
echo "$version ($(printf "%04d" $((10#$build))))"
+2 -1
View File
@@ -12,7 +12,8 @@ settings:
base:
SWIFT_VERSION: "6.0"
MARKETING_VERSION: "0.2.0"
CURRENT_PROJECT_VERSION: "2"
# 构建号四位数字,每次 make build 加一;营销版本只在发布时用 Scripts/version.sh patch / minor 修改
CURRENT_PROJECT_VERSION: "0003"
MACOSX_DEPLOYMENT_TARGET: "14.0"
# 本地开发使用 ad-hoc 签名;发布时改为 Developer ID(见 docs/PLAN.md)
CODE_SIGN_STYLE: Manual