-
Notifications
You must be signed in to change notification settings - Fork 92
229 lines (196 loc) · 6.94 KB
/
build.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Build, Test, and Draft Releae for static and dynamic versions of the
# MTConnect Agent on Windows, Mac OS, and Linux.
#
# The Windows x86 and x86_64 builds create ZIP packages and attach them to
# a draft release when the commit is tagged.
#
# Secret required for Release:
# RELEASE_GITHUB_TOKEN - Release token created by admin in Settings / Developer Settings / Personal access tokens /
# Find-grained tokens
# The token must be renewed every 90 days.
name: Build MTConnect C++ Agent
on:
# Enable automated build once verified
pull_request:
paths-ignore: ["**/*.md", "LICENSE.txt", ".gitignore"]
branches: [ "main", "main-dev" ]
push:
paths-ignore: ["**/*.md", "LICENSE.txt", ".gitignore"]
branches: [ "main", "main-dev" ]
tags:
- "v*.*.*"
# Allow manually run workflows
workflow_dispatch:
jobs:
build_windows:
runs-on: windows-2019
name: "Windows 2019 Arch: ${{ matrix.arch }}, Shared: ${{ matrix.shared }}"
strategy:
matrix:
arch: ["x86", "amd64"]
shared: ["True", "False"]
include:
- arch: "x86"
profile: "vs32"
- arch: "amd64"
profile: "vs64"
- shared: "True"
profile: "vs64shared"
exclude:
- arch: "x86"
shared: "True"
steps:
- name: Setup conan and zip directories
run: |
ruby -e @"
base = ENV['GITHUB_WORKSPACE'].gsub('\\', '/').
gsub(/\/[a-zA-Z]+$/, '')
puts %{ZIP_DIR=#{base}}
puts %{CONAN_HOME=#{base}/conan2}
"@ >> $env:GITHUB_ENV
echo "CTEST_OUTPUT_ON_FAILURE=TRUE" >> $env:GITHUB_ENV
- name: Print Directories
run: |
echo $CONAN_HOME
echo $ZIP_DIR
echo $CTEST_OUTPUT_ON_FAILURE
- name: Checkout Agent
uses: actions/checkout@v3
- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ${{ env.CONAN_HOME }}
key: ${{ runner.os }}-build-${{ matrix.profile }}-${{ hashFiles('**/conanfile.py') }}
- name: Install Conan
uses: turtlebrowser/[email protected]
- name: Initialize VS Dev Env
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: ${{ matrix.arch }}
host_arch: ${{ matrix.arch }}
- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
run: |
set CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/${{ matrix.profile }} -o "&:with_docs=False" -o "&:cpack=True" -o "&:cpack_destination=${{ env.ZIP_DIR }}" -o "&:shared=${{ matrix.shared }}"
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.shared == 'False' }}
with:
name: Version ${{ github.ref_name }}
draft: true
files: |
${{ env.ZIP_DIR }}/agent*.zip
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
build_linux:
runs-on: ubuntu-latest
name: "Ubuntu Latest, Shared: ${{ matrix.shared }}"
strategy:
matrix:
shared: ["True", "False"]
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt install -y build-essential cmake gcc-11 g++-11 python3 autoconf automake
- name: Checkout Agent
uses: actions/checkout@v3
- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ matrix.shared }}-${{ hashFiles('**/conanfile.py') }}
- name: Install Conan
uses: turtlebrowser/[email protected]
- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
shell: bash
run: |
export CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/gcc -o '&:shared=${{ matrix.shared }}' -o '&:with_docs=False' -o '&:cpack=True' -o '&:cpack_name=dist' -o '&:cpack_destination=${{ github.workspace }}'
- name: Cleanse package version
run: |
if [[ $PACKAGE_VERSION == v*.*.*.* ]]; then
echo "PACKAGE_VERSION=${PACKAGE_VERSION:1}" >> $GITHUB_ENV
elif [[ $PACKAGE_VERSION == [0-9].*.*.* ]]; then
echo "PACKAGE_VERSION=${PACKAGE_VERSION:0}" >> $GITHUB_ENV
else
echo "PACKAGE_VERSION=0.0.0.0" >> $GITHUB_ENV
fi
- name: Prepare Debian Package
shell: bash
working-directory: ${{ github.workspace }}
run: |
mkdir -p pkgroot/home/edge/
ls -lah pkgroot
tar -xzf dist.tar.gz -C pkgroot/
mv pkgroot/dist pkgroot/usr
- name: Create Debian Package
id: create_debian_package
uses: jiro4989/build-deb-action@v3
with:
package: mtconnect-agent
package_root: ${{ github.workspace}}/pkgroot
version: ${{ env.PACKAGE_VERSION }}
arch: amd64
desc: "MTConnect Agent for Ununtu"
maintainer: Datanomix <[email protected]>
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.shared == 'False' }}
with:
name: Version ${{ github.ref_name }}
draft: true
files: |
${{ github.workspace }}/${{ steps.create_debian_package.outputs.file_name }}
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
build_macos:
runs-on: macos-latest
name: "MacOS Latest, Shared: ${{ matrix.shared }}"
strategy:
matrix:
shared: ["True", "False"]
steps:
- name: Checkout Agent
uses: actions/checkout@v3
- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ matrix.shared }}-${{ hashFiles('**/conanfile.py') }}
- name: Install Conan
run: |
brew install conan
- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
shell: bash
run: |
export CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/macos -o '&:shared=${{ matrix.shared }}' -o '&:with_docs=False'