-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (102 loc) · 3.39 KB
/
build-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: build-ci
# Controls when the action will run. Triggers the workflow on push events but to the release branch
on:
push:
branches:
- "**"
pull_request:
branches:
- main
- release
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Build application
build:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set up directories
run: mkdir build
- name: Set up cross compiler
run: ../utils/toolchain.sh rpi3-armv8 --pull --export
working-directory: build
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.22.x'
- name: CMake configure
run: cmake --version && cmake -DCMAKE_TOOLCHAIN_FILE=../utils/armv8-rpi3-linux-gnueabihf.cmake -DCMAKE_BUILD_TYPE=Release ..
working-directory: build
- name: Build
run: make -j`nproc`
working-directory: build
- name: Gather build artifacts
run: mkdir output && cp -r build/bin build/lib scripts output/.
- name: Compress artifacts
run: tar czf ../Swerve-Platform.tar.gz .
working-directory: output
- uses: actions/upload-artifact@v3
with:
name: raw-build-output
path: Swerve-Platform.tar.gz
# Add raw build artifacts to release
release-raw:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: raw-build-output
- uses: softprops/action-gh-release@v1
with:
files: '**/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Build image that includes application
# @todo This isn't working... Only run on ciTest branch for now
build-image:
needs: [build]
if: github.ref == 'refs/heads/ciTest'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: APT update
run: sudo apt update
# Get artifacts from CI build
- uses: actions/download-artifact@v2
with:
name: raw-build-output
- name: Extract artifacts
run: mkdir buildOutput && tar xf Swerve-Platform.tar.gz -C buildOutput
- name: Move artifacts
run: mkdir build && mv buildOutput/bin build/ && mv buildOutput/lib build/
# Build image with docker
- name: Run build-docker.sh
run: sudo modprobe binfmt_misc && sudo ./build-docker.sh
working-directory: image
- name: Upload built image
uses: actions/upload-artifact@v3
with:
name: built-image
path: image/deploy/image_*Swerve-Platform.zip
if-no-files-found: error
# Add image to release
release-image:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-image]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: built-image
- uses: softprops/action-gh-release@v1
with:
files: '**/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}