|
| 1 | +name: 'Setup wolfSSL' |
| 2 | +description: 'Build a wolfSSL profile, install it to /usr/local, and report its sha256' |
| 3 | + |
| 4 | +inputs: |
| 5 | + ref: |
| 6 | + description: 'wolfSSL git ref (branch, tag, or SHA)' |
| 7 | + required: true |
| 8 | + default: 'master' |
| 9 | + flags: |
| 10 | + description: 'configure flags for this profile' |
| 11 | + required: true |
| 12 | + cflags: |
| 13 | + description: 'extra CFLAGS for this profile' |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + |
| 17 | +outputs: |
| 18 | + sha256: |
| 19 | + description: 'sha256 of the installed libwolfssl.so - the identity gate compares against this' |
| 20 | + value: ${{ steps.identity.outputs.sha256 }} |
| 21 | + resolved-ref: |
| 22 | + description: 'the commit SHA the input ref resolved to' |
| 23 | + value: ${{ steps.resolve.outputs.sha }} |
| 24 | + |
| 25 | +runs: |
| 26 | + using: composite |
| 27 | + steps: |
| 28 | + # Resolve to a commit SHA so the cache key is stable across a run. Keying on |
| 29 | + # a moving branch name lets two jobs in one nightly build different wolfSSLs. |
| 30 | + - name: Resolve wolfSSL ref |
| 31 | + id: resolve |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + ref='${{ inputs.ref }}' |
| 35 | + if [[ "$ref" =~ ^[0-9a-f]{40}$ ]]; then |
| 36 | + sha="$ref" |
| 37 | + else |
| 38 | + # An annotated tag resolves to the tag object, not the commit, so ask |
| 39 | + # for the peeled ref first and fall back for branches. |
| 40 | + sha=$(git ls-remote https://github.com/wolfSSL/wolfssl.git \ |
| 41 | + "refs/tags/$ref^{}" | cut -f1) |
| 42 | + [ -n "$sha" ] || sha=$(git ls-remote \ |
| 43 | + https://github.com/wolfSSL/wolfssl.git "$ref" | head -n1 | cut -f1) |
| 44 | + fi |
| 45 | + [ -n "$sha" ] || { echo "could not resolve wolfSSL ref '$ref'"; exit 1; } |
| 46 | + echo "sha=$sha" >> "$GITHUB_OUTPUT" |
| 47 | + echo "resolved '$ref' -> $sha" |
| 48 | +
|
| 49 | + - name: Hash profile config |
| 50 | + id: cfg |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + printf '%s|%s' '${{ inputs.flags }}' '${{ inputs.cflags }}' \ |
| 54 | + | sha256sum | cut -c1-16 | sed 's/^/hash=/' >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + # Key on the image, not runner.os: a binary built against a newer glibc must |
| 57 | + # not be restored onto an older runner image. ImageOS is set by the hosted |
| 58 | + # runner; fall back so a self-hosted or container runner still gets a key. |
| 59 | + - name: Compute cache key |
| 60 | + id: key |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + img="${ImageOS:-$(. /etc/os-release 2>/dev/null && echo "$ID$VERSION_ID" || echo unknown)}" |
| 64 | + echo "key=wolfssl-${img}-${{ steps.resolve.outputs.sha }}-${{ steps.cfg.outputs.hash }}-v1" >> "$GITHUB_OUTPUT" |
| 65 | + echo "cache key: wolfssl-${img}-${{ steps.resolve.outputs.sha }}-${{ steps.cfg.outputs.hash }}-v1" |
| 66 | +
|
| 67 | + - name: Restore wolfSSL install |
| 68 | + id: cache |
| 69 | + uses: actions/cache@v5 |
| 70 | + with: |
| 71 | + path: ~/wolfssl-install |
| 72 | + key: ${{ steps.key.outputs.key }} |
| 73 | + |
| 74 | + - name: Build wolfSSL |
| 75 | + if: steps.cache.outputs.cache-hit != 'true' |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + set -euo pipefail |
| 79 | + rm -rf /tmp/wolfssl && mkdir -p /tmp/wolfssl |
| 80 | + cd /tmp/wolfssl |
| 81 | + git init -q |
| 82 | + git fetch -q --depth 1 https://github.com/wolfSSL/wolfssl.git ${{ steps.resolve.outputs.sha }} |
| 83 | + git checkout -q FETCH_HEAD |
| 84 | + ./autogen.sh |
| 85 | + # We need the library, not wolfSSL's own examples and test suite. Those |
| 86 | + # also fail to build under some profiles (the `tls` profile died on |
| 87 | + # tests/unit.test), and skipping them cuts every build substantially. |
| 88 | + ./configure --prefix="$HOME/wolfssl-install" \ |
| 89 | + --disable-examples --disable-crypttests \ |
| 90 | + ${{ inputs.flags }} \ |
| 91 | + ${{ inputs.cflags && format('CFLAGS="{0}"', inputs.cflags) || '' }} |
| 92 | + make -j"$(nproc)" |
| 93 | + make install |
| 94 | +
|
| 95 | + # Every README tells users to build against a wolfSSL at /usr/local, and 5 |
| 96 | + # host-tier Makefiles have no -I/-L at all. Installing there means CI runs the |
| 97 | + # exact command sequence the docs document, with no overrides. |
| 98 | + - name: Install to /usr/local |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + set -euo pipefail |
| 102 | + sudo cp -a "$HOME/wolfssl-install/." /usr/local/ |
| 103 | + sudo ldconfig |
| 104 | +
|
| 105 | + - name: Report cache outcome |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + if [ '${{ steps.cache.outputs.cache-hit }}' = 'true' ]; then |
| 109 | + echo "wolfSSL restored from cache (no rebuild)" |
| 110 | + else |
| 111 | + echo "wolfSSL cache MISS -- built from source and saved for later jobs" |
| 112 | + fi |
| 113 | +
|
| 114 | + - name: Record wolfSSL identity |
| 115 | + id: identity |
| 116 | + shell: bash |
| 117 | + run: | |
| 118 | + set -euo pipefail |
| 119 | + lib=$(ls /usr/local/lib/libwolfssl.so.*.*.* 2>/dev/null | head -n1 \ |
| 120 | + || readlink -f /usr/local/lib/libwolfssl.so) |
| 121 | + [ -f "$lib" ] || { echo "no libwolfssl.so installed under /usr/local/lib"; exit 1; } |
| 122 | + sha=$(sha256sum "$lib" | cut -d' ' -f1) |
| 123 | + echo "sha256=$sha" >> "$GITHUB_OUTPUT" |
| 124 | + echo "installed $lib" |
| 125 | + echo "sha256 $sha" |
| 126 | + /usr/local/bin/wolfssl-config --version 2>/dev/null || true |
0 commit comments