Skip to content

Commit c8ade92

Browse files
Create main.yml to support Github Actions CI
Signed-off-by: Clark Wang <[email protected]>
1 parent f9ab41a commit c8ade92

File tree

4 files changed

+137
-73
lines changed

4 files changed

+137
-73
lines changed

.github/workflows/main.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: BCU CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'bcu_*'
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
os: [windows-latest, ubuntu-latest, macos-latest]
13+
configuration: [Release]
14+
platform: ['x64']
15+
runs-on: ${{ matrix.os }}
16+
17+
steps:
18+
# Checkout code
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
# Initialize the sub-module
23+
- name: Initialize submodules
24+
run: git submodule update --init
25+
26+
# Install dependencies
27+
- name: Install dependencies
28+
if: matrix.os == 'ubuntu-latest'
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y libyaml-dev libftdi1-dev libusb-1.0-0-dev
32+
33+
- name: Install dependencies (macOS)
34+
if: matrix.os == 'macos-latest'
35+
run: |
36+
brew reinstall pkgconfig
37+
export PATH="/usr/local/Cellar/pkg-config/0.29.2_3/bin:${PATH}"
38+
brew reinstall libyaml
39+
brew install libftdi
40+
pkg-config --list-all
41+
42+
- name: Create env variables (Linux/macOS)
43+
if: matrix.os != 'windows-latest'
44+
run: |
45+
echo "CI_BUILD_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
46+
47+
- name: Create env variables (Windows)
48+
if: matrix.os == 'windows-latest'
49+
run: |
50+
echo "CI_BUILD_VERSION=${{ github.ref_name }}" >> $env:GITHUB_ENV
51+
52+
# Build Project
53+
- name: Build (Linux/macOS)
54+
if: matrix.os != 'windows-latest'
55+
run: |
56+
echo $CI_BUILD_VERSION
57+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
58+
cmake .
59+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
60+
export PATH="/usr/local/Cellar/pkg-config/0.29.2_3/bin:${PATH}"
61+
cmake .
62+
fi
63+
make
64+
65+
# Windows build
66+
- name: Windows setup selection
67+
uses: microsoft/[email protected]
68+
if: matrix.os == 'windows-latest'
69+
70+
- name: Build step2 (Windows)
71+
if: matrix.os == 'windows-latest'
72+
run: |
73+
echo $env.CI_BUILD_VERSION
74+
msbuild /p:Configuration=${{ matrix.configuration }} /p:PlatformToolset=v143 /p:Platform=${{ matrix.platform }} Board_Control_Utilities.sln
75+
76+
- name: Copy Board_Control_Utilities.exe to bcu.exe
77+
if: matrix.os == 'windows-latest'
78+
run: |
79+
if (Test-Path "${{ github.workspace }}\x64\Release\Board_Control_Utilities.exe") {
80+
Copy-Item "${{ github.workspace }}\x64\Release\Board_Control_Utilities.exe" "${{ github.workspace }}\bcu.exe"
81+
}
82+
83+
# Upload build artifacts
84+
- name: Upload artifact
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: bcu-artifacts-${{ github.run_id }}-${{ matrix.os }}
88+
path: |
89+
${{ github.workspace }}/bcu.exe
90+
${{ github.workspace }}/bcu
91+
${{ github.workspace }}/bcu_mac
92+
93+
deploy:
94+
needs: build
95+
runs-on: ubuntu-latest
96+
steps:
97+
# Check out the code
98+
- name: Checkout code
99+
uses: actions/checkout@v3
100+
101+
# Download build artifacts for all OS
102+
- name: Download artifacts (Ubuntu)
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: bcu-artifacts-${{ github.run_id }}-ubuntu-latest
106+
path: artifacts/ubuntu-latest
107+
108+
- name: Download artifacts (macOS)
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: bcu-artifacts-${{ github.run_id }}-macos-latest
112+
path: artifacts/macos-latest
113+
114+
- name: Download artifacts (Windows)
115+
uses: actions/download-artifact@v4
116+
with:
117+
name: bcu-artifacts-${{ github.run_id }}-windows-latest
118+
path: artifacts/windows-latest
119+
120+
# GitHub Releases
121+
- name: Create GitHub Release
122+
uses: softprops/action-gh-release@v2
123+
with:
124+
tag_name: ${{ github.ref_name }}
125+
release_name: Prebuild for ${{ github.ref_name }}
126+
body: |
127+
Prebuild for commit ${{ github.sha }}
128+
Commit message: ${{ github.event.head_commit.message }}
129+
draft: true
130+
files: |
131+
artifacts/ubuntu-latest/bcu
132+
artifacts/macos-latest/bcu_mac
133+
artifacts/windows-latest/bcu.exe
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

appveyor.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

create_version_h.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
echo //generated by file create_version_h.bat > version.h
22

3-
IF "%APPVEYOR_BUILD_VERSION%"=="" (
3+
IF "%CI_BUILD_VERSION%"=="" (
44
echo build not in appveyor
5-
) ELSE (
6-
git tag %APPVEYOR_BUILD_VERSION%
75
)
86

97

create_version_h.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
echo creating ${1}/version.h
22

3-
if [ "${APPVEYOR_BUILD_VERSION}" = "" ];
3+
if [ "${CI_BUILD_VERSION}" = "" ];
44
then
55
echo build not in appveyor
6-
else
7-
git tag ${APPVEYOR_BUILD_VERSION}
86
fi
97

108
version=`git describe --tags --long`

0 commit comments

Comments
 (0)