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
40 changes: 40 additions & 0 deletions .github/workflows/android_sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Android SDK

permissions:
contents: read

on:
workflow_call:
inputs:
env_vars:
type: string
description: "Environment variables for jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
default: "{}"
additional_command_arguments:
type: string
description: "Additional arguments passed to swift build (the Android SDK will be specified). Defaults to empty."
default: ""

jobs:
android-sdk:
name: Android Swift SDK
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
with:
name: "Android Swift SDK"
matrix_string: >-
{
"config":[
{
"name":"main Jammy",
"swift_version":"main",
"platform":"Linux",
"runner":"ubuntu-latest",
"image":"ubuntu:jammy",
"setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_sdk.sh | INSTALL_SWIFT_BRANCH=main INSTALL_SWIFT_ARCH=x86_64 INSTALL_SWIFT_SDK=android-sdk bash && hash -r",
"command":"curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/swift-build-with-android-sdk.sh | bash -s --",
"command_arguments":"${{ inputs.additional_command_arguments }}",
"env":'"$env_vars_json"'
}
]
}
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ jobs:
with:
additional_command_arguments: "--target NIOCore"

android-sdk:
name: Android Swift SDK
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/android_sdk.yml@main
with:
additional_command_arguments: "--target NIOCore"

macos-tests:
name: macOS tests
# Workaround https://github.com/nektos/act/issues/1875
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ jobs:
with:
additional_command_arguments: "--target NIOCore"

android-sdk:
name: Android Swift SDK
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/android_sdk.yml@main
with:
additional_command_arguments: "--target NIOCore"

release-builds:
name: Release builds
uses: apple/swift-nio/.github/workflows/release_builds.yml@main
4 changes: 4 additions & 0 deletions scripts/install_swift_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ case "$sdk" in
sdk_dir="wasm-sdk"
sdk_suffix="_wasm"
;;
"android-sdk")
sdk_dir="android-sdk"
sdk_suffix="_android-0.1"
;;
*)
fatal "Unexpected Swift SDK: $sdk"
;;
Expand Down
26 changes: 26 additions & 0 deletions scripts/swift-build-with-android-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftNIO open source project
##
## Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##

set -uo pipefail

# Select the Swift SDK for Android
SWIFT_SDK="$(swift sdk list | grep android | head -n1)"
if [[ -z "$SWIFT_SDK" ]]; then
echo "No Android Swift SDK found. Please ensure you have the Android Swift SDK installed."
exit 1
fi

echo "Using Swift SDK: $SWIFT_SDK"
swift build --swift-sdk "$SWIFT_SDK" "${@}"