From f1c3a840545774cf1e3fcadb1e12ed1f41c16647 Mon Sep 17 00:00:00 2001 From: Teodor Calin Date: Tue, 9 Jun 2026 09:45:03 +0300 Subject: [PATCH 1/2] fix(release+ci): SwiftPM checksum is SHA-256, smoke extracts only Quick start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated bugs surfacing as one red CI on main: 1) Package.swift's checksum was 128 hex chars — a SHA-512 — when SwiftPM's binaryTarget API requires SHA-256 (64 hex). SwiftPM accepted the value at parse time but rejected at fetch: error: checksum of downloaded artifact of binary target 'PilotC' (a59c9b99…25e) does not match checksum specified by the manifest (2a39465a…020) Recomputed via `swift package compute-checksum` and updated. The right value is the one SwiftPM was already showing in the diff. 2) The smoke test's awk extracted the FIRST ```swift fenced block, which on this README is the install snippet showing how to add the package to a consumer's Package.swift. Concatenated with the actual quickstart block below, the result was syntactically broken Swift that swiftc couldn't compile. Anchored the extraction to the `## Quick start` heading so only the runnable block is picked. Exits with a clearer error if the heading or its swift block ever moves. Verified locally: `swift package compute-checksum Pilot.xcframework.zip` returns the new value; the awk extracts exactly the 27 runnable lines. --- .github/workflows/sdk-examples-smoke-test.yml | 16 +++++++++++++--- Package.swift | 7 ++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sdk-examples-smoke-test.yml b/.github/workflows/sdk-examples-smoke-test.yml index d4d2f5d..c5eb96a 100644 --- a/.github/workflows/sdk-examples-smoke-test.yml +++ b/.github/workflows/sdk-examples-smoke-test.yml @@ -24,11 +24,21 @@ jobs: - name: Extract README quickstart run: | - # PILOT-197: extract the first ```swift fenced block. + # PILOT-197: extract the ```swift fenced block under the + # `## Quick start` heading. The README has multiple ```swift + # blocks (the install-instructions Package.swift snippet + # being the first); concatenating them with a naive `awk` + # produced invalid code that swiftc couldn't compile. mkdir -p /tmp/smoke - awk '/^```swift$/{flag=1;next}/^```$/{flag=0}flag' README.md > /tmp/smoke/main.swift + awk ' + /^## Quick start/ { in_section = 1; next } + in_section && /^## / { in_section = 0; next } + in_section && /^```swift$/ { flag = 1; next } + in_section && flag && /^```$/ { flag = 0; exit } + in_section && flag + ' README.md > /tmp/smoke/main.swift if [ ! -s /tmp/smoke/main.swift ]; then - echo "::error::no quickstart code block found in README.md" + echo "::error::no quickstart code block found under '## Quick start' in README.md" exit 1 fi diff --git a/Package.swift b/Package.swift index e56fbb5..440dbe4 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,12 @@ let package = Package( .binaryTarget( name: "PilotC", url: "https://github.com/pilot-protocol/sdk-swift/releases/download/v0.2.0/Pilot.xcframework.zip", - checksum: "2a39465af3d9e77eed750b494272c690251824198f6d5b68cfa2d60f4bbc9b02a600976380d24f7911b396872fc83e8d6e748d71f176fbdb8075141447e67020" + // SwiftPM binaryTarget checksums are SHA-256 (64 hex chars). + // The previous value was 128 hex (a SHA-512), which SwiftPM + // accepted at parse time but rejected at fetch: + // "checksum of downloaded artifact … does not match …". + // Recomputed via `swift package compute-checksum`. + checksum: "a59c9b99061d1078cc6f5e7ae1261af90144e2177cdb1b932fbcf3979578a25e" ), .testTarget( name: "PilotTests", From 53c139689e805682eda90807169869a6e10764ab Mon Sep 17 00:00:00 2001 From: Teodor Calin Date: Tue, 9 Jun 2026 09:52:11 +0300 Subject: [PATCH 2/2] fix(ci): unquote the smoke-test heredoc so $GITHUB_WORKSPACE expands The previous quoted heredoc (<<'PKG') left the literal string $GITHUB_WORKSPACE in the generated smoke Package.swift. SwiftPM threw: 'The folder "$GITHUB_WORKSPACE" doesn't exist.' Same workflow, separate bug from the checksum + awk fix in the parent commit. Discovered when CI re-ran after pushing this PR. --- .github/workflows/sdk-examples-smoke-test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sdk-examples-smoke-test.yml b/.github/workflows/sdk-examples-smoke-test.yml index c5eb96a..23d75f2 100644 --- a/.github/workflows/sdk-examples-smoke-test.yml +++ b/.github/workflows/sdk-examples-smoke-test.yml @@ -49,8 +49,13 @@ jobs: run: | # Wrap the snippet in a tiny SwiftPM project that depends on # the just-built SDK and runs the README block as @main. + # The heredoc is UNQUOTED so the shell expands + # $GITHUB_WORKSPACE into the absolute path — using the + # quoted form `<<'PKG'` (as the original did) leaves the + # literal string in Package.swift and SwiftPM throws + # "The folder $GITHUB_WORKSPACE doesn't exist". cd /tmp/smoke - cat > Package.swift <<'PKG' + cat > Package.swift <