summaryrefslogtreecommitdiffstats
path: root/.github/workflows/nightly.yml
blob: aefab297935eede44ba181fa2608544222c83baf (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
# Creates nightly deployment builds for main targets.  Note this does not cover package distribution channels,
# such as choco, Homebrew, etc.

name: nightly

on:
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:
    inputs:
      isMock:
        description: "Replace to trigger a non-mock run."
        default: "mock"
        required: false

jobs:
  create-github-release:
    name: create-github-release
    runs-on: ubuntu-latest
    steps:
      - name: Create artifacts directory
        run: mkdir artifacts

      - name: Check if mock
        run: |
          echo "${{ github.event.inputs.isMock }}";
          if [[ -z "${{ github.event.inputs.isMock }}" ]]; then
            echo "This is a scheduled nightly run."
          elif [[ "${{ github.event.inputs.isMock }}" == "mock" ]]; then
            echo "This is a mock run."
          else
            echo "This is NOT a mock run.  Watch for the generated files!"
          fi

      - name: Delete tag and release
        uses: dev-drprasad/delete-tag-and-release@v0.1.3
        if: github.event.inputs.isMock != 'mock'
        with:
          delete_release: true
          tag_name: nightly
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release
        run: sleep 10

      - name: Create nightly GitHub release
        id: release
        uses: actions/create-release@v1
        if: github.event.inputs.isMock != 'mock'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          draft: false
          tag_name: nightly
          release_name: nightly
          prerelease: true

      - name: Save release upload URL to artifact
        run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url

      - name: Save version number to artifact
        run: echo "nightly" > artifacts/release-version

      - name: Upload artifacts
        uses: actions/upload-artifact@v1
        with:
          name: artifacts
          path: artifacts

  build-release:
    name: build-release
    needs: [create-github-release]
    runs-on: ${{ matrix.triple.os }}
    container: ${{ matrix.triple.container }}
    env:
      RUST_BACKTRACE: 1
    strategy:
      fail-fast: false
      matrix:
        triple:
          # Standard x86-64 stuff, stable
          - {
              os: "ubuntu-18.04",
              target: "x86_64-unknown-linux-gnu",
              cross: false,
              strip: true,
            }
          - {
              os: "ubuntu-18.04",
              target: "x86_64-unknown-linux-gnu",
              cross: false,
              container: quay.io/pypa/manylinux2014_x86_64,
              suffix: "2-17",
              strip: true,
            }
          - {
              os: "ubuntu-18.04",
              target: "i686-unknown-linux-gnu",
              cross: true,
              strip: true,
            }
          - {
              os: "ubuntu-18.04",
              target: "x86_64-unknown-linux-musl",
              cross: false,
              strip: true,
            }
          - {
              os: "ubuntu-18.04",
              target: "i686-unknown-linux-musl",
              cross: true,
              strip: true,
            }
          - {
              os: "macOS-latest",
              target: "x86_64-apple-darwin",
              cross: false,
              strip: true,
            }
          - {
              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,
            }

          # aarch64
          - {
              os: "ubuntu-18.04",
              target: "aarch64-unknown-linux-gnu",
              cross: true,
            }

          # armv7
          - {
              os: "ubuntu-18.04",
              target: "armv7-unknown-linux-gnueabihf",
              cross: true,
            }

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

          # Risc-V 64gc
          - {
              os: "ubuntu-18.04",
              target: "riscv64gc-unknown-linux-gnu",
              cross: true,
            }

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 1

      - uses: actions/setup-python@v2

      - name: Get release download URL
        uses: actions/download-artifact@v2
        with:
          name: artifacts
          path: artifacts

      - name: Set release upload URL and release version
        shell: bash
        run: |
          release_upload_url="$(cat ./artifacts/release-upload-url)"
          echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
          release_version="$(cat ./artifacts/release-version)"
          echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV

      - name: Validate release environment variables
        run: |
          echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
          echo "Release version: ${{ env.RELEASE_VERSION }}"

      - name: Install Net-Framework-Core (Windows x86-64 MSVC)
        if: matrix.triple.target == 'x86_64-pc-windows-msvc'
        shell: powershell
        run: Install-WindowsFeature Net-Framework-Core

      - name: Install wixtoolset (Windows x86-64 MSVC)
        if: matrix.triple.target == 'x86_64-pc-windows-msvc'
        uses: crazy-max/ghaction-chocolatey@v1.4.0
        with:
          args: install -y wixtoolset

      - name: Install toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          target: ${{ matrix.triple.target }}

      - uses: Swatinem/rust-cache@v1
        with:
          key: ${{ matrix.triple.target }}

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --verbose --target=${{ matrix.triple.target }} --features "battery"
          use-cross: ${{ matrix.triple.cross }}

      - name: Move autocomplete to working directory
        shell: bash
        run: |
          mkdir completion
          cp -r ./target/${{ matrix.triple.target }}/release/build/bottom-*/out/. completion

      - name: Strip release binary (macOS or Linux x86-64/i686)
        if: matrix.triple.strip == true
        run: |
          strip target/${{ matrix.triple.target }}/release/btm

      # TODO: Strip ARM

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

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

      # TODO: Move this elsewhere; do this all at once, and do not continue if any fails.  Store artifacts.  Do the same for deployment.

      - name: Upload main release
        if: github.event.inputs.isMock != 'mock'
        uses: actions/upload-release-asset@v1.0.1
        id: upload
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ env.RELEASE_UPLOAD_URL }}
          asset_path: ${{ env.ASSET }}
          asset_name: ${{ env.ASSET }}
          asset_content_type: application/octet-stream

      - name: Build msi file (Windows x86-64 MSVC)
        if: matrix.triple.target == 'x86_64-pc-windows-msvc'
        shell: powershell
        run: |
          cargo install cargo-wix --version 0.3.1 --locked
          cargo wix init
          cargo wix

      - name: Upload msi file (Windows x86-64 MSVC)
        if: matrix.triple.target == 'x86_64-pc-windows-msvc' && github.event.inputs.isMock != 'mock'
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ env.RELEASE_UPLOAD_URL }}
          asset_path: bottom_x86_64_installer.msi
          asset_name: bottom_x86_64_installer.msi
          asset_content_type: application/octet-stream

      - name: Build Debian release (Linux x86-64 GNU)
        if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
        run: |
          cargo install cargo-deb --version 1.29.0 --locked
          cargo deb
          cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb

      - name: Upload Debian file (Linux x86-64 GNU)
        if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' && github.event.inputs.isMock != 'mock'
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ env.RELEASE_UPLOAD_URL }}
          asset_path: bottom_${{ env.RELEASE_VERSION }}_amd64.deb
          asset_name: bottom_${{ env.RELEASE_VERSION }}_amd64.deb
          asset_content_type: application/octet-stream

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

      - name: Release completion files (Linux x86-64 GNU)
        if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' && github.event.inputs.isMock != 'mock'
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ env.RELEASE_UPLOAD_URL }}
          asset_path: completion.tar.gz
          asset_name: completion.tar.gz
          asset_content_type: application/octet-stream