Skip to content

Commit f5d1bab

Browse files
authored
Restore amazon linux 2 as the default release build platform (#192)
Make using RHEL UBI9 an option to the build release script, default is false. Update the workflows to use UBI9 since AL2 doesn't work in GitHub workflows.
1 parent b8e7af6 commit f5d1bab

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.github/workflows/build_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
description: "Version of swiftly to build release artifacts"
88
required: true
99
type: string
10-
default: "0.3.0"
10+
default: "0.4.0-dev"
1111
skip:
1212
description: "Perform release checks, such as the git tag, and swift version, or '--skip' to skip that."
1313
required: true
@@ -24,7 +24,7 @@ jobs:
2424
- name: Checkout repository
2525
uses: actions/checkout@v4
2626
- name: Build Release Artifact
27-
run: swift run build-swiftly-release ${{ inputs.skip }} ${{ inputs.version }}
27+
run: swift run build-swiftly-release --use-rhel-ubi9 ${{ inputs.skip }} ${{ inputs.version }}
2828
- name: Upload Release Artifact
2929
uses: actions/upload-artifact@v4
3030
with:

.github/workflows/pull_request.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
name: Test
2424
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
2525
with:
26-
# Amazon Linux 2 won't work with GH infrastructure
2726
linux_os_versions: "[\"jammy\", \"focal\", \"rhel-ubi9\", \"noble\", \"bookworm\", \"fedora39\"]"
2827
# We only care about the current stable release, because that's where we make our swiftly releases
2928
linux_exclude_swift_versions: "[{\"swift_version\": \"nightly-main\"},{\"swift_version\": \"nightly-6.0\"},{\"swift_version\": \"5.8\"},{\"swift_version\": \"5.9\"},{\"swift_version\": \"5.10\"}]"
@@ -39,7 +38,7 @@ jobs:
3938
- name: Checkout repository
4039
uses: actions/checkout@v4
4140
- name: Build Artifact
42-
run: swift run build-swiftly-release --skip "999.0.0"
41+
run: swift run build-swiftly-release --use-rhel-ubi9 --skip "999.0.0"
4342
- name: Upload Artifact
4443
uses: actions/upload-artifact@v4
4544
with:

Tools/build-swiftly-release/BuildSwiftlyRelease.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public func getShell() async throws -> String {
126126
}
127127
#endif
128128

129-
public func isRHEL9() -> Bool {
129+
public func isSupportedLinux(useRhelUbi9: Bool) -> Bool {
130130
let osReleaseFiles = ["/etc/os-release", "/usr/lib/os-release"]
131131
var releaseFile: String?
132132
for file in osReleaseFiles {
@@ -165,8 +165,14 @@ public func isRHEL9() -> Bool {
165165
return false
166166
}
167167

168-
guard let versionID, versionID.hasPrefix("9"), (id + idlike).contains("rhel") else {
169-
return false
168+
if useRhelUbi9 {
169+
guard let versionID, versionID.hasPrefix("9"), (id + idlike).contains("rhel") else {
170+
return false
171+
}
172+
} else {
173+
guard let versionID = versionID, versionID == "2", (id + idlike).contains("amzn") else {
174+
return false
175+
}
170176
}
171177

172178
return true
@@ -188,6 +194,9 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
188194

189195
@Option(help: "Package identifier of macOS package")
190196
var identifier: String = "org.swift.swiftly"
197+
#elseif os(Linux)
198+
@Flag(name: .long, help: "Use RHEL UBI9 as the supported Linux to build a release instead of Amazon Linux 2")
199+
var useRhelUbi9: Bool = false
191200
#endif
192201

193202
@Argument(help: "Version of swiftly to build the release.")
@@ -286,11 +295,12 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
286295
}
287296

288297
func buildLinuxRelease() async throws {
298+
#if os(Linux)
289299
// Check system requirements
290-
guard isRHEL9() else {
291-
// TODO: see if docker can be used to spawn an Amazon Linux 2 container to continue the release building process
292-
throw Error(message: "Linux releases must be made from Amazon Linux 2 because it has the oldest version of glibc for maximum compatibility with other versions of Linux")
300+
guard isSupportedLinux(useRhelUbi9: self.useRhelUbi9) else {
301+
throw Error(message: "Linux releases must be made from specific distributions so that the binary can be used everyone else because it has the oldest version of glibc for maximum compatibility with other versions of Linux. Please try again with \(!self.useRhelUbi9 ? "Amazon Linux 2" : "RedHat UBI 9").")
293302
}
303+
#endif
294304

295305
// TODO: turn these into checks that the system meets the criteria for being capable of using the toolchain + checking for packages, not tools
296306
let curl = try await self.assertTool("curl", message: "Please install curl with `yum install curl`")

0 commit comments

Comments
 (0)