sv2v/.github/workflows/build_binary.yml

110 lines
3.8 KiB
YAML

name: Build Release Binary
on:
push:
tags:
- v*
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: |
brew install haskell-stack shunit2 icarus-verilog || ls
sudo apt-get install -y haskell-stack shunit2 flex bison autoconf gperf || ls
- name: Cache iverilog
uses: actions/cache@v1
with:
path: ~/.local
key: ${{ runner.OS }}-iverilog-10-2
restore-keys: ${{ runner.OS }}-iverilog-10-2
- name: Install iverilog
run: |
if [ "${{ runner.OS }}" = "Linux" ]; then
if [ ! -e "$HOME/.local/bin/iverilog" ]; then
curl --retry-max-time 60 -L https://github.com/steveicarus/iverilog/archive/v10_2.tar.gz > iverilog.tar.gz
tar -xzf iverilog.tar.gz
cd iverilog-10_2
autoconf
./configure --prefix=$HOME/.local
make
make install
cd ..
fi
fi
- name: Cache Build
uses: actions/cache@v1
with:
path: ~/.stack
key: ${{ runner.OS }}-${{ hashFiles('**/stack.yaml') }}-${{ hashFiles('**/sv2v.cabal') }}
restore-keys: |
${{ runner.OS }}-${{ hashFiles('**/stack.yaml') }}-${{ hashFiles('**/sv2v.cabal') }}
${{ runner.OS }}-${{ hashFiles('**/stack.yaml') }}-
${{ runner.OS }}-
- name: Build
run: make
- name: Test
run: make test
- name: Packaging for artifact
run: cp LICENSE NOTICE README.md bin
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ runner.os }}
path: bin
release:
runs-on: ubuntu-latest
needs: build
steps:
- run: sudo apt-get install -y tree
- name: Download Linux artifact
uses: actions/download-artifact@v1
with:
name: Linux
path: sv2v-Linux
- name: Download MacOS artifact
uses: actions/download-artifact@v1
with:
name: macOS
path: sv2v-macOS
- name: Zip binary
run: |
zip sv2v-Linux ./sv2v-Linux/sv2v ./sv2v-Linux/LICENSE ./sv2v-Linux/NOTICE ./sv2v-Linux/README.md
zip sv2v-macOS ./sv2v-macOS/sv2v ./sv2v-macOS/LICENSE ./sv2v-macOS/NOTICE ./sv2v-macOS/README.md
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./sv2v-Linux.zip
asset_name: sv2v-Linux.zip
asset_content_type: application/zip
- name: Upload MacOS Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./sv2v-macOS.zip
asset_name: sv2v-macOS.zip
asset_content_type: application/zip