|
| 1 | +name: Publish Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + publish-binary: |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + package: [mdbook-tabs, mdbook-trunk] |
| 16 | + target: |
| 17 | + [ |
| 18 | + aarch64-unknown-linux-gnu, |
| 19 | + aarch64-unknown-linux-musl, |
| 20 | + x86_64-unknown-linux-gnu, |
| 21 | + x86_64-unknown-linux-musl, |
| 22 | + aarch64-apple-darwin, |
| 23 | + x86_64-apple-darwin, |
| 24 | + x86_64-pc-windows-msvc, |
| 25 | + ] |
| 26 | + include: |
| 27 | + - target: aarch64-unknown-linux-gnu |
| 28 | + os: ubuntu-latest |
| 29 | + - target: aarch64-unknown-linux-musl |
| 30 | + os: ubuntu-latest |
| 31 | + - target: x86_64-unknown-linux-gnu |
| 32 | + os: ubuntu-latest |
| 33 | + - target: x86_64-unknown-linux-musl |
| 34 | + os: ubuntu-latest |
| 35 | + - target: aarch64-apple-darwin |
| 36 | + os: macos-latest |
| 37 | + - target: x86_64-apple-darwin |
| 38 | + os: macos-latest |
| 39 | + - target: x86_64-pc-windows-msvc |
| 40 | + os: windows-latest |
| 41 | + |
| 42 | + runs-on: ${{ matrix.os }} |
| 43 | + name: Publish ${{ matrix.package }} for ${{ matrix.target }} |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 47 | + |
| 48 | + - name: Set up Rust toolchain |
| 49 | + uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1 |
| 50 | + with: |
| 51 | + components: clippy, llvm-tools-preview, rustfmt, rust-std |
| 52 | + target: ${{ matrix.target }} |
| 53 | + |
| 54 | + - name: Set up target (*-musl) |
| 55 | + if: ${{ endsWith(matrix.target, '-musl') }} |
| 56 | + run: | |
| 57 | + sudo apt update -y |
| 58 | + sudo apt install -y musl-dev musl-tools |
| 59 | +
|
| 60 | + - name: Set up target (aarch64-unknown-linux-gnu) |
| 61 | + if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} |
| 62 | + run: | |
| 63 | + sudo apt update -y |
| 64 | + sudo apt install -y gcc-aarch64-linux-gnu |
| 65 | + echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc >> $GITHUB_ENV |
| 66 | +
|
| 67 | + - name: Set up target (aarch64-unknown-linux-musl) |
| 68 | + if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} |
| 69 | + run: | |
| 70 | + sudo apt update -y |
| 71 | + sudo apt install -y clang llvm musl-dev musl-tools |
| 72 | + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld" >> $GITHUB_ENV |
| 73 | + echo CC_aarch64_unknown_linux_musl=clang >> $GITHUB_ENV |
| 74 | + echo AR_aarch64_unknown_linux_musl=llvm-ar >> $GITHUB_ENV |
| 75 | +
|
| 76 | + - name: Build |
| 77 | + run: cargo build --bins --locked --release --target ${{ matrix.target }} |
| 78 | + |
| 79 | + - name: Archive (tar.gz) |
| 80 | + if: ${{ !contains(matrix.target, '-windows-') }} |
| 81 | + run: tar czf ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz ${{ matrix.package }} |
| 82 | + working-directory: target/${{ matrix.target }}/release |
| 83 | + |
| 84 | + - name: Archive (zip) |
| 85 | + if: ${{ contains(matrix.target, '-windows-') }} |
| 86 | + run: 7z a ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip ${{ matrix.package }}.exe |
| 87 | + working-directory: target/${{ matrix.target }}/release |
| 88 | + |
| 89 | + - name: Upload release asset (tar.gz) |
| 90 | + if: ${{ !contains(matrix.target, '-windows-') }} |
| 91 | + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 |
| 92 | + with: |
| 93 | + tag_name: ${{ needs.release.outputs.version }} |
| 94 | + files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz |
| 95 | + |
| 96 | + - name: Upload release asset (zip) |
| 97 | + if: ${{ contains(matrix.target, '-windows-') }} |
| 98 | + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 |
| 99 | + with: |
| 100 | + tag_name: ${{ needs.release.outputs.version }} |
| 101 | + files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip |
0 commit comments