Skip to content

Commit 1e40c52

Browse files
committed
Add localOnly flag to the release script.
1 parent 3a008b0 commit 1e40c52

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Tools/Release/Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ let package = Package(
99
products: [.executable(name: "release", targets: ["Release"])],
1010
dependencies: [
1111
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
12-
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "f9695015fff3c619172e5337266c46cfe5c327d7")
12+
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "c8e3448595363a3948f6260053fc78d3accb2ebc")
13+
// .package(path: "../../../swift-command-line-tools")
1314
],
1415
targets: [
1516
.executableTarget(name: "Release",

Tools/Release/Sources/Release.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ struct Release: AsyncParsableCommand {
77
@Option(help: "The version of the package that is being released.")
88
var version: String
99

10+
@Flag(help: "Prevents the run from pushing anything to GitHub.")
11+
var localOnly = false
12+
1013
var apiToken = (try? NetrcParser.parse(file: FileManager.default.homeDirectoryForCurrentUser.appending(component: ".netrc")))!
1114
.authorization(for: URL(string: "https://api.github.com")!)!
1215
.password
@@ -24,7 +27,7 @@ struct Release: AsyncParsableCommand {
2427
.appending(component: "matrix-rust-sdk")
2528

2629
mutating func run() async throws {
27-
let package = Package(repository: packageRepo, directory: packageDirectory, apiToken: apiToken)
30+
let package = Package(repository: packageRepo, directory: packageDirectory, apiToken: apiToken, urlSession: localOnly ? .releaseMock : .shared)
2831
Zsh.defaultDirectory = package.directory
2932

3033
Log.info("Build directory: \(buildDirectory.path())")
@@ -68,6 +71,12 @@ struct Release: AsyncParsableCommand {
6871
try Zsh.run(command: "git add Package.swift")
6972
try Zsh.run(command: "git add Sources")
7073
try Zsh.run(command: "git commit -m 'Bump to version \(version) (\(product.sourceRepo.name)/\(product.branch) \(product.commitHash))'")
74+
75+
guard !localOnly else {
76+
Log.info("Skipping push for --local-only")
77+
return
78+
}
79+
7180
try Zsh.run(command: "git push")
7281
}
7382
}

0 commit comments

Comments
 (0)