Skip to content

Commit 32a6c45

Browse files
committed
Make using RHEL UBI9 an option to the build release script
1 parent eafe366 commit 32a6c45

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

.github/workflows/build_release.yml

Lines changed: 3 additions & 3 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
@@ -19,12 +19,12 @@ jobs:
1919
name: Build Release
2020
runs-on: ubuntu-latest
2121
container:
22-
image: "swift:6.0-amazonlinux2"
22+
image: "swift:6.0-rhel-ubi9"
2323
steps:
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
name: Test
2424
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
2525
with:
26-
linux_os_versions: "[\"jammy\", \"focal\", \"rhel-ubi9\", \"noble\", \"bookworm\", \"fedora39\", \"amazonlinux2\"]"
26+
linux_os_versions: "[\"jammy\", \"focal\", \"rhel-ubi9\", \"noble\", \"bookworm\", \"fedora39\"]"
2727
# We only care about the current stable release, because that's where we make our swiftly releases
2828
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\"}]"
2929
linux_pre_build_command: ./scripts/prep-gh-action.sh && ./scripts/install-libarchive.sh
@@ -33,12 +33,12 @@ jobs:
3333
name: Release Build Check
3434
runs-on: ubuntu-latest
3535
container:
36-
image: "swift:6.0-amazonlinux2"
36+
image: "swift:6.0-rhel-ubi9"
3737
steps:
3838
- name: Checkout repository
3939
uses: actions/checkout@v4
4040
- name: Build Artifact
41-
run: swift run build-swiftly-release --skip "999.0.0"
41+
run: swift run build-swiftly-release --use-rhel-ubi9 --skip "999.0.0"
4242
- name: Upload Artifact
4343
uses: actions/upload-artifact@v4
4444
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 isAmazonLinux2() -> 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 isAmazonLinux2() -> Bool {
165165
return false
166166
}
167167

168-
guard let versionID = versionID, versionID == "2", (id + idlike).contains("amzn") 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
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 isAmazonLinux2() 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(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)