Skip to content

Commit 2a0476d

Browse files
committed
Add VersionBump swift script
1 parent a05094d commit 2a0476d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Utils/VersionBump/Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "VersionBump",
5+
dependencies: [
6+
.Package(url: "https://github.com/kareman/SwiftShell.git", "3.0.0-beta"),
7+
.Package(url: "https://github.com/sharplet/Regex.git", majorVersion: 0, minor: 4),
8+
]
9+
)

Utils/VersionBump/main.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Foundation
2+
import SwiftShell
3+
import Regex
4+
5+
let files = [
6+
"./Sentry.podspec",
7+
"./docs/sentry-doc-config.json",
8+
"./Sentry/Info.plist",
9+
"./Sources/Sentry.swift",
10+
]
11+
12+
let args = CommandLine.arguments
13+
14+
let regex = Regex("[0-9]+\\.[0-9]+\\.[0-9]+")
15+
if regex.match(args[1]) == nil || regex.match(args[2]) == nil {
16+
exit(errormessage: "version number must bit 0.0.0 format" )
17+
}
18+
19+
let fromVersion = args[1]
20+
let toVersion = args[2]
21+
for file in files {
22+
//let fileContents = try! String(contentsOfFile: file, encoding: .utf8)
23+
//print("\(fileContents.replacingOccurrences(of: " ", with: "+"))")
24+
25+
let readFile = try open(file)
26+
let contents: String = readFile.read()
27+
let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
28+
let overwriteFile = try! open(forWriting: file, overwrite: true)
29+
overwriteFile.write(newContents)
30+
overwriteFile.close()
31+
}
32+
33+

0 commit comments

Comments
 (0)