summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build-workflow.yml
blob: 17c9e6737859d2b9bc3dfa8ea43a62e36d6c9b7a (plain)
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: build-workflow

on:
  workflow_run:
    workflows: ["commit-workflow"]
    branches: [main]
    types:
      - completed
  workflow_dispatch:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  build_amd64:
    name: Build tedge and mapper Debian packages for amd64
    runs-on: Ubuntu-20.04
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: enable toolchain via github action
        # https://github.com/actions-rs/toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.58.1
          override: true

      - name: Enable cache
        # https://github.com/marketplace/actions/rust-cache
        uses: Swatinem/rust-cache@v1

      - name: Install cargo-deb
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: install
          args: cargo-deb --version 1.34.2

      - name: Build tedge debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge

      - name: Build tedge_mapper debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_mapper

      - name: Build tedge_apt_plugin debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_apt_plugin

      - name: Build tedge_apama_plugin debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_apama_plugin

      - name: Build tedge_agent debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_agent

      - name: Build tedge_watchdog debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_watchdog

      - name: Build c8y_log_plugin debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p c8y_log_plugin 

      - name: Build c8y_configuration_plugin debian package
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p c8y_configuration_plugin

      - name: build sawtooth-publisher for amd64
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: build
          args: --release -p sawtooth_publisher

      - name: Upload artifacts as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v2
        with:
          name: debian-packages-amd64
          path: target/debian/*.deb

      - name: upload amd64 sawtooth-publisher as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v2
        with:
          name: sawtooth_publisher_amd64
          path: target/release/sawtooth_publisher

      - name: Build tedge_dummy_plugin
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: build
          args: --release -p tedge_dummy_plugin

      - name: upload dummy-plugin
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v2
        with:
          name: tedge_dummy_plugin_amd64
          path: target/release/tedge_dummy_plugin

  build_matrix_arm:
    name: Build tedge and mapper Debian for armv7
    runs-on: Ubuntu-20.04
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    strategy:
      matrix:
        # Currently only arm targets, as we use a custom strip binary !
        target:
          [
            aarch64-unknown-linux-gnu,
            aarch64-unknown-linux-musl,
            arm-unknown-linux-gnueabihf,
            armv7-unknown-linux-gnueabihf,
            armv7-unknown-linux-musleabihf,
          ]

    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: enable toolchain via github action
        # https://github.com/actions-rs/toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.58.1
          target: ${{ matrix.target }}
          override: true

      - name: Enable cache
        # https://github.com/marketplace/actions/rust-cache
        uses: Swatinem/rust-cache@v1

      - name: install cargo-deb
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: install
          args: cargo-deb --version 1.34.2

      - name: install cargo-strip
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: install
          args: cargo-strip

      - name: build cross release for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          use-cross: true
          command: build
          args: --release --target=${{ matrix.target }}

      - name: apt update
        run: sudo apt update

      # armv7 uses `arm-linux-gnueabihf-strip`; aarch64 uses `aarch64-linux-gnu-strip`
      # It appears `aarch64-linux-gnu-strip` seems to work explicitly on other arm bins but not other way around.
      - name: Install binutils to add `strip` for striping arm binaries
        run: sudo apt-get --assume-yes install binutils-arm-linux-gnueabihf binutils-aarch64-linux-gnu

      - name: Strip tedge
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge

      - name: Strip tedge_mapper
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge_mapper || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge_mapper

      - name: Strip tedge_agent
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge_agent || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge_agent

      - name: Strip tedge_watchdog
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge_watchdog || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge_watchdog

      - name: Strip tedge_apt_plugin
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge_apt_plugin || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge_apt_plugin

      - name: Strip tedge_apama_plugin
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/tedge_apama_plugin || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/tedge_apama_plugin

      - name: Strip c8y_log_plugin 
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/c8y_log_plugin || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/c8y_log_plugin

      - name: Strip c8y_configuration_plugin
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/c8y_configuration_plugin || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/c8y_configuration_plugin

      - name: build tedge debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge --no-strip --no-build --target=${{ matrix.target }}

      - name: build tedge_mapper debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_mapper --no-strip --no-build --target=${{ matrix.target }}

      - name: build tedge_agent debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_agent --no-strip --no-build --target=${{ matrix.target }}

      - name: build tedge_watchdog debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_watchdog --no-strip --no-build --target=${{ matrix.target }}

      - name: build tedge_apt_plugin debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_apt_plugin --no-strip --no-build --target=${{ matrix.target }}

      - name: build tedge_apama_plugin debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p tedge_apama_plugin --no-strip --no-build --target=${{ matrix.target }}

      - name: build c8y_log_plugin debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p c8y_log_plugin --no-strip --no-build --target=${{ matrix.target }}

      - name: build c8y_configuration_plugin debian package for target
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: deb
          args: -p c8y_configuration_plugin --no-strip --no-build --target=${{ matrix.target }}

      - name: build sawtooth publisher
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          use-cross: true
          command: build
          args: --release -p sawtooth_publisher --target=${{ matrix.target }}

      - name: Strip workaround sawtooth_publisher
        run: arm-linux-gnueabihf-strip target/${{ matrix.target }}/release/sawtooth_publisher || aarch64-linux-gnu-strip target/${{ matrix.target }}/release/sawtooth_publisher

      - name: upload debian packages as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v2
        with:
          name: debian-packages-${{ matrix.target }}
          path: target/${{ matrix.target }}/debian/*.deb

      - name: upload