Skip to content

Commit

Permalink
Add localOnly flag to the release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed May 14, 2024
1 parent 3a008b0 commit 1e40c52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Tools/Release/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ let package = Package(
products: [.executable(name: "release", targets: ["Release"])],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "f9695015fff3c619172e5337266c46cfe5c327d7")
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "c8e3448595363a3948f6260053fc78d3accb2ebc")
// .package(path: "../../../swift-command-line-tools")
],
targets: [
.executableTarget(name: "Release",
Expand Down
11 changes: 10 additions & 1 deletion Tools/Release/Sources/Release.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ struct Release: AsyncParsableCommand {
@Option(help: "The version of the package that is being released.")
var version: String

@Flag(help: "Prevents the run from pushing anything to GitHub.")
var localOnly = false

var apiToken = (try? NetrcParser.parse(file: FileManager.default.homeDirectoryForCurrentUser.appending(component: ".netrc")))!
.authorization(for: URL(string: "https://api.github.com")!)!
.password
Expand All @@ -24,7 +27,7 @@ struct Release: AsyncParsableCommand {
.appending(component: "matrix-rust-sdk")

mutating func run() async throws {
let package = Package(repository: packageRepo, directory: packageDirectory, apiToken: apiToken)
let package = Package(repository: packageRepo, directory: packageDirectory, apiToken: apiToken, urlSession: localOnly ? .releaseMock : .shared)
Zsh.defaultDirectory = package.directory

Log.info("Build directory: \(buildDirectory.path())")
Expand Down Expand Up @@ -68,6 +71,12 @@ struct Release: AsyncParsableCommand {
try Zsh.run(command: "git add Package.swift")
try Zsh.run(command: "git add Sources")
try Zsh.run(command: "git commit -m 'Bump to version \(version) (\(product.sourceRepo.name)/\(product.branch) \(product.commitHash))'")

guard !localOnly else {
Log.info("Skipping push for --local-only")
return
}

try Zsh.run(command: "git push")
}
}

0 comments on commit 1e40c52

Please sign in to comment.