Handle semver pre-release versions in isNewer; restore full version string in beta workflow
This commit is contained in:
@@ -48,10 +48,8 @@ jobs:
|
|||||||
- name: Update version-beta.json
|
- name: Update version-beta.json
|
||||||
run: |
|
run: |
|
||||||
notes=$(cat RELEASE_NOTES.md 2>/dev/null || echo "Beta release ${{ steps.version.outputs.version }}")
|
notes=$(cat RELEASE_NOTES.md 2>/dev/null || echo "Beta release ${{ steps.version.outputs.version }}")
|
||||||
base_version="${{ steps.version.outputs.version }}"
|
|
||||||
base_version="${base_version%%-*}"
|
|
||||||
jq -n \
|
jq -n \
|
||||||
--arg version "$base_version" \
|
--arg version "${{ steps.version.outputs.version }}" \
|
||||||
--arg url "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ClaudeChecker.zip" \
|
--arg url "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ClaudeChecker.zip" \
|
||||||
--arg notes "$notes" \
|
--arg notes "$notes" \
|
||||||
'{version: $version, url: $url, notes: $notes}' > version-beta.json
|
'{version: $version, url: $url, notes: $notes}' > version-beta.json
|
||||||
|
|||||||
@@ -318,13 +318,30 @@ class UpdateManager: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func isNewer(_ version: String, than current: String) -> Bool {
|
private func isNewer(_ version: String, than current: String) -> Bool {
|
||||||
let toInts = { (v: String) in v.split(separator: ".").compactMap { Int($0) } }
|
func parse(_ v: String) -> (base: [Int], pre: [Int]?) {
|
||||||
let a = toInts(version), b = toInts(current)
|
let halves = v.split(separator: "-", maxSplits: 1)
|
||||||
for i in 0..<max(a.count, b.count) {
|
let base = halves[0].split(separator: ".").compactMap { Int($0) }
|
||||||
let av = i < a.count ? a[i] : 0
|
let pre = halves.count > 1 ? String(halves[1]).split(separator: ".").compactMap { Int($0) } : nil
|
||||||
let bv = i < b.count ? b[i] : 0
|
return (base, pre)
|
||||||
|
}
|
||||||
|
let a = parse(version), b = parse(current)
|
||||||
|
// Compare base version numbers
|
||||||
|
for i in 0..<max(a.base.count, b.base.count) {
|
||||||
|
let av = i < a.base.count ? a.base[i] : 0
|
||||||
|
let bv = i < b.base.count ? b.base[i] : 0
|
||||||
if av != bv { return av > bv }
|
if av != bv { return av > bv }
|
||||||
}
|
}
|
||||||
|
// Base equal: stable beats pre-release
|
||||||
|
if a.pre == nil && b.pre != nil { return true }
|
||||||
|
if a.pre != nil && b.pre == nil { return false }
|
||||||
|
// Both pre-release: compare pre-release numbers
|
||||||
|
if let ap = a.pre, let bp = b.pre {
|
||||||
|
for i in 0..<max(ap.count, bp.count) {
|
||||||
|
let av = i < ap.count ? ap[i] : 0
|
||||||
|
let bv = i < bp.count ? bp[i] : 0
|
||||||
|
if av != bv { return av > bv }
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user