Skip to content

use docker to build bin #30

use docker to build bin

use docker to build bin #30

Workflow file for this run

name: BCU CI
on:
push:
tags:
- 'bcu_*'
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
configuration: Release
platform: x64
- os: ubuntu-latest
configuration: Release
platform: x64
container: ubuntu:20.04
- os: macos-latest
configuration: Release
platform: x64
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v3
- name: Install basic tools (Ubuntu 20.04)
if: matrix.container == 'ubuntu:20.04'
env:
DEBIAN_FRONTEND: noninteractive
TZ: Etc/UTC
run: |
apt-get update
apt-get install -y git cmake make gcc g++ pkg-config
apt-get install -y libyaml-dev libftdi1-dev libusb-1.0-0-dev
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global --add safe.directory '*'
# Initialize the sub-module
- name: Initialize submodules
run: git submodule update --init
# Install dependencies
- name: Install dependencies
if: matrix.os == 'ubuntu-latest' && matrix.container != 'ubuntu:20.04'
run: |
sudo apt-get update
sudo apt-get install -y libyaml-dev libftdi1-dev libusb-1.0-0-dev
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew reinstall pkgconfig
export PATH="/usr/local/Cellar/pkg-config/0.29.2_3/bin:${PATH}"
brew reinstall libyaml
brew install libftdi
pkg-config --list-all
- name: Create env variables (Linux/macOS)
if: matrix.os != 'windows-latest'
run: |
echo "CI_BUILD_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Create env variables (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "CI_BUILD_VERSION=${{ github.ref_name }}" >> $env:GITHUB_ENV
# Build Project
- name: Build (Linux/macOS)
if: matrix.os != 'windows-latest'
run: |
echo $CI_BUILD_VERSION
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
cmake .
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
export PATH="/usr/local/Cellar/pkg-config/0.29.2_3/bin:${PATH}"
cmake .
fi
make
# Windows build
- name: Windows setup selection
uses: microsoft/setup-msbuild@v1.1
if: matrix.os == 'windows-latest'
- name: Build step2 (Windows)
if: matrix.os == 'windows-latest'
run: |
echo $env.CI_BUILD_VERSION
msbuild /p:Configuration=${{ matrix.configuration }} /p:PlatformToolset=v143 /p:Platform=${{ matrix.platform }} Board_Control_Utilities.sln
- name: Copy Board_Control_Utilities.exe to bcu.exe
if: matrix.os == 'windows-latest'
run: |
if (Test-Path "${{ github.workspace }}\x64\Release\Board_Control_Utilities.exe") {
Copy-Item "${{ github.workspace }}\x64\Release\Board_Control_Utilities.exe" "${{ github.workspace }}\bcu.exe"
}
# Upload build artifacts
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bcu-artifacts-${{ github.run_id }}-${{ matrix.os }}
path: |
${{ github.workspace }}/bcu.exe
${{ github.workspace }}/bcu
${{ github.workspace }}/bcu_mac
deploy:
needs: build
runs-on: ubuntu-latest
steps:
# Check out the code
- name: Checkout code
uses: actions/checkout@v3
# Download build artifacts for all OS
- name: Download artifacts (Ubuntu)
uses: actions/download-artifact@v4
with:
name: bcu-artifacts-${{ github.run_id }}-ubuntu-latest
path: artifacts/ubuntu-latest
- name: Download artifacts (macOS)
uses: actions/download-artifact@v4
with:
name: bcu-artifacts-${{ github.run_id }}-macos-latest
path: artifacts/macos-latest
- name: Download artifacts (Windows)
uses: actions/download-artifact@v4
with:
name: bcu-artifacts-${{ github.run_id }}-windows-latest
path: artifacts/windows-latest
# GitHub Releases
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
release_name: Prebuild for ${{ github.ref_name }}
body: |
Prebuild for commit ${{ github.sha }}
Commit message: ${{ github.event.head_commit.message }}
draft: true
files: |
artifacts/ubuntu-latest/bcu
artifacts/macos-latest/bcu_mac
artifacts/windows-latest/bcu.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}