pipeprogress 2023.3.0

Progress bar for long pipe operations
Documentation
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
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
##################################################
# Name: release.yaml
# Description: Workflow to create and publish to a GitHub release
##################################################

name: Release

on:

  # Treating approved PRs into trunk as "pre-releases"
  pull_request_review:
    branches:
      - "trunk"
    types:
      - submitted
    paths-ignore:
      - "docs/**"
      - "*.md"
      - Cargo.lock
      - Cargo.toml

  # Treating merged PRs into trunk as "releases"
  push:
    branches:
      - "trunk"
    paths-ignore:
      - "docs/**"
      - "*.md"

permissions:
  packages: write
  contents: write

env:
  CARGO_TERM_COLOR: always

  REGISTRY: ghcr.io

  REGISTRY_USERNAME: ${{ github.actor }}
  REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

  ORGANISATION: ${{ github.repository_owner }}
  PROJECT: ${{ github.event.repository.name }}

  # Works on pushes or PRs
  BRANCH_NAME_CURRENT: ${{ github.head_ref || github.ref_name }}
  BRANCH_NAME_DEFAULT: ${{ github.event.repository.default_branch }}

defaults:
  run:
    shell: bash

jobs:

  #########################
  # Create a GitHub Release
  #########################

  create_release:

    name: Create a GitHub Release

    runs-on: ${{ matrix.os }}

    timeout-minutes: 30

    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest

    steps:

      - id: checkout_repository
        name: Checkout repository with all history and tags
        uses: actions/checkout@main
        env:
          GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_REPOS }}
        with:
          fetch-depth: 0
          submodules: false
          clean: true
          persist-credentials: true

      # NOTE: Cargo version needs to be SemVer compatible
      # ${MAJOR}.${MINOR}.${PATCH}-${PRE-RELEASE}+${BUILD}
      - id: prep_release
        name: Prepare for Release
        uses: salt-labs/action-its-shipping-time@trunk
        with:
          loglevel: "INFO"
          tag_enable: "TRUE"
          tag_force: "FALSE"
          changelog_enable: "TRUE"
          git_pretty_format: "* %h %G? %aN - %s"
          calver_enable: "TRUE"
          calver_scheme: "YYYY.MM.GEN"
          calver_split: "."
          calver_split_mod: "."
          timezone: "Australia/Sydney"

      - id: create_release_prerelease
        name: Create Pre-Release
        if: github.event.review.state == 'approved'
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.prep_release.outputs.calver }}
          release_name: ${{ steps.prep_release.outputs.calver }}
          body: |
            # ${{ steps.prep_release.outputs.repo_name }} changelog

            ${{ steps.prep_release.outputs.changelog }}

            # Containers

            ```bash
            docker pull ghcr.io/salt-labs/pipeprogress:${{ steps.prep_release.outputs.calver }}
            ```

          draft: false
          prerelease: true

      - id: create_release
        if: github.event_name == 'push' && contains( github.ref, 'trunk' )
        name: Create Release Draft
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.prep_release.outputs.calver }}
          release_name: ${{ steps.prep_release.outputs.calver }}
          body: |
            # ${{ steps.prep_release.outputs.repo_name }} changelog

            ${{ steps.prep_release.outputs.changelog }}

            # Containers

            ```bash
            docker pull ghcr.io/salt-labs/pipeprogress:${{ steps.prep_release.outputs.calver }}
            ```

          draft: true
          prerelease: false

    outputs:

      # Prep-Release
      calver: ${{ steps.prep_release.outputs.calver }}
      changelog: ${{ steps.prep_release.outputs.changelog }}
      repo_owner: ${{ steps.prep_release.outputs.repo_owner }}
      repo_name: ${{ steps.prep_release.outputs.repo_name }}

      # Pre-Release
      upload_url_prerelease: ${{ steps.create_release_prerelease.outputs.upload_url }}

      # Release
      upload_url: ${{ steps.create_release.outputs.upload_url }}

  #########################
  # Build the Rust app
  #########################

  build_rust:

    name: Build Rust app

    needs:
      - create_release

    runs-on: ${{ matrix.os }}

    timeout-minutes: 60

    strategy:
      fail-fast: true
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-apple-darwin
            os: macos-latest
            toolchain: stable
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            toolchain: stable
          #- target: aarch64-unknown-linux-gnu
          #  os: ubuntu-latest
          #  toolchain: stable
        #exclude:

    steps:

      - id: setup_rust
        name: Setup the Rust environment
        uses: actions-rs/toolchain@v1
        with:
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.toolchain }}
          default: true

      - id: setup_rust_arm64
        name: Setup the Rust environment for ARM64
        if: matrix.target == 'aarch64-unknown-linux-gnu' && matrix.os == 'ubuntu-latest'
        run: |
          sudo apt install gcc-multilib

      - id: checkout_repository
        name: Checkout repository
        uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          persist-credentials: true

      - id: cache_artifacts_cargo_registry
        name: Cache Cargo registry
        uses: actions/cache@v2
        with:
          path: ~/.cargo/registry
          key: ${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-registry-

      - id: cache_artifacts_cargo_index
        name: Cache Cargo index
        uses: actions/cache@v2
        with:
          path: ~/.cargo/git
          key: ${{ matrix.target }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-index-

      - id: cache_artifacts_cargo_target
        name: Cache Cargo build
        uses: actions/cache@v2
        with:
          path: target/release
          key: ${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-target-

      - id: cargo_check
        name: Run Cargo check
        run: |
          cargo --version
          cargo check --verbose

      - id: cargo_fmt
        name: Run Cargo format
        run: |
          rustup component add rustfmt
          rustup component list --toolchain ${{ matrix.toolchain }}
          cargo fmt --version
          cargo fmt --all -- --check

      - id: cargo_clippy
        name: Run Cargo clippy
        run: |
          rustup component add clippy
          rustup component list --toolchain ${{ matrix.toolchain }}
          cargo clippy --version
          cargo clippy --all --all-features -- -D warnings

      - id: cargo_test
        name: Run Cargo tests
        run: |
          cargo --version
          cargo test --verbose

      - id: cargo_build
        name: Run Cargo build
        run: |
          rustup target add ${{ matrix.target }}
          rustup target list --toolchain ${{ matrix.toolchain }}
          cargo --version
          cargo build --verbose --release --target=${{ matrix.target }}

      - id: archive_rust
        name: Archive Rust artifacts (cross-platform)
        shell: pwsh
        working-directory: "${{ github.workspace }}"
        run: >
          ./.github/scripts/archive.ps1
          -Target ${{ matrix.target }}
          -LogLevel debug
          -DieHard

      - id: upload_artifacts
        name: Upload artifacts
        uses: actions/upload-artifact@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          name: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip
          path: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip

  #########################
  # Publish Docker Container
  #########################

  release_publish_oci:

    name: Publish Release to registry

    needs:
      - create_release
      - build_rust

    runs-on: ${{ matrix.os }}

    timeout-minutes: 30

    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest

    steps:

      - id: checkout_repository
        name: Checkout repository with all history and tags
        uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          fetch-depth: 0
          submodules: false
          clean: true
          persist-credentials: true

      - id: setup_qemu
        name: Setup QEMU
        uses: docker/setup-qemu-action@v1

      - id: setup_buildx
        name: Setup BuildX
        uses: docker/setup-buildx-action@v1

      - id: login
        name: Login to Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ env.REGISTRY_USERNAME }}
          password: ${{ env.REGISTRY_PASSWORD }}

      - id: meta
        name: Define Container metadata
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.REGISTRY }}/${{ env.ORGANISATION }}/${{ env.PROJECT }}
          flavor: |
            latest=true
          tags: |
            type=raw,value=${{ needs.create_release.outputs.calver }}
            type=sha,format=long
            type=ref,event=branch
            type=ref,event=tag

      - id: build
        name: Build and push Container image
        uses: docker/build-push-action@v2
        with:
          context: ${{ matrix.config.folder }}
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            VERSION=latest

  #########################
  # Publish the the Rust app (GitHub Release)
  #########################

  release_publish_github:

    name: Publish Release to GitHub

    needs:
      - create_release
      - build_rust

    runs-on: ${{ matrix.os }}

    timeout-minutes: 60

    strategy:
      fail-fast: true
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-apple-darwin
            os: macos-latest
            toolchain: stable
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            toolchain: stable
          #- target: aarch64-unknown-linux-gnu
          #  os: ubuntu-latest
          #  toolchain: stable
        #exclude:

    steps:

      - id: fetch_artifact
        name: Fetch the Build artifact to upload
        uses: actions/download-artifact@v2
        with:
          name: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip

      - id: show_artifacts
        name: Show downloaded Artifacts
        run: ls -R

      - id: upload_release_artifact_github_prerelease
        if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
        name: Upload Artifact to Pre-Release
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create_release.outputs.upload_url_prerelease }}
          asset_path: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip
          asset_name: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip
          asset_content_type: application/zip

      - id: upload_release_artifact_github
        if: github.event_name == 'push' && contains( github.ref, 'trunk' )
        name: Upload Artifact to Release
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create_release.outputs.upload_url }}
          asset_path: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip
          asset_name: ${{ needs.create_release.outputs.repo_name }}-${{ matrix.target }}.zip
          asset_content_type: application/zip

  #########################
  # Publish the the Rust app (crates.io)
  #########################

  release_publish_crates_io:

    name: Publish Release to crates.io

    needs:
      - create_release
      - build_rust

    runs-on: ${{ matrix.os }}

    timeout-minutes: 30

    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest

    steps:

      - id: setup_rust
        name: Setup the Rust environment
        uses: actions-rs/toolchain@v1
        with:
          target: ${{ matrix.target }}
          toolchain: stable
          default: true

      - id: checkout_repository
        name: Checkout repository
        uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_REPOS }}
        with:
          fetch-depth: 0
          submodules: false
          clean: true
          persist-credentials: true

      - id: bump_cargo_release_dry
        name: Bump Cargo release (Dry Run)
        if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
        # && !contains( github.event.head_commit.author.name, 'GITHUBACTION' )
        run: |
          git config --local user.name "${GITHUB_ACTOR}"
          git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
          cargo install --verbose cargo-bump
          cargo bump ${{ needs.create_release.outputs.calver }}
          cargo update --verbose --package ${{ needs.create_release.outputs.repo_name }}
          git status
          grep "version" Cargo.toml
          git add Cargo.toml Cargo.lock
          git commit --no-verify --all --message "Bump Cargo version to ${{ needs.create_release.outputs.calver }}" \
          || echo "No changes to commit"

      - id: bump_cargo_release
        name: Bump Cargo release
        if: github.event_name == 'push' && contains( github.ref, 'trunk' )
        # && !contains( github.event.head_commit.author.name, 'GITHUBACTION' )
        run: |
          git config --local user.name "${GITHUB_ACTOR}"
          git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
          cargo install --verbose cargo-bump
          cargo bump ${{ needs.create_release.outputs.calver }}
          cargo update --verbose --package ${{ needs.create_release.outputs.repo_name }}
          git status
          grep "version" Cargo.toml
          git add Cargo.toml Cargo.lock
          git commit --no-verify --all --message "Bump Cargo version to ${{ needs.create_release.outputs.calver }}" \
          || echo "No changes to commit"
          git push --force origin trunk

      - id: upload_release_artifact_crates_io_dry
        name: Upload Rust application to crates.io (Dry Run)
        run: >
          cargo publish
          --token ${{ secrets.PAT_CRATES_IO }}
          --dry-run

      - id: upload_release_artifact_crates_io
        name: Upload Rust application to crates.io
        if: github.event_name == 'push' && contains( github.ref, 'trunk' )
        run: >
          cargo publish
          --token ${{ secrets.PAT_CRATES_IO }}