diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index c2639bd8..654158bd 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -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 @@ -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: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 562f6e67..52fc7760 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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\"}]" @@ -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: diff --git a/Tools/build-swiftly-release/BuildSwiftlyRelease.swift b/Tools/build-swiftly-release/BuildSwiftlyRelease.swift index 1ca10696..a6ea0142 100644 --- a/Tools/build-swiftly-release/BuildSwiftlyRelease.swift +++ b/Tools/build-swiftly-release/BuildSwiftlyRelease.swift @@ -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 { @@ -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 @@ -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.") @@ -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`")