Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7af0cdc

Browse files
fix: conform CFBundleVersion to documentation (#167)
Second PR for#47.Previously, we were setting [`CFBundleVersion`](https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleversion) to the output of `git describe --tags` (`vX.Y.Z` or `vX.Y.Z-N-gHASH` for preview builds).To support Sparkle, and potentially to avoid a breakage with macOS failing to update an installed `LaunchDaemon` when it can't parse `CFBundleVersion`, we'll conform the string to the specification.Given that:> You can include more integers but the system ignores them.We set `CFBundleVersion` to a value of the form `X.Y.Z[.N]` where N is the number of commits since the `X.Y.Z` tag (omitted if 0)Sparkle did previously allow you to supply a manual version comparator, but it was deprecated to help require `CFBundleVersion` start with `X.Y.Z`sparkle-project/Sparkle#2585That issue recommends instead putting marketing version information in `CFBundleShortVersionString`, but that actually has even stricter requirements:https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleshortversionstringThough not documented, from testing & reading the [Sparkle source](https://github.com/sparkle-project/Sparkle/blob/2.x/Sparkle/SUStandardVersionComparator.m), I discovered that `X.Y.Z.N+1` will be deemed a later version than `X.Y.Z.N`, which is what we'll do for the preview stream of auto-updates. For non-preview builds (i.e. builds on a tag), both version strings will be `X.Y.Z`.Since we're no longer including the commit hash in a version string, we instead embed it separately in the `Info.plist` so we can continue to display it in the UI:<img width="284" alt="image" src="https://github.com/user-attachments/assets/a9b2359d-6e2f-4f7d-979c-ba69ee01e69c" />
1 parentb2da490 commit7af0cdc

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
lines changed

‎Coder-Desktop/Coder-Desktop/About.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ enum About {
3131
return coder
3232
}
3333

34+
privatestaticvarversion:NSString{
35+
letversion=Bundle.main.infoDictionary?["CFBundleShortVersionString"]as?String??"Unknown"
36+
letcommitHash=Bundle.main.infoDictionary?["CommitHash"]as?String??"Unknown"
37+
return"Version\(version) -\(commitHash)"asNSString
38+
}
39+
3440
@MainActor
3541
staticfunc open(){
3642
appActivate()
3743
NSApp.orderFrontStandardAboutPanel(options:[
3844
.credits: credits,
45+
.applicationVersion: version,
3946
])
4047
}
4148
}

‎Coder-Desktop/Coder-Desktop/Info.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<string>$(TeamIdentifierPrefix)com.coder.Coder-Desktop.VPN</string>
3333
</dict>
3434
<key>SUPublicEDKey</key>
35-
<string>Ae2oQLTcx89/a73XrpOt+IVvqdo+fMTjo3UKEm77VdA=</string>
35+
<string>Ae2oQLTcx89/a73XrpOt+IVvqdo+fMTjo3UKEm77VdA=</string>
36+
<key>CommitHash</key>
37+
<string>$(GIT_COMMIT_HASH)</string>
3638
</dict>
3739
</plist>

‎Coder-Desktop/project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ settings:
1313
base:
1414
MARKETING_VERSION:${MARKETING_VERSION}# Sets the version number.
1515
CURRENT_PROJECT_VERSION:${CURRENT_PROJECT_VERSION}# Sets the build number.
16+
GIT_COMMIT_HASH:${GIT_COMMIT_HASH}
1617

1718
ALWAYS_SEARCH_USER_PATHS:NO
1819
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS:YES

‎Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,29 @@ $(error MUTAGEN_VERSION must be a valid version)
3232
endif
3333

3434
ifndefCURRENT_PROJECT_VERSION
35-
CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
35+
# Must be X.Y.Z[.N]
36+
CURRENT_PROJECT_VERSION:=$(shell ./scripts/version.sh)
3637
endif
3738
ifeq ($(strip$(CURRENT_PROJECT_VERSION)),)
3839
$(error CURRENT_PROJECT_VERSION cannot be empty)
3940
endif
4041

4142
ifndefMARKETING_VERSION
42-
MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
43+
# Must be X.Y.Z
44+
MARKETING_VERSION:=$(shell ./scripts/version.sh --short)
4345
endif
4446
ifeq ($(strip$(MARKETING_VERSION)),)
4547
$(error MARKETING_VERSION cannot be empty)
4648
endif
4749

50+
ifndefGIT_COMMIT_HASH
51+
# Must be a valid git commit hash
52+
GIT_COMMIT_HASH :=$(shell ./scripts/version.sh --hash)
53+
endif
54+
ifeq ($(strip$(GIT_COMMIT_HASH)),)
55+
$(error GIT_COMMIT_HASH cannot be empty)
56+
endif
57+
4858
# Define the keychain file name first
4959
KEYCHAIN_FILE := app-signing.keychain-db
5060
# Use shell to get the absolute path only if the file exists
@@ -70,6 +80,7 @@ $(XCPROJECT): $(PROJECT)/project.yml
7080
EXT_PROVISIONING_PROFILE_ID=${EXT_PROVISIONING_PROFILE_ID}\
7181
CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
7282
MARKETING_VERSION=$(MARKETING_VERSION)\
83+
GIT_COMMIT_HASH=$(GIT_COMMIT_HASH)\
7384
xcodegen
7485

7586
$(PROJECT)/VPNLib/vpn.pb.swift:$(PROJECT)/VPNLib/vpn.proto

‎scripts/version.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
echo"Usage:$0 [--short] [--hash]"
6+
echo" --short Output a CFBundleShortVersionString compatible version (X.Y.Z)"
7+
echo" --hash Output only the commit hash"
8+
echo" -h, --help Display this help message"
9+
echo""
10+
echo"With no flags, outputs: X.Y.Z[.N]"
11+
}
12+
13+
SHORT=false
14+
HASH_ONLY=false
15+
16+
while [["$#"-gt 0 ]];do
17+
case$1in
18+
--short)
19+
SHORT=true
20+
shift
21+
;;
22+
--hash)
23+
HASH_ONLY=true
24+
shift
25+
;;
26+
-h | --help)
27+
usage
28+
exit 0
29+
;;
30+
*)
31+
echo"Unknown parameter passed:$1"
32+
usage
33+
exit 1
34+
;;
35+
esac
36+
done
37+
38+
if [["$HASH_ONLY"==true ]];then
39+
current_hash=$(git rev-parse --short=7 HEAD)
40+
echo"$current_hash"
41+
exit 0
42+
fi
43+
44+
describe_output=$(git describe --tags)
45+
46+
# Of the form `vX.Y.Z-N-gHASH`
47+
if [[$describe_output=~ ^v([0-9]+\.[0-9]+\.[0-9]+)(-([0-9]+)-g[a-f0-9]+)?$ ]];then
48+
version=${BASH_REMATCH[1]}# X.Y.Z
49+
commits=${BASH_REMATCH[3]}# number of commits since tag
50+
51+
if [["$SHORT"==true ]];then
52+
echo"$version"
53+
exit 0
54+
fi
55+
56+
echo"${version}.${commits}"
57+
else
58+
echo"Error: Could not parse git describe output:$describe_output">&2
59+
exit 1
60+
fi

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp