summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build_releases.yml
blob: e1acbd742dba414cee93d0c41136e839b8644834 (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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# Builds the following releases:
# - Binary releases
# - .deb releases
# - .rpm releases
# - MSI installer for Windows (.msi)
# - Cirrus CI binaries
#   - FreeBSD (x86_64)
#   - macOS (aarch64)

name: "build releases"

on:
  workflow_dispatch:
  workflow_call:
    inputs:
      caller:
        description: "The calling workflow."
        default: ""
        required: false
        type: string

env:
  RUST_BACKTRACE: 1
  CARGO_INCREMENTAL: 0
  CARGO_PROFILE_DEV_DEBUG: 0
  CARGO_HUSKY_DONT_INSTALL_HOOKS: true
  COMPLETION_DIR: "target/tmp/bottom/completion/"
  MANPAGE_DIR: "target/tmp/bottom/manpage/"

# TODO: Maybe add retry job in case of timeouts?
jobs:
  build-binaries:
    name: "Build binaries"
    runs-on: ${{ matrix.info.os }}
    container: ${{ matrix.info.container }}
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        info:
          # ======= Supported targets =======
          # Linux (x64, x86, aarch64)
          - {
              os: "ubuntu-20.04",
              target: "x86_64-unknown-linux-gnu",
              cross: false,
            }
          - {
              os: "ubuntu-20.04",
              target: "x86_64-unknown-linux-gnu",
              cross: false,
              container: quay.io/pypa/manylinux2014_x86_64,
              suffix: "2-17",
            }
          - {
              os: "ubuntu-20.04",
              target: "i686-unknown-linux-gnu",
              cross: true,
            }
          - {
              os: "ubuntu-20.04",
              target: "x86_64-unknown-linux-musl",
              cross: false,
              rust: "1.71.0",
            }
          - {
              os: "ubuntu-20.04",
              target: "i686-unknown-linux-musl",
              cross: true,
            }
          - {
              os: "ubuntu-20.04",
              target: "aarch64-unknown-linux-gnu",
              cross: true,
            }
          - {
              os: "ubuntu-20.04",
              target: "aarch64-unknown-linux-musl",
              cross: true,
            }

          # macOS (x64), M1 is built via CirrusCI.
          - { os: "macos-12", target: "x86_64-apple-darwin", cross: false }

          # Windows (x64, x86)
          - {
              os: "windows-2019",
              target: "x86_64-pc-windows-msvc",
              cross: false,
            }
          - { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false }
          - {
              os: "windows-2019",
              target: "x86_64-pc-windows-gnu",
              cross: false,
            }

          # ======= Unsupported targets =======
          # armv7
          - {
              os: "ubuntu-20.04",
              target: "armv7-unknown-linux-gnueabihf",
              cross: true,
            }
          - {
              os: "ubuntu-20.04",
              target: "armv7-unknown-linux-musleabihf",
              cross: true,
            }

          # PowerPC 64 LE
          - {
              os: "ubuntu-20.04",
              target: "powerpc64le-unknown-linux-gnu",
              cross: true,
            }

          # Risc-V 64gc
          - {
              os: "ubuntu-20.04",
              target: "riscv64gc-unknown-linux-gnu",
              cross: true,
            }
    steps:
      - name: Checkout repository
        uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
        with:
          fetch-depth: 1

      - name: Set up Rust toolchain
        if: matrix.info.container == ''
        uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d
        with:
          toolchain: ${{ matrix.info.rust || 'stable' }}
          target: ${{ matrix.info.target }}

      - name: Set up Rust toolchain (non-GitHub container)
        if: matrix.info.container != ''
        shell: bash
        run: |
          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs --output rustup.sh
          sh rustup.sh --default-toolchain stable -y
          echo "$HOME/.cargo/bin" >> $GITHUB_PATH

      - name: Build
        uses: ClementTsang/cargo-action@v0.0.4
        env:
          BTM_GENERATE: true
          BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
        with:
          command: build
          args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy
          use-cross: ${{ matrix.info.cross }}
          cross-version: 0.2.5

      - name: Move automatically generated completion/manpage
        shell: bash
        run: |
          mv "$COMPLETION_DIR" completion
          mv "$MANPAGE_DIR" manpage

      - name: Bundle release and completion (Windows)
        if: matrix.info.os == 'windows-2019'
        shell: bash
        run: |
          cp target/${{ matrix.info.target }}/release/btm.exe btm.exe
          7z a bottom_${{ matrix.info.target }}.zip "btm.exe"
          7z a bottom_${{ matrix.info.target }}.zip "completion"
          echo "ASSET=bottom_${{ matrix.info.target }}.zip" >> $GITHUB_ENV

      - name: Bundle release and completion (Linux and macOS)
        if: matrix.info.os != 'windows-2019'
        shell: bash
        run: |
          cp target/${{ matrix.info.target }}/release/btm ./btm
          tar -czvf bottom_${{ matrix.info.target }}${{ matrix.info.suffix }}.tar.gz btm completion
          echo "ASSET=bottom_${{ matrix.info.target }}${{ matrix.info.suffix }}.tar.gz" >> $GITHUB_ENV

      - name: Create release directory for artifact, move file
        shell: bash
        run: |
          mkdir release
          mv ${{ env.ASSET }} release/

      - name: Compress completion files (Linux x86-64 GNU)
        if: matrix.info.target == 'x86_64-unknown-linux-gnu' && matrix.info.container == ''
        shell: bash
        run: |
          tar -C ./completion -czvf completion.tar.gz .
          mv completion.tar.gz release/

      - name: Compress manpage files (Linux x86-64 GNU)
        if: matrix.info.target == 'x86_64-unknown-linux-gnu' && matrix.info.container == ''
        shell: bash
        run: |
          gzip ./manpage/btm.1
          tar -C ./manpage -czvf manpage.tar.gz .
          mv manpage.tar.gz release/

      - name: Save release as artifact
        uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
        with:
          retention-days: 3
          name: release
          path: release

  build-msi:
    name: "Build MSI installer"
    runs-on: "windows-2019"
    steps:
      - name: Checkout repository
        uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
        with:
          fetch-depth: 1

      - name: Install Net-Framework-Core
        shell: powershell
        run: Install-WindowsFeature Net-Framework-Core

      - name: Install wixtoolset
        uses: crazy-max/ghaction-chocolatey@5a5864861ce2c988001531e48993aa687c51f6c8 # 2.2.0
        with:
          args: install -y wixtoolset

      - name: Set up Rust toolchain
        uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d
        with:
          toolchain: stable
          target: x86_64-pc-windows-msvc

      - name: Build MSI file
        shell: powershell
        env:
          BTM_GENERATE: ""
        run: |
          cargo install cargo-wix --version 0.3.1 --locked
          cargo wix init
          cargo wix

      - name: Create release directory for artifact, move files
        shell: bash
        run: |
          mkdir release
          mv bottom_x86_64_installer.msi release/

      - name: Save release as artifact
        uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
        with:
          retention-days: 3
          name: release
          path: release

  build-cirrus:
    name: "Build using Cirrus CI"
    runs-on: "ubuntu-latest"
    steps:
      - name: Checkout repository
        uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
        with:
          fetch-depth: 0

      - name: Create release directory
        run: |
          mkdir -p release

      - name: Execute Cirrus CI build script
        env:
          CIRRUS_KEY: ${{ secrets.CIRRUS_TOKEN }}
        run: |
          if [[ "${{ github.ref_type }}" == "branch" ]]; then
            BRANCH="${{ github.ref_name }}";
          else
            raw=$(git branch -r --contains '${{ github.ref_name }}');
            BRANCH=${raw##*/};
          fi
          python ./scripts/cirrus/build.py "$BRANCH" "release/" "${{ inputs.caller }}"

      - name: Save release as artifact
        uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
        with:
          retention-days: 3
          name: release
          path: release

  build-deb:
    name: "Build .deb software packages"
    runs-on: "ubuntu-20.04"
    strategy:
      fail-fast: false
      matrix:
        info: