topgrade 17.4.0

Upgrade all the things
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
name: Publish release files for CD native and non-cd-native environments

on:
  repository_dispatch:
    types: [release-created]

permissions:
  # Write permissions to call the repository dispatch
  contents: write

defaults:
  run:
    shell: bash

jobs:
  # Publish release files for CD native environments
  native_build:
    permissions:
      # Use to sign the release artifacts
      id-token: write
      # Used to upload release artifacts
      contents: write
      # Used to generate artifact attestations
      attestations: write
    strategy:
      fail-fast: false
      matrix:
        # Use the Ubuntu 22.04 image to link with a low version of glibc
        #
        # https://github.com/topgrade-rs/topgrade/issues/1095
        platform: [ubuntu-22.04, macos-latest, macos-15-intel, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      tag: ${{ github.event.client_payload.tag }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Install needed components
        run: |
          rustup component add rustfmt
          rustup component add clippy

      - name: Install cargo-deb
        run: cargo install cargo-deb
        if: ${{ startsWith(matrix.platform, 'ubuntu-') }}
        shell: bash

      - name: Check format
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --all-targets --locked -- -D warnings

      - name: Run clippy (All features)
        run: cargo clippy --all-targets --locked --all-features -- -D warnings

      - name: Run tests
        run: cargo test

      # Used `https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml`
      # as a reference.
      - name: Build debug binary to create release assets
        shell: bash
        run: |
          cargo build --all-features
          bin="target/debug/topgrade"
          echo "BIN=$bin" >> $GITHUB_ENV

      - name: Create deployment directory
        shell: bash
        run: |
          dir=deployment/deb
          mkdir -p "$dir"
          echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV

      - name: Generate man page and shell completions
        shell: bash
        run: |
          "$BIN" --gen-manpage > "$DEPLOY_DIR/topgrade.1"
          "$BIN" --gen-completion bash > "$DEPLOY_DIR/topgrade.bash"
          "$BIN" --gen-completion fish > "$DEPLOY_DIR/topgrade.fish"
          "$BIN" --gen-completion zsh > "$DEPLOY_DIR/_topgrade"

      - name: Build in Release profile with all features enabled
        run: cargo build --release --all-features

      - name: Install default-target
        run: cargo install default-target

      - name: Rename Release (Unix)
        run: |
          mkdir -p assets
          FILENAME=topgrade-${tag}-$(default-target)
          mv target/release/topgrade assets
          cd assets
          tar --format=ustar -czf "$FILENAME.tar.gz" topgrade
          rm topgrade
          ls .
        if: ${{ matrix.platform != 'windows-latest' }}
        shell: bash

      - name: Build Debian-based system binary and create package
        # First remove the binary built by previous steps
        # because we don't want the auto-update feature,
        # then build the new binary without auto-updating.
        run: |
          rm -rf target/release
          cargo build --release
          cargo deb --no-build --no-strip
        if: ${{ startsWith(matrix.platform, 'ubuntu-') }}
        shell: bash

      - name: Move Debian-based system package
        run: |
          mkdir -p assets
          mv target/debian/*.deb assets
        if: ${{ startsWith(matrix.platform, 'ubuntu-') }}
        shell: bash

      - name: Rename Release (Windows)
        run: |
          mkdir assets
          FILENAME=topgrade-${tag}-$(default-target)
          mv target/release/topgrade.exe assets/topgrade.exe
          cd assets
          powershell Compress-Archive -Path * -Destination ${FILENAME}.zip
          rm topgrade.exe
          ls .
        if: ${{ matrix.platform == 'windows-latest' }}
        shell: bash

      - name: Upload assets
        run: |
          gh release upload "${tag}" assets/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate artifact attestations
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
        with:
          subject-path: assets/*

  # Publish release files for non-CD-native environments
  cross_build:
    permissions:
      # Use to sign the release artifacts
      id-token: write
      # Used to upload release artifacts
      contents: write
      # Used to generate artifact attestations
      attestations: write
    strategy:
      fail-fast: false
      matrix:
        target:
          [
            "aarch64-unknown-linux-gnu",
            "armv7-unknown-linux-gnueabihf",
            "x86_64-unknown-linux-musl",
            "aarch64-unknown-linux-musl",
            "x86_64-unknown-freebsd",
          ]
    # Run this one on an older version as well, to limit glibc to 2.34 instead of 2.39.
    # Even though this is cross-compiled, it links to the libc6-<arch>-cross installed on the host
    # (see the apt-get install calls below)
    runs-on: ubuntu-22.04
    env:
      matrix_target: ${{ matrix.target }}
      tag: ${{ github.event.client_payload.tag }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Install needed components
        run: |
          rustup component add rustfmt
          rustup component add clippy

      - name: Install cargo-deb cross compilation dependencies
        run: sudo apt-get install libc6-arm64-cross libgcc-s1-arm64-cross
        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
        shell: bash

      - name: Install cargo-deb cross compilation dependencies for armv7
        run: sudo apt-get install libc6-armhf-cross libgcc-s1-armhf-cross
        if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
        shell: bash

      - name: Install cargo-deb
        run: cargo install cargo-deb
        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'armv7-unknown-linux-gnueabihf' }}
        shell: bash

      - name: install targets
        run: rustup target add "${matrix_target}"

      - name: install cross
        # Install from source to fix `ld: cannot find -lgeom` for freebsd build
        run: cargo +stable install --git https://github.com/cross-rs/cross cross

      - name: Run clippy
        run: cross clippy --all-targets --locked --target "${matrix_target}" -- -D warnings

      - name: Run clippy (All features)
        run: cross clippy --locked --all-features --target "${matrix_target}" -- -D warnings

      - name: Run tests
        run: cross test --target "${matrix_target}"
        # Running tests on FreeBSD is impossible; see https://github.com/cross-rs/cross/wiki/FAQ#running-bsd-tests
        # Not that this is *NOT* the same as the original issue with `ld: cannot find -lgeom`, but a new issue:
        # error: test failed, to rerun pass `--lib`
        # Caused by:
        #   could not execute process `/target/x86_64-unknown-freebsd/debug/deps/topgrade-9b1670d87ca863dd` (never executed)
        # Caused by:
        #   No such file or directory (os error 2)
        # TODO: I have not tested this in GHA yet, only locally
        if: ${{ matrix.target != 'x86_64-unknown-freebsd' }}

      # Used `https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml`
      # as a reference.
      - name: Build debug binary to create release assets
        shell: bash
        run: |
          # This build is not using the target arch since this binary is only needed in CI. It needs
          # to be the compiled for the runner since it has the run the binary to generate completion
          # scripts.
          cargo build --all-features
          bin="target/debug/topgrade"
          echo "BIN=$bin" >> $GITHUB_ENV

      - name: Create deployment directory
        shell: bash
        run: |
          dir=deployment/deb
          mkdir -p "$dir"
          echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV

      - name: Generate man page and shell completions
        shell: bash
        run: |
          "$BIN" --gen-manpage > "$DEPLOY_DIR/topgrade.1"
          "$BIN" --gen-completion bash > "$DEPLOY_DIR/topgrade.bash"
          "$BIN" --gen-completion fish > "$DEPLOY_DIR/topgrade.fish"
          "$BIN" --gen-completion zsh > "$DEPLOY_DIR/_topgrade"

      - name: Build in Release profile with all features enabled
        run: cross build --release --all-features --target "${matrix_target}"

      - name: Rename Release
        run: |
          mkdir -p assets
          FILENAME=topgrade-${tag}-${matrix_target}
          mv "target/${matrix_target}/release/topgrade" assets
          cd assets
          tar --format=ustar -czf "$FILENAME.tar.gz" topgrade
          rm topgrade
          ls .

      - name: Build Debian-based system package without autoupdate feature
        # First remove the binary built by previous steps
        # because we don't want the auto-update feature,
        # then build the new binary without auto-updating.
        run: |
          rm -rf "target/${matrix_target}"
          cross build --release --target "${matrix_target}"
          cargo deb --target="${matrix_target}" --no-build --no-strip
        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'armv7-unknown-linux-gnueabihf' }}
        shell: bash

      - name: Move Debian-based system package
        run: |
          mkdir -p assets
          mv target/"${matrix_target}"/debian/*.deb assets
        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'armv7-unknown-linux-gnueabihf' }}
        shell: bash

      - name: Upload assets
        run: gh release upload "${tag}" assets/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate artifact attestations
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
        with:
          subject-path: assets/*

  # Publish release files for OpenBSD
  openbsd_build:
    permissions:
      id-token: write
      contents: write
      attestations: write
    runs-on: ubuntu-latest
    env:
      tag: ${{ github.event.client_payload.tag }}

    defaults:
      run:
        shell: openbsd {0}

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Start OpenBSD VM
        uses: vmactions/openbsd-vm@d7d892b7b9ba97ed2747b0fc201be65037d64c3e # v1.4.0
        with:
          arch: x86_64
          sync: nfs
          usesh: true

      - name: Install dependencies
        run: >
          pkg_add -v
          rust
          git
          gmake
          bash

      - name: Install Rust components
        run: |
          pkg_add -v rust-rustfmt rust-clippy

      - name: Check format
        run: |
          cd $GITHUB_WORKSPACE
          cargo fmt --all -- --check

      - name: Run clippy
        run: |
          cd $GITHUB_WORKSPACE
          cargo clippy --all-targets --locked -- -D warnings

      - name: Run clippy (All features)
        run: |
          cd $GITHUB_WORKSPACE
          cargo clippy --all-targets --locked --all-features -- -D warnings

      - name: Run tests
        run: |
          cd $GITHUB_WORKSPACE
          cargo test

      - name: Build Release binary
        run: |
          cd $GITHUB_WORKSPACE
          cargo build --release --all-features

      - name: Package OpenBSD release
        run: |
          cd $GITHUB_WORKSPACE
          cargo install default-target
          mkdir -p assets
          # TODO: this should use the env var (${tag}), but can't because it's not set in the VM.
          FILENAME=topgrade-${{ github.event.client_payload.tag }}-$(/root/.cargo/bin/default-target)
          mv target/release/topgrade assets
          cd assets
          tar -F ustar -czf "$FILENAME.tar.gz" topgrade
          rm topgrade
          ls .

      - name: Upload assets
        shell: bash
        run: gh release upload "${tag}" assets/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate artifact attestations
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
        with:
          subject-path: assets/*

  publish:
    runs-on: ubuntu-latest
    needs: [native_build, cross_build, openbsd_build]
    env:
      tag: ${{ github.event.client_payload.tag }}
    permissions:
      contents: write # `gh release edit`
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
      - name: Publish release
        run: gh release edit "$tag" --draft=false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  triggers:
    runs-on: ubuntu-latest
    needs: [publish]
    env:
      tag: ${{ github.event.client_payload.tag }}
    steps:
      - name: Trigger workflows
        run: |
          gh api "repos/${GITHUB_REPOSITORY}/dispatches" \
            -f "event_type=release-assets-built" \
            -F "client_payload[tag]=${tag}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}