circt/.github/workflows/uploadBinaries.yml

137 lines
4.5 KiB
YAML

name: Upload Binaries
on:
release:
types: [created]
jobs:
publish:
strategy:
matrix:
compiler:
- cc: clang
cxx: clang++
mode: release
assert: OFF
shared: OFF
runner: [ubuntu-20.04, ubuntu-18.04, macos-11]
include:
- runner: ubuntu-20.04
os: linux
cmake-args: ''
tar: tar
- runner: ubuntu-18.04
os: linux
cmake-args: ''
tar: tar
- runner: macos-11
os: macos
cmake-args: ''
tar: gtar
runs-on: ${{ matrix.runner }}
steps:
# Clone the CIRCT repo and its submodules. Do shallow clone to save clone
# time.
- name: Get CIRCT
uses: actions/checkout@v2
with:
fetch-depth: 2
submodules: "true"
# --------
# Restore LLVM from cache and build if it's not in there.
# --------
# Extract the LLVM submodule hash for use in the cache key.
- name: Get LLVM Hash
id: get-llvm-hash
run: echo "::set-output name=hash::$(git rev-parse @:./llvm)"
- name: Get workflow spec hash
id: get-workflow-hash
run: echo "::set-output name=hash::$(shasum $GITHUB_WORKSPACE/.github/workflows/uploadBinaries.yml | awk '{print $1}')"
# Try to fetch LLVM from the cache.
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: |
llvm/build
key: ${{ matrix.runner }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}-${{ matrix.compiler.cc }}
- name: Setup Ninja Linux
if: matrix.os == 'linux'
run: sudo apt-get install ninja-build
- name: Setup Ninja and GNU Tar Mac
if: matrix.os == 'macos'
run: brew install ninja gnu-tar
# Build LLVM if we didn't hit in the cache. Even though we build it in
# the previous job, there is a low chance that it'll have been evicted by
# the time we get here.
- name: Rebuild LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
mkdir -p llvm/build
cd llvm/build
cmake -G Ninja ../llvm \
${{ matrix.cmake-args }} \
-DCMAKE_BUILD_TYPE=${{ matrix.compiler.mode }} \
-DCMAKE_C_COMPILER=${{ matrix.compiler.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \
-DBUILD_SHARED_LIBS=${{ matrix.compiler.shared }} \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_ENABLE_ASSERTIONS=${{ matrix.compiler.assert }} \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_PROJECTS='mlir' \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DLLVM_TARGETS_TO_BUILD="host"
ninja
# --------
# Build and test CIRCT
# --------
- name: Build and Test CIRCT
run: |
mkdir build
cd build
cmake -G Ninja .. \
${{ matrix.cmake-args }} \
-DBUILD_SHARED_LIBS=${{ matrix.compiler.shared }} \
-DCMAKE_BUILD_TYPE=${{ matrix.compiler.mode }} \
-DLLVM_ENABLE_ASSERTIONS=${{ matrix.compiler.assert }} \
-DMLIR_DIR=`pwd`/../llvm/build/lib/cmake/mlir \
-DLLVM_DIR=`pwd`/../llvm/build/lib/cmake/llvm \
-DCMAKE_C_COMPILER=${{ matrix.compiler.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \
-DVERILATOR_DISABLE=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=OFF
ninja
ninja check-circt
- name: Display Files
run: file build/bin/*
- name: Package Binaries
run: |
cd build
${{ matrix.tar }} czf circt-bin-${{ matrix.runner }}.tar.gz bin
- name: Show Tarball
run: |
cd build
ls -l circt-bin-${{ matrix.runner }}.tar.gz
shasum -a 256 circt-bin-${{ matrix.runner }}.tar.gz
- name: Upload Binaries
uses: AButler/upload-release-assets@v2.0
with:
files: build/circt-bin-${{ matrix.runner }}.tar.gz
repo-token: ${{ secrets.GITHUB_TOKEN }}