Skip to content

Commit 7ad0a0a

Browse files
Create main.yml
1 parent baac49a commit 7ad0a0a

1 file changed

Lines changed: 141 additions & 0 deletions

File tree

.github/workflows/main.yml

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

0 commit comments

Comments
 (0)