|
| 1 | +# |
| 2 | +# Based on https://github.com/release-plz/release-plz/blob/a5043c478d46d051c00e4fbc85036ac22510f07e/.github/workflows/cd.yml |
| 3 | +# |
| 4 | + |
| 5 | +name: CD # Continuous Deployment |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + # Manual triggers don't actually publish but dry-run the builds. |
| 11 | + workflow_dispatch: null |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_INCREMENTAL: 0 |
| 15 | + CARGO_NET_GIT_FETCH_WITH_CLI: true |
| 16 | + CARGO_NET_RETRY: 10 |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + RUST_BACKTRACE: 1 |
| 19 | + RUSTFLAGS: -D warnings |
| 20 | + RUSTUP_MAX_RETRIES: 10 |
| 21 | + |
| 22 | +defaults: |
| 23 | + run: |
| 24 | + shell: bash |
| 25 | + |
| 26 | +jobs: |
| 27 | + upload-assets: |
| 28 | + name: ${{ matrix.target }} |
| 29 | + |
| 30 | + permissions: |
| 31 | + contents: write |
| 32 | + id-token: write |
| 33 | + attestations: write |
| 34 | + |
| 35 | + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.repository_owner == 'reubeno' && startsWith(github.event.release.name, 'brush-shell-v')) |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + strategy: |
| 38 | + # Run all jobs to completion regardless of errors. |
| 39 | + # This is useful because sometimes we fail to compile for a certain target. |
| 40 | + fail-fast: false |
| 41 | + matrix: |
| 42 | + include: |
| 43 | + # NOTE: We don't provide Windows binaries yet. |
| 44 | + # - target: aarch64-pc-windows-msvc |
| 45 | + # os: windows-2022 |
| 46 | + - target: x86_64-unknown-linux-gnu |
| 47 | + os: ubuntu-22.04 |
| 48 | + - target: x86_64-apple-darwin |
| 49 | + os: macos-13 |
| 50 | + # - target: x86_64-pc-windows-msvc |
| 51 | + # os: windows-2022 |
| 52 | + - target: x86_64-unknown-linux-musl |
| 53 | + os: ubuntu-22.04 |
| 54 | + - target: aarch64-unknown-linux-gnu |
| 55 | + os: ubuntu-22.04 |
| 56 | + - target: aarch64-unknown-linux-musl |
| 57 | + os: ubuntu-22.04 |
| 58 | + - target: aarch64-apple-darwin |
| 59 | + os: macos-13 |
| 60 | + timeout-minutes: 60 |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: "Checkout repository" |
| 64 | + |
| 65 | + with: |
| 66 | + persist-credentials: false |
| 67 | + |
| 68 | + - name: "Install Rust toolchain" |
| 69 | + uses: actions-rust-lang/[email protected] |
| 70 | + |
| 71 | + - name: "Setup cross-compiling toolchain" |
| 72 | + if: startsWith(matrix.os, 'ubuntu') && !contains(matrix.target, '-musl') |
| 73 | + |
| 74 | + with: |
| 75 | + target: ${{ matrix.target }} |
| 76 | + |
| 77 | + - name: "Installing musl cross tools" |
| 78 | + if: contains(matrix.target, '-musl') |
| 79 | + |
| 80 | + with: |
| 81 | + tool: cross |
| 82 | + |
| 83 | + - name: "Update build flags" |
| 84 | + if: endsWith(matrix.target, 'windows-msvc') |
| 85 | + run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}" |
| 86 | + |
| 87 | + - name: "Build and upload binaries to release" |
| 88 | + |
| 89 | + id: upload-release |
| 90 | + with: |
| 91 | + dry-run: ${{ github.event_name != 'release' }} |
| 92 | + bin: brush |
| 93 | + locked: true |
| 94 | + target: ${{ matrix.target }} |
| 95 | + tar: unix |
| 96 | + zip: windows |
| 97 | + checksum: sha256,sha512 |
| 98 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + - name: "Generate artifact attestation" |
| 101 | + if: github.event_name == 'release' |
| 102 | + |
| 103 | + with: |
| 104 | + subject-path: "${{ steps.upload-release.outputs.archive }}.*" |
0 commit comments