Skip to content

Restore amazon linux 2 as the default release build platform #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 10, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
description: "Version of swiftly to build release artifacts"
required: true
type: string
default: "0.3.0"
default: "0.4.0-dev"
skip:
description: "Perform release checks, such as the git tag, and swift version, or '--skip' to skip that."
required: true
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Release Artifact
run: swift run build-swiftly-release ${{ inputs.skip }} ${{ inputs.version }}
run: swift run build-swiftly-release --use-rhel-ubi9 ${{ inputs.skip }} ${{ inputs.version }}
- name: Upload Release Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
# Amazon Linux 2 won't work with GH infrastructure
linux_os_versions: "[\"jammy\", \"focal\", \"rhel-ubi9\", \"noble\", \"bookworm\", \"fedora39\"]"
# We only care about the current stable release, because that's where we make our swiftly releases
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\"}]"
Expand All @@ -39,7 +38,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Artifact
run: swift run build-swiftly-release --skip "999.0.0"
run: swift run build-swiftly-release --use-rhel-ubi9 --skip "999.0.0"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
22 changes: 16 additions & 6 deletions Tools/build-swiftly-release/BuildSwiftlyRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public func getShell() async throws -> String {
}
#endif

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

guard let versionID, versionID.hasPrefix("9"), (id + idlike).contains("rhel") else {
return false
if useRhelUbi9 {
guard let versionID, versionID.hasPrefix("9"), (id + idlike).contains("rhel") else {
return false
}
} else {
guard let versionID = versionID, versionID == "2", (id + idlike).contains("amzn") else {
return false
}
}

return true
Expand All @@ -188,6 +194,9 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {

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

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

func buildLinuxRelease() async throws {
#if os(Linux)
// Check system requirements
guard isRHEL9() else {
// TODO: see if docker can be used to spawn an Amazon Linux 2 container to continue the release building process
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")
guard isSupportedLinux(useRhelUbi9: self.useRhelUbi9) else {
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").")
}
#endif

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