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
81 changes: 81 additions & 0 deletions .github/workflows/watch-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Watch latest Linux

# Weekly: installs the newest swift.org release on every Ubuntu that swift.org publishes it for AND
# GitHub offers a hosted runner for, so new Ubuntu releases are exercised as soon as both exist
# (plan-linux.sh maps any Ubuntu version generically). Failures open or update a tracking issue.
on:
schedule:
- cron: "17 3 * * 1"
workflow_dispatch:

permissions:
contents: read

jobs:
discover:
runs-on: ubuntu-latest
outputs:
swift: ${{ steps.find.outputs.swift }}
runners: ${{ steps.find.outputs.runners }}
steps:
- id: find
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
releases="$(curl -sSfL --retry 3 https://www.swift.org/api/v1/install/releases.json)"
swift="$(jq -r '.[-1].name' <<< "$releases")"
[[ "$swift" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]] || { echo "::error::unexpected release name '$swift'"; exit 1; }
ubuntus="$(jq -r '.[-1].platforms[].name | capture("^Ubuntu (?<v>[0-9]{2}\\.[0-9]{2})$").v' <<< "$releases")"
labels="$(gh api repos/actions/runner-images/contents/README.md -H 'Accept: application/vnd.github.raw' \
| grep -oE "\`ubuntu-[0-9]{2}\\.[0-9]{2}(-arm)?\`" | tr -d '`' | sort -u)"
runners="$(for v in $ubuntus; do grep -E "^ubuntu-${v//./\\.}(-arm)?$" <<< "$labels" || true; done | jq -R . | jq -cs .)"
[ "$runners" != "[]" ] || { echo "::error::no Ubuntu runner matches swift.org $swift ($ubuntus)"; exit 1; }
echo "Swift $swift on $runners"
{ echo "swift=$swift"; echo "runners=$runners"; } >> "$GITHUB_OUTPUT"

install:
name: install (${{ matrix.os }}, ${{ needs.discover.outputs.swift }})
needs: discover
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.discover.outputs.runners) }}
steps:
- uses: actions/checkout@v7
- id: setup
uses: ./
with:
swift-version: ${{ needs.discover.outputs.swift }}
cache: "false"
- name: Compile and run hello world
env:
WANT: ${{ needs.discover.outputs.swift }}
VERSION: ${{ steps.setup.outputs.version }}
run: |
set -euo pipefail
test "$VERSION" = "$WANT"
mkdir hello && cd hello
swift package init --type executable --name hello
swift run

report:
needs: [discover, install]
if: failure() && github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SWIFT: ${{ needs.discover.outputs.swift }}
RUNNERS: ${{ needs.discover.outputs.runners }}
run: |
set -euo pipefail
title="Latest Linux check failing"
body="Swift \`${SWIFT:-?}\` on \`${RUNNERS:-?}\` failed: $RUN_URL"
num="$(gh issue list --state open --search "\"$title\" in:title" --json number --jq '.[0].number // empty')"
if [ -n "$num" ]; then gh issue comment "$num" --body "$body"; else gh issue create --title "$title" --body "$body"; fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ emitted); that toolchain is **not verified** by this action.

| Platform | Artifact | Verification |
| --- | --- | --- |
| Ubuntu 20.04 / 22.04 / 24.04 / 26.04, x86_64 and aarch64 | `swift-<v>-RELEASE-ubuntuNN.NN[-aarch64].tar.gz` | GPG `.sig` against pinned swift.org keys |
| Ubuntu (any release swift.org publishes, e.g. 22.04 / 24.04 / 26.04), x86_64 and aarch64 | `swift-<v>-RELEASE-ubuntuNN.NN[-aarch64].tar.gz` | GPG `.sig` against pinned swift.org keys |
| macOS (any runner) | `swift-<v>-RELEASE-osx.pkg` | `pkgutil --check-signature`, notarization, pinned Developer ID team |
| Windows, x86_64 and arm64 | `swift-<v>-RELEASE-windows10[-arm64].exe` | Authenticode `Valid` and signer subject (Apple Inc.) |
| Swift SDKs (`static-linux`, `wasm`, `android`) on any host | `swift-<v>-RELEASE_<kind>.artifactbundle.tar.gz` | sha256 pinned in `sdk-checksums.txt`, plus GPG `.sig` when `gpg` exists |
Expand Down
5 changes: 4 additions & 1 deletion install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ case "$(. /etc/os-release && echo "${VERSION_ID:-}")" in
26.04) gcc_ver=15 ;;
24.04) gcc_ver=13 ;;
22.04) gcc_ver=12 ;;
*) gcc_ver=10 ;;
20.04) gcc_ver=10 ;;
# Newer releases: the distribution's default GCC (what swift.org's Dockerfiles have used so far).
*) gcc_ver="$(apt-cache depends gcc 2> /dev/null | grep -m1 -oE 'gcc-[0-9]+' | cut -d- -f2 || true)" ;;
esac
[ -n "$gcc_ver" ] || { echo "::error::Cannot determine the GCC version for this Ubuntu release"; exit 1; }
for pkg in curl gnupg2 binutils git libcurl4-openssl-dev libedit2 libsqlite3-0 libxml2-dev \
libncurses-dev pkg-config tzdata uuid-dev zlib1g-dev "libgcc-${gcc_ver}-dev" "libstdc++-${gcc_ver}-dev"; do
dpkg -s "$pkg" > /dev/null 2>&1 || missing+=("$pkg")
Expand Down
19 changes: 9 additions & 10 deletions plan-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ fi

# shellcheck disable=SC1091
. /etc/os-release
case "${ID:-}-${VERSION_ID:-}" in
ubuntu-20.04) dir_platform=ubuntu2004; file_platform=ubuntu20.04 ;;
ubuntu-24.04) dir_platform=ubuntu2404; file_platform=ubuntu24.04 ;;
ubuntu-22.04) dir_platform=ubuntu2204; file_platform=ubuntu22.04 ;;
ubuntu-26.04) dir_platform=ubuntu2604; file_platform=ubuntu26.04 ;;
*)
echo "::error::Unsupported Linux distribution '${ID:-?} ${VERSION_ID:-?}'; setup-swift supports Ubuntu 20.04, 22.04, 24.04 and 26.04"
exit 1
;;
esac
# Any Ubuntu release maps to swift.org's naming (ubuntu2604 / ubuntu26.04), so new releases work
# without a code change; a version swift.org does not publish fails at download time.
if [ "${ID:-}" = ubuntu ] && [[ "${VERSION_ID:-}" =~ ^[0-9]{2}\.[0-9]{2}$ ]]; then
dir_platform="ubuntu${VERSION_ID//./}"
file_platform="ubuntu${VERSION_ID}"
else
echo "::error::Unsupported Linux distribution '${ID:-?} ${VERSION_ID:-?}'; setup-swift supports Ubuntu releases published on swift.org"
exit 1
fi

case "$(uname -m)" in
x86_64) arch=x86_64; arch_suffix="" ;;
Expand Down
Loading