-
Notifications
You must be signed in to change notification settings - Fork 20
/
action.yml
58 lines (57 loc) · 2.11 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Hash Rust
description: Build and hash Rust binaries
inputs:
dir:
description: The root directory for the Rust sources to build
default: ${{ github.workspace }}
required: false
image:
description: The docker image to use for the build
default: oasisprotocol/runtime-builder:v0.0
required: false
binaries:
description: The list of all binaries that should be hashed
required: true
clean:
description: Control whether to run cleanup afterwards
default: yes
required: false
sgx:
description: Control whether to produce sgxs binaries
default: no
required: false
outputs:
hashes:
description: Comma-separated list of binary hashes
value: ${{ steps.build.outputs.hashes }}
build-path:
description: Path to the output directory, relative to inputs.dir
value: ${{ steps.build.outputs.build-path }}
runs:
using: "composite"
steps:
- shell: bash
id: build
run: |
docker run --rm -i -v ${{ inputs.dir }}:/src ${{ inputs.image }} /bin/bash <<-'EOF'
set -e
cd /src
CARGO_TARGET_ROOT="/src/target"
TARGET=""
if [ "${{ inputs.sgx }}" == "yes" ]; then
TARGET="x86_64-fortanix-unknown-sgx"
export CARGO_TARGET_DIR="$CARGO_TARGET_ROOT/sgx"
export CFLAGS_x86_64_fortanix_unknown_sgx="-isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening"
export CC_x86_64_fortanix_unknown_sgx=clang-11
cargo build --release --target $TARGET
cargo elf2sgxs --release
else
export CARGO_TARGET_DIR="$CARGO_TARGET_ROOT/default"
cargo build --release
fi
echo "::set-output name=hashes::$(cd "$CARGO_TARGET_DIR/$TARGET/release"; shasum -a 512256 -b $(tr ',' ' ' <<< "${{ inputs.binaries }}") | cut -d' ' -f1 | tr '\n' ',' | sed -e 's/,$//g')"
echo "::set-output name=build-path::$(sed -e 's/^\/src//g' <<< "$CARGO_TARGET_DIR")/$TARGET/release"
if [ "${{ inputs.clean }}" == "yes" ]; then
cargo clean
fi
EOF