Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Swift has a tool for producing final product packages, suitable for distribution
5. Create a tag on that commit with the format "x.y.z". Do not omit "z", even if its value is 0.

6. Build the executables for the release by running `swift run build-swiftly-release <version>` from the root of the swiftly repository
* Build on a Apple silicon macOS machine to produce a universal package for x86_64 and arm64
* Build on an Apple macOS machine to produce a universal package for x86_64 and arm64 (add the --cert option to provide a signing certificate file for the .pkg)
* Build on an Amazon Linux 2 image for x86_64
* Build on an Amazon Linux 2 image for arm64

Expand Down
57 changes: 43 additions & 14 deletions Tools/build-swiftly-release/BuildSwiftlyRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
@Flag(name: .long, help: "Skip the git repo checks and proceed.")
var skip: Bool = false

#if os(macOS)
@Option(help: "Installation certificate to use when building the macOS package")
var cert: String?

@Option(help: "Package identifier of macOS package")
var identifier: String = "org.swift.swiftly"
#endif

@Argument(help: "Version of swiftly to build the release.")
var version: String

Expand All @@ -191,7 +199,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
#if os(Linux)
try await self.buildLinuxRelease()
#elseif os(macOS)
try await self.buildMacOSRelease()
try await self.buildMacOSRelease(cert: self.cert, identifier: self.identifier)
#else
#error("Unsupported OS")
#endif
Expand Down Expand Up @@ -234,6 +242,10 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
}

func checkSwiftRequirement() async throws -> String {
guard !self.skip else {
return try await self.assertTool("swift", message: "Please install swift and make sure that it is added to your path.")
}

guard let requiredSwiftVersion = try? self.findSwiftVersion() else {
throw Error(message: "Unable to determine the required swift version for this version of swiftly. Please make sure that you `cd <swiftly_git_dir>` and there is a .swift-version file there.")
}
Expand Down Expand Up @@ -361,7 +373,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
print(releaseArchive)
}

func buildMacOSRelease() async throws {
func buildMacOSRelease(cert: String?, identifier: String) async throws {
// Check system requirements
let git = try await self.assertTool("git", message: "Please install git with either `xcode-select --install` or `brew install git`")

Expand Down Expand Up @@ -389,17 +401,34 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
try? FileManager.default.createDirectory(atPath: swiftlyLicenseDir, withIntermediateDirectories: true)
try await self.collectLicenses(swiftlyLicenseDir)

try runProgram(
pkgbuild,
"--root",
swiftlyBinDir + "/..",
"--install-location",
"usr/local",
"--version",
self.version,
"--identifier",
"org.swift.swiftly",
".build/release/swiftly-\(self.version).pkg"
)
if let cert {
try runProgram(
pkgbuild,
"--root",
swiftlyBinDir + "/..",
"--install-location",
"usr/local",
"--version",
self.version,
"--identifier",
identifier,
"--sign",
cert,
".build/release/swiftly-\(self.version).pkg"
)
} else {
try runProgram(
pkgbuild,
"--root",
swiftlyBinDir + "/..",
"--install-location",
"usr/local",
"--version",
self.version,
"--identifier",
identifier,
".build/release/swiftly-\(self.version).pkg"
)
}
}
}