From 28e70b57e99130b7590d91c8b2f5c8d7230b39a3 Mon Sep 17 00:00:00 2001 From: Daiki Matsudate <20222809+d-date@users.noreply.github.com> Date: Thu, 22 Oct 2026 02:34:11 +0900 Subject: [PATCH 1/4] Extract Linux toolchains into a deterministic, freshly wiped directory SwiftPM records the compiler's absolute path in build signatures, so a random extraction directory invalidated restored .build caches on every run. The toolchain now goes to $RUNNER_TOOL_CACHE/swift-verified//-, which is removed entirely (after validating the path) and then filled only from the archive verified in this run. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XVjPg7eFxt1cU3r6wzjYTa --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++-------- README.md | 10 ++++++---- action.yml | 1 + install-linux.sh | 20 ++++++++++++++++---- plan-linux.sh | 1 + 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e33b1d9..bded42d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,17 @@ jobs: env: SOURCE: ${{ steps.setup.outputs.source }} run: test "$SOURCE" = cache + - id: again + uses: ./ + with: + swift-version: ${{ matrix.swift }} + - name: Two runs in one job resolve the same swift-path + env: + FIRST: ${{ steps.setup.outputs.swift-path }} + SECOND: ${{ steps.again.outputs.swift-path }} + run: | + echo "$FIRST / $SECOND" + test -n "$FIRST" && test "$FIRST" = "$SECOND" unsupported-version: runs-on: ubuntu-24.04 @@ -164,8 +175,10 @@ jobs: export RUNNER_TEMP="${RUNNER_TEMP:-/tmp}" GITHUB_OUTPUT="$PWD/out.txt" GITHUB_PATH="$PWD/path.txt" : > "$GITHUB_OUTPUT"; : > "$GITHUB_PATH" bash plan-linux.sh - export SWIFT_URL SWIFT_FILE + export SWIFT_URL SWIFT_FILE INSTALL_DIR SWIFT_URL="$(sed -n 's/^url=//p' out.txt)"; SWIFT_FILE="$(sed -n 's/^file=//p' out.txt)" + INSTALL_DIR="$(sed -n 's/^install-dir=//p' out.txt)" + echo "install dir: $INSTALL_DIR" dl="$RUNNER_TEMP/dl-cache" echo "== 1. populate: downloads and verifies" @@ -176,19 +189,27 @@ jobs: DOWNLOAD_DIR="$dl" bash install-linux.sh tail -1 out.txt | grep -q '^source=cache$' test "$(grep -c . path.txt)" -eq 2 - test "$(sort -u path.txt | wc -l)" -eq 2 # a fresh directory per run + test "$(sort -u path.txt | wc -l)" -eq 1 # deterministic path keeps SwiftPM caches valid - echo "== 3. planted extracted tree and fake swift are never used (cache disabled)" - planted="$RUNNER_TOOL_CACHE/swift/planted" - mkdir -p "$planted/usr/bin" - printf '#!/bin/sh\ntouch "%s/planted-ran"\n' "$RUNNER_TEMP" > "$planted/usr/bin/swift" - chmod +x "$planted/usr/bin/swift" + echo "== 3. a planted tree at the deterministic path is wiped, never used (cache disabled)" + mkdir -p "$INSTALL_DIR/usr/bin" "$INSTALL_DIR/evil" + printf '#!/bin/sh\ntouch "%s/planted-ran"\n' "$RUNNER_TEMP" > "$INSTALL_DIR/usr/bin/swift" + chmod +x "$INSTALL_DIR/usr/bin/swift" + touch "$INSTALL_DIR/evil/marker" : > path.txt env -u DOWNLOAD_DIR bash install-linux.sh tail -1 out.txt | grep -q '^source=download$' - if grep -q planted path.txt; then exit 1; fi + test ! -e "$INSTALL_DIR/evil/marker" + test ! -e "$RUNNER_TEMP/planted-ran" + "$INSTALL_DIR/usr/bin/swift" --version | grep -q "swift-$SWIFT_VERSION-RELEASE" test ! -e "$RUNNER_TEMP/planted-ran" + echo "== 3b. unexpected install directories are refused" + for bad in "" / "$RUNNER_TEMP" "$RUNNER_TOOL_CACHE/swift-verified/../x"; do + if INSTALL_DIR="$bad" DOWNLOAD_DIR="$dl" bash install-linux.sh; then echo "accepted '$bad'"; exit 1; fi + done + test -d "$RUNNER_TEMP" + echo "== 4. tampered archive fails closed (no silent re-download)" cp -r "$dl" "$RUNNER_TEMP/dl-bad-archive" printf 'x' >> "$RUNNER_TEMP/dl-bad-archive/$SWIFT_FILE" diff --git a/README.md b/README.md index 2b22bd8..3b15fcc 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ see [How verification works](#how-verification-works)). It never runs a pre-exis | `swift-version` | yes | | Exact toolchain version, e.g. `6.4.1` or `6.3.3`. Ranges and `latest` are not supported. | | `swift-sdks` | no | | Cross-compilation Swift SDKs to install after the toolchain: `static-linux`, `wasm`, `android` (comma or space separated). | | `use-preinstalled` | no | `false` | **Unverified opt-in.** If `swift` on `PATH` already reports exactly `swift-version`, run and use it instead of installing. By default no pre-existing binary is ever executed. | -| `cache` | no | `true` | Cache the downloaded Linux toolchain archive and its `.sig` with `actions/cache`. The archive is re-verified with GPG on every run and extracted into a fresh directory; `false` reuses nothing on disk. | +| `cache` | no | `true` | Cache the downloaded Linux toolchain archive and its `.sig` with `actions/cache`. The archive is re-verified with GPG on every run and extracted into a clean per-version directory; `false` reuses nothing on disk. | ## Outputs @@ -50,14 +50,16 @@ published for every platform (for example, newer releases have no Ubuntu 20.04 b download fails with the URL that was tried. Linux: the tarball and `.sig` are kept in `$RUNNER_TOOL_CACHE/swift-archives/...` and cached (key: version, -platform, arch). Every run, including a cache hit, re-verifies them with GPG and extracts into a new private -directory under `$RUNNER_TEMP`, which is added to `PATH`; extracted trees are never cached or reused. A cache +platform, arch). Every run, including a cache hit, re-verifies them with GPG and wipes and then extracts into the +deterministic directory `$RUNNER_TOOL_CACHE/swift-verified//-`, which is added to `PATH`. +The path is stable so SwiftPM build caches (which record the compiler path) stay valid, but whatever was in it is +deleted first and only the archive verified in this run is extracted; extracted trees are never cached or reused. A cache entry that fails verification fails the job instead of being re-downloaded. Missing build prerequisites (`libcurl4-openssl-dev`, `libxml2-dev`, the GCC dev packages, ...) are installed with `apt-get` only if absent. macOS: the package is installed into the user domain (`~/Library/Developer/Toolchains`), falling back to `sudo installer -target /`. `TOOLCHAINS` is exported with the toolchain's bundle identifier and its -`usr/bin` is prepended to `PATH`. macOS installs are not cached. +`usr/bin` is prepended to `PATH`. The install path is deterministic (like the Linux and Windows ones), so SwiftPM build caches stay valid. macOS installs are not cached. Windows: the installer runs silently (`/install /quiet`) into `%LocalAppData%\Programs\Swift`; the toolchain and runtime `bin` directories are added to `PATH` and `SDKROOT` is set. Visual Studio (C++ tools, Windows SDK), diff --git a/action.yml b/action.yml index 9533990..af4a377 100644 --- a/action.yml +++ b/action.yml @@ -85,6 +85,7 @@ runs: env: SWIFT_URL: ${{ steps.plan.outputs.url }} SWIFT_FILE: ${{ steps.plan.outputs.file }} + INSTALL_DIR: ${{ steps.plan.outputs.install-dir }} DOWNLOAD_DIR: ${{ inputs.cache == 'true' && steps.plan.outputs.download-dir || '' }} run: bash "$GITHUB_ACTION_PATH/install-linux.sh" diff --git a/install-linux.sh b/install-linux.sh index 9eb470a..6eefbf4 100755 --- a/install-linux.sh +++ b/install-linux.sh @@ -1,14 +1,16 @@ #!/usr/bin/env bash # Installs a swift.org Linux toolchain. The tarball and its .sig are verified with GPG on -# EVERY run (see verify-gpg.sh) and extracted into a fresh private directory, so nothing -# previously on disk is ever executed. DOWNLOAD_DIR may hold a cached copy of the archive +# EVERY run (see verify-gpg.sh) and extracted into INSTALL_DIR, a deterministic per-version path (stable compiler paths keep SwiftPM +# build caches valid). INSTALL_DIR is removed completely before extraction, so nothing previously +# on disk is ever executed. DOWNLOAD_DIR may hold a cached copy of the archive # pair to skip the download; it is re-verified before use. Without DOWNLOAD_DIR # (cache: false) nothing on disk is reused. -# Inputs (env): SWIFT_URL, SWIFT_FILE; optional DOWNLOAD_DIR, GITHUB_PATH, GITHUB_OUTPUT. +# Inputs (env): SWIFT_URL, SWIFT_FILE, INSTALL_DIR; optional DOWNLOAD_DIR, GITHUB_PATH, GITHUB_OUTPUT. set -euo pipefail url="${SWIFT_URL:?}" file="${SWIFT_FILE:?}" +dest="${INSTALL_DIR:?}" here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=verify-gpg.sh . "$here/verify-gpg.sh" @@ -66,7 +68,17 @@ fi # Fail closed: a tampered cache entry is NOT replaced by a fresh download. verify_gpg_signature "$archive_dir/$file" "$archive_dir/$file.sig" "$scratch" -dest="$(mktemp -d "${RUNNER_TEMP:-/tmp}/swift-toolchain.XXXXXX")" +# Refuse anything but an absolute .../swift-verified// path before deleting it. +case "$dest" in + /*/swift-verified/*/*) ;; + *) echo "::error::Refusing unexpected install directory '$dest'"; exit 1 ;; +esac +case "$dest" in + *..* | */./* | *//*) echo "::error::Refusing unexpected install directory '$dest'"; exit 1 ;; +esac +# Never reuse existing contents: wipe, then extract only the archive verified above. +rm -r -f -- "$dest" +mkdir -p "$dest" tar -xzf "$archive_dir/$file" -C "$dest" --strip-components=1 [ -x "$dest/usr/bin/swift" ] || { echo "::error::$dest/usr/bin/swift is missing after extraction"; exit 1; } if [ -n "${GITHUB_PATH:-}" ]; then echo "$dest/usr/bin" >> "$GITHUB_PATH"; fi diff --git a/plan-linux.sh b/plan-linux.sh index 6c28c94..3d7a918 100755 --- a/plan-linux.sh +++ b/plan-linux.sh @@ -37,6 +37,7 @@ root="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:-/tmp}}" { echo "url=${base}/${file}" echo "file=${file}" + echo "install-dir=${root}/swift-verified/${v}/${arch}-${dir_platform}" echo "download-dir=${root}/swift-archives/${v}-${arch}-${dir_platform}" echo "cache-key=swift-toolchain-${v}-${dir_platform}-${arch}-archive-v2" } >> "${GITHUB_OUTPUT:?}" From afd1d0059c3f38ea1cb67a357e2825717efb3da0 Mon Sep 17 00:00:00 2001 From: Daiki Matsudate <20222809+d-date@users.noreply.github.com> Date: Thu, 22 Oct 2026 02:43:16 +0900 Subject: [PATCH 2/4] Install under RUNNER_TEMP from a verified snapshot and refuse symlinked paths The toolchain moves to $RUNNER_TEMP/setup-swift//- (stable across runs, private to one runner instance). The cached archive is copied to a private snapshot that is both GPG-verified and extracted, and no path component from RUNNER_TEMP down may be a symlink. CI covers symlinked components and out-of-tree install directories. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XVjPg7eFxt1cU3r6wzjYTa --- .github/workflows/ci.yml | 12 +++++++++- README.md | 14 ++++++++---- install-linux.sh | 49 ++++++++++++++++++++++++++++++++-------- plan-linux.sh | 7 +++++- 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bded42d..11c6dc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,11 +205,21 @@ jobs: test ! -e "$RUNNER_TEMP/planted-ran" echo "== 3b. unexpected install directories are refused" - for bad in "" / "$RUNNER_TEMP" "$RUNNER_TOOL_CACHE/swift-verified/../x"; do + for bad in "" / "$RUNNER_TEMP" "$RUNNER_TEMP/setup-swift/../x" "$RUNNER_TOOL_CACHE/swift-verified/x/y"; do if INSTALL_DIR="$bad" DOWNLOAD_DIR="$dl" bash install-linux.sh; then echo "accepted '$bad'"; exit 1; fi done test -d "$RUNNER_TEMP" + echo "== 3c. a symlinked path component is refused and its target left untouched" + decoy="$(mktemp -d)" + touch "$decoy/marker" + rm -r -f -- "$RUNNER_TEMP/setup-swift/$SWIFT_VERSION" + ln -s "$decoy" "$RUNNER_TEMP/setup-swift/$SWIFT_VERSION" + if DOWNLOAD_DIR="$dl" bash install-linux.sh; then echo "installed through a symlink"; exit 1; fi + test -e "$decoy/marker" + test "$(find "$decoy" -mindepth 1 | wc -l)" -eq 1 + rm -f -- "$RUNNER_TEMP/setup-swift/$SWIFT_VERSION" + echo "== 4. tampered archive fails closed (no silent re-download)" cp -r "$dl" "$RUNNER_TEMP/dl-bad-archive" printf 'x' >> "$RUNNER_TEMP/dl-bad-archive/$SWIFT_FILE" diff --git a/README.md b/README.md index 3b15fcc..0917fa1 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,15 @@ published for every platform (for example, newer releases have no Ubuntu 20.04 b download fails with the URL that was tried. Linux: the tarball and `.sig` are kept in `$RUNNER_TOOL_CACHE/swift-archives/...` and cached (key: version, -platform, arch). Every run, including a cache hit, re-verifies them with GPG and wipes and then extracts into the -deterministic directory `$RUNNER_TOOL_CACHE/swift-verified//-`, which is added to `PATH`. -The path is stable so SwiftPM build caches (which record the compiler path) stay valid, but whatever was in it is -deleted first and only the archive verified in this run is extracted; extracted trees are never cached or reused. A cache -entry that fails verification fails the job instead of being re-downloaded. Missing build prerequisites (`libcurl4-openssl-dev`, +platform, arch). Every run, including a cache hit, copies them to a private snapshot, re-verifies the snapshot with +GPG, and extracts that same snapshot into `$RUNNER_TEMP/setup-swift//-`, which is added to +`PATH`. The path is stable across runs so SwiftPM build caches (which record the compiler path) stay valid. Before +extraction the directory is validated (exactly that shape, no `..`, and no symlink in any component from +`RUNNER_TEMP` down, checked again just before use) and removed entirely, so nothing previously on disk is reused. +A cache entry that fails verification fails the job instead of being re-downloaded. Isolation model: +`RUNNER_TEMP` is private to one runner instance and emptied for every job on GitHub-hosted runners, so earlier or +concurrent jobs cannot plant or wipe the toolchain. Self-hosted runners must not share `RUNNER_TEMP` between +concurrently running jobs, and must run jobs of different trust levels on separate runner instances. Missing build prerequisites (`libcurl4-openssl-dev`, `libxml2-dev`, the GCC dev packages, ...) are installed with `apt-get` only if absent. macOS: the package is installed into the user domain (`~/Library/Developer/Toolchains`), falling back to diff --git a/install-linux.sh b/install-linux.sh index 6eefbf4..55c9d5a 100755 --- a/install-linux.sh +++ b/install-linux.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # Installs a swift.org Linux toolchain. The tarball and its .sig are verified with GPG on -# EVERY run (see verify-gpg.sh) and extracted into INSTALL_DIR, a deterministic per-version path (stable compiler paths keep SwiftPM -# build caches valid). INSTALL_DIR is removed completely before extraction, so nothing previously -# on disk is ever executed. DOWNLOAD_DIR may hold a cached copy of the archive +# EVERY run (see verify-gpg.sh) and extracted from a private snapshot (the very bytes that were verified) into INSTALL_DIR, a stable +# per-version path under RUNNER_TEMP (stable compiler paths keep SwiftPM build caches valid). +# INSTALL_DIR is removed completely first, so nothing previously on disk is ever executed. DOWNLOAD_DIR may hold a cached copy of the archive # pair to skip the download; it is re-verified before use. Without DOWNLOAD_DIR # (cache: false) nothing on disk is reused. # Inputs (env): SWIFT_URL, SWIFT_FILE, INSTALL_DIR; optional DOWNLOAD_DIR, GITHUB_PATH, GITHUB_OUTPUT. @@ -65,21 +65,50 @@ else mv "$archive_dir/$file.partial" "$archive_dir/$file" fi +# Work on a private snapshot: the cache path can be rewritten by others between verification +# and extraction, so verify and extract the very same copy. +snap="$scratch/snapshot" +mkdir "$snap" +cp "$archive_dir/$file" "$snap/$file" +cp "$archive_dir/$file.sig" "$snap/$file.sig" + # Fail closed: a tampered cache entry is NOT replaced by a fresh download. -verify_gpg_signature "$archive_dir/$file" "$archive_dir/$file.sig" "$scratch" +verify_gpg_signature "$snap/$file" "$snap/$file.sig" "$scratch" -# Refuse anything but an absolute .../swift-verified// path before deleting it. +# The install directory must be exactly $RUNNER_TEMP/setup-swift//, with no +# symlink anywhere from RUNNER_TEMP down (checked again right before use). +case "${RUNNER_TEMP:-}" in + /*) ;; + *) echo "::error::RUNNER_TEMP must be set to an absolute path"; exit 1 ;; +esac case "$dest" in - /*/swift-verified/*/*) ;; + "$RUNNER_TEMP"/setup-swift/*/*) ;; *) echo "::error::Refusing unexpected install directory '$dest'"; exit 1 ;; esac case "$dest" in - *..* | */./* | *//*) echo "::error::Refusing unexpected install directory '$dest'"; exit 1 ;; + *..* | */./* | *//* | */) echo "::error::Refusing unexpected install directory '$dest'"; exit 1 ;; esac -# Never reuse existing contents: wipe, then extract only the archive verified above. + +assert_no_symlinks() { # path: every component from RUNNER_TEMP down must not be a symlink + local cur="$RUNNER_TEMP" rest part + [ ! -L "$cur" ] || { echo "::error::$cur is a symlink"; return 1; } + rest="${1#"$RUNNER_TEMP"/}" + while [ -n "$rest" ]; do + part="${rest%%/*}" + cur="$cur/$part" + if [ -L "$cur" ]; then echo "::error::$cur is a symlink; refusing to install through it"; return 1; fi + case "$rest" in */*) rest="${rest#*/}" ;; *) rest="" ;; esac + done +} + +(umask 077 && mkdir -p "$(dirname "$dest")") +assert_no_symlinks "$dest" +# Never reuse existing contents: wipe, then extract only the snapshot verified above. rm -r -f -- "$dest" -mkdir -p "$dest" -tar -xzf "$archive_dir/$file" -C "$dest" --strip-components=1 +mkdir "$dest" +assert_no_symlinks "$dest" +tar -xzf "$snap/$file" -C "$dest" --strip-components=1 --no-same-owner +rm -r -f -- "$snap" [ -x "$dest/usr/bin/swift" ] || { echo "::error::$dest/usr/bin/swift is missing after extraction"; exit 1; } if [ -n "${GITHUB_PATH:-}" ]; then echo "$dest/usr/bin" >> "$GITHUB_PATH"; fi if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "source=$source" >> "$GITHUB_OUTPUT"; fi diff --git a/plan-linux.sh b/plan-linux.sh index 3d7a918..a1cca30 100755 --- a/plan-linux.sh +++ b/plan-linux.sh @@ -33,11 +33,16 @@ esac base="https://download.swift.org/swift-${v}-release/${dir_platform}${arch_suffix}/swift-${v}-RELEASE" file="swift-${v}-RELEASE-${file_platform}${arch_suffix}.tar.gz" root="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:-/tmp}}" +# The toolchain lives under RUNNER_TEMP: private to this runner instance and emptied for every job. +case "${RUNNER_TEMP:-}" in + /*) ;; + *) echo "::error::RUNNER_TEMP must be set to an absolute path"; exit 1 ;; +esac { echo "url=${base}/${file}" echo "file=${file}" - echo "install-dir=${root}/swift-verified/${v}/${arch}-${dir_platform}" + echo "install-dir=${RUNNER_TEMP}/setup-swift/${v}/${arch}-${dir_platform}" echo "download-dir=${root}/swift-archives/${v}-${arch}-${dir_platform}" echo "cache-key=swift-toolchain-${v}-${dir_platform}-${arch}-archive-v2" } >> "${GITHUB_OUTPUT:?}" From d339f472ac939b378e124f4273729eea9b0406b5 Mon Sep 17 00:00:00 2001 From: Daiki Matsudate <20222809+d-date@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:31:00 +0900 Subject: [PATCH 3/4] Support Ubuntu 26.04 and map any Ubuntu release generically plan-linux.sh derives swift.org's platform names from VERSION_ID instead of a fixed list, so new Ubuntu releases work once swift.org publishes them. install-linux.sh adds GCC 15 for 26.04 and falls back to the distribution's default GCC for unknown releases. CI covers ubuntu-26.04(-arm) with 6.4.1. Co-Authored-By: Claude Opus 5.5 --- .github/actionlint.yaml | 3 +++ .github/workflows/ci.yml | 7 +++++++ README.md | 5 +++-- install-linux.sh | 6 +++++- plan-linux.sh | 18 +++++++++--------- 5 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 .github/actionlint.yaml diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..6ee46a3 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,3 @@ +# GitHub-hosted labels newer than the pinned actionlint release. +self-hosted-runner: + labels: [ubuntu-26.04, ubuntu-26.04-arm] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11c6dc8..356832b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,10 @@ jobs: matrix: os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm, macos-latest, windows-latest] swift: ["6.4.1", "6.3.3"] + # swift.org publishes Ubuntu 26.04 toolchains from 6.4 on. + include: + - { os: ubuntu-26.04, swift: "6.4.1" } + - { os: ubuntu-26.04-arm, swift: "6.4.1" } steps: - uses: actions/checkout@v7 - id: setup @@ -66,6 +70,9 @@ jobs: matrix: os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm] swift: ["6.4.1", "6.3.3"] + include: + - { os: ubuntu-26.04, swift: "6.4.1" } + - { os: ubuntu-26.04-arm, swift: "6.4.1" } steps: - uses: actions/checkout@v7 - id: setup diff --git a/README.md b/README.md index 0917fa1..264759b 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,14 @@ emitted); that toolchain is **not verified** by this action. | Platform | Artifact | Verification | | --- | --- | --- | -| Ubuntu 20.04 / 22.04 / 24.04, x86_64 and aarch64 | `swift--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--RELEASE-ubuntuNN.NN[-aarch64].tar.gz` | GPG `.sig` against pinned swift.org keys | | macOS (any runner) | `swift--RELEASE-osx.pkg` | `pkgutil --check-signature`, notarization, pinned Developer ID team | | Windows, x86_64 and arm64 | `swift--RELEASE-windows10[-arm64].exe` | Authenticode `Valid` and signer subject (Apple Inc.) | | Swift SDKs (`static-linux`, `wasm`, `android`) on any host | `swift--RELEASE_.artifactbundle.tar.gz` | sha256 pinned in `sdk-checksums.txt`, plus GPG `.sig` when `gpg` exists | Other Linux distributions and architectures fail with an explicit error. Not every version is -published for every platform (for example, newer releases have no Ubuntu 20.04 build); a missing +published for every platform (for example, newer releases have no Ubuntu 20.04 build and Ubuntu 26.04 +starts with 6.4); a missing download fails with the URL that was tried. Linux: the tarball and `.sig` are kept in `$RUNNER_TOOL_CACHE/swift-archives/...` and cached (key: version, diff --git a/install-linux.sh b/install-linux.sh index 55c9d5a..4342cae 100755 --- a/install-linux.sh +++ b/install-linux.sh @@ -23,10 +23,14 @@ missing=() # GCC development packages per swift.org's prerequisites for each Ubuntu release. # shellcheck disable=SC1091 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") diff --git a/plan-linux.sh b/plan-linux.sh index a1cca30..1fcffed 100755 --- a/plan-linux.sh +++ b/plan-linux.sh @@ -11,15 +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 ;; - *) - echo "::error::Unsupported Linux distribution '${ID:-?} ${VERSION_ID:-?}'; setup-swift supports Ubuntu 20.04, 22.04 and 24.04" - exit 1 - ;; -esac +# Any Ubuntu release maps to swift.org's naming (ubuntu2604 / ubuntu26.04), so new LTS 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="" ;; From ebf0ff769771494dff02eb666ff8559ff5f8b7d0 Mon Sep 17 00:00:00 2001 From: Daiki Matsudate <20222809+d-date@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:31:00 +0900 Subject: [PATCH 4/4] Add a weekly workflow that tests the newest Swift on the newest Ubuntu runners Discovers the latest swift.org release and every Ubuntu version that both swift.org and GitHub-hosted runners offer, installs and runs hello world on each, and opens or updates a tracking issue when the scheduled run fails. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/watch-linux.yml | 81 +++++++++++++++++++++++++++++++ README.md | 8 ++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/watch-linux.yml diff --git a/.github/workflows/watch-linux.yml b/.github/workflows/watch-linux.yml new file mode 100644 index 0000000..af78535 --- /dev/null +++ b/.github/workflows/watch-linux.yml @@ -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 (?[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 diff --git a/README.md b/README.md index 264759b..8b0f0eb 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,12 @@ compressed; use `curl --compressed`). The fingerprints were cross-checked agains ## Development CI (`.github/workflows/ci.yml`) runs shellcheck, actionlint, installs 6.4.1 and 6.3.3 on -`ubuntu-22.04`, `ubuntu-24.04`, `ubuntu-24.04-arm`, `macos-latest` and `windows-latest`, checks the Linux +`ubuntu-22.04`, `ubuntu-24.04`, `ubuntu-24.04-arm`, `macos-latest` and `windows-latest` (plus 6.4.1 on +`ubuntu-26.04` and `ubuntu-26.04-arm`), checks the Linux cache-hit path, and builds hello world with the static Linux, WebAssembly and Android SDKs. Not covered by CI: Ubuntu 20.04 (no 6.x tarballs for recent versions), Windows arm64, running WebAssembly output. + +`.github/workflows/watch-linux.yml` runs weekly: it installs the newest swift.org release on every Ubuntu +runner that both swift.org and GitHub-hosted runners offer, so a new Ubuntu release is tested as soon as it +appears (no code change is needed for a new Ubuntu version). A failing scheduled run opens or comments on a +"Latest Linux check failing" issue.