Skip to content
Open
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
33 changes: 33 additions & 0 deletions .github/actions/setup-nasm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

name: Set up NASM
description: >-
Installs NASM on Windows, which assembles the x86-64 assembly of the BoringSSL
that pkgs/boring vendors. Downloads the release from nasm.us and checks it
against a pinned SHA-256, instead of trusting a third-party action and its
mirror.
runs:
using: composite
steps:
- name: Install NASM
shell: bash
env:
NASM_VERSION: 2.16.01
# nasm.us doesn't publish checksums. This is the SHA-256 of
# nasm-2.16.01-win64.zip from nasm.us, which matches the hash in Scoop's
# manifest of NASM 2.16.01.
NASM_SHA256: 029eed31faf0d2c5f95783294432cbea6c15bf633430f254bb3c1f195c67ca3a
run: |
url="https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64/nasm-$NASM_VERSION-win64.zip"
curl -fsSL -o "$RUNNER_TEMP/nasm.zip" "$url"
actual="$(sha256sum < "$RUNNER_TEMP/nasm.zip" | cut -d' ' -f1)"
if [ "$actual" != "$NASM_SHA256" ]; then
echo "::error::Expected SHA-256 $NASM_SHA256 for $url, got $actual."
exit 1
fi
7z x "$RUNNER_TEMP/nasm.zip" -o"$RUNNER_TEMP" -y > /dev/null
"$RUNNER_TEMP/nasm-$NASM_VERSION/nasm.exe" -v
cygpath -w "$RUNNER_TEMP/nasm-$NASM_VERSION" >> "$GITHUB_PATH"
35 changes: 30 additions & 5 deletions .github/workflows/boring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ on:
push:
branches: [ main ]
paths:
- '.github/actions/setup-nasm/**'
- '.github/workflows/boring.yaml'
- 'pkgs/boring/**'
pull_request:
branches: [ main ]
paths:
- '.github/actions/setup-nasm/**'
- '.github/workflows/boring.yaml'
- 'pkgs/boring/**'
schedule:
Expand Down Expand Up @@ -78,16 +80,39 @@ jobs:
sdk: ${{ matrix.sdk }}
- name: Setup NASM
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b
uses: ./.github/actions/setup-nasm
- name: Install Linux cross toolchain (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# A third-party tap, which Homebrew can't pin, unlike the Windows download
# below. It only links the test's cross-compiled example, never anything
# that is released.
# The release of messense/homebrew-macos-cross-toolchains that its
# Homebrew tap installs, downloaded directly to pin its SHA-256, like the
# Windows download below.
- name: Install Linux cross toolchain (macOS)
if: runner.os == 'macOS'
run: brew install messense/macos-cross-toolchains/aarch64-unknown-linux-gnu
shell: bash
run: |
case "$(uname -m)" in
arm64)
url="https://github.com/messense/homebrew-macos-cross-toolchains/releases/download/v15.2.0/aarch64-unknown-linux-gnu-aarch64-darwin.tar.gz"
expected="0f224db36d8572489f09ed5bce39f189eee998f9ab4f8ea07f510d6c7078caa3"
;;
x86_64)
url="https://github.com/messense/homebrew-macos-cross-toolchains/releases/download/v15.2.0/aarch64-unknown-linux-gnu-x86_64-darwin.tar.gz"
expected="7fa485313b7049d57c5de56bf876d5c4648ebfd736f86a8f4739596218523127"
;;
*)
echo "::error::Unsupported macOS architecture: $(uname -m)"
exit 1
;;
esac
curl -fSL -o "$RUNNER_TEMP/aarch64-linux-gnu.tar.gz" "$url"
actual="$(shasum -a 256 < "$RUNNER_TEMP/aarch64-linux-gnu.tar.gz" | cut -d' ' -f1)"
if [ "$actual" != "$expected" ]; then
echo "::error::Expected SHA-256 $expected for $url, got $actual."
exit 1
fi
tar -xzf "$RUNNER_TEMP/aarch64-linux-gnu.tar.gz" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/aarch64-unknown-linux-gnu/bin" >> "$GITHUB_PATH"
- name: Install Linux cross toolchain (Windows)
if: runner.os == 'Windows'
shell: bash
Expand Down
30 changes: 24 additions & 6 deletions .github/workflows/boring_binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
push:
branches: [ main ]
paths:
- '.github/actions/setup-nasm/**'
- '.github/workflows/boring_binaries.yaml'
- 'pkgs/boring/src/**'
- 'pkgs/boring/third_party/boringssl/**'
Expand All @@ -28,6 +29,7 @@ on:
pull_request:
branches: [ main ]
paths:
- '.github/actions/setup-nasm/**'
- '.github/workflows/boring_binaries.yaml'
- 'pkgs/boring/src/**'
- 'pkgs/boring/tool/precompile_binaries.dart'
Expand All @@ -40,13 +42,13 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
# Runs compilers and other build tools, so it only gets `contents: read` and
# cannot mint OIDC tokens. The `attest` job attests the libraries.
precompile:
name: Precompile (${{ matrix.target-os }}-${{ matrix.target-arch }}${{ matrix.ios-sdk && format('-{0}', matrix.ios-sdk) || '' }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
id-token: write # To sign the provenance attestations of the libraries.
attestations: write # To store the attestations with the repository.
defaults:
run:
working-directory: pkgs/boring/
Expand Down Expand Up @@ -116,7 +118,7 @@ jobs:
sdk: stable
- name: Setup NASM
if: matrix.target-os == 'windows'
uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b
uses: ./.github/actions/setup-nasm
- name: Install dependencies
run: dart pub get
# Builds the dynamic library, which is bundled when linking is disabled,
Expand Down Expand Up @@ -202,16 +204,32 @@ jobs:
name: binaries-${{ matrix.target-os }}-${{ matrix.target-arch }}${{ matrix.ios-sdk && format('-{0}', matrix.ios-sdk) || '' }}
path: pkgs/boring/bin/*
if-no-files-found: error

# Attests the provenance of the libraries that `precompile` built. Only
# downloads and attests them, so no build tool runs with `id-token: write`.
attest:
name: Attest the provenance of the release libraries
needs: precompile
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
id-token: write # To sign the provenance attestations of the libraries.
attestations: write # To store the attestations with the repository.
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: binaries-*
path: release-assets
merge-multiple: true
# Verify with `gh attestation verify <file> --repo dart-lang/tools`.
- name: Attest the provenance of the release libraries
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8
with:
subject-path: pkgs/boring/bin/*
subject-path: release-assets/*

release:
name: Attach the binaries to a GitHub release
needs: precompile
needs: attest
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
Expand Down
Loading