From 2cd0299151b888922c8f64dd5daf321b42fcb331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABlle=20Huisman?= Date: Sat, 13 Jun 2026 14:30:46 +0200 Subject: [PATCH] ci: add publish binaries workflow --- .github/workflows/publish-binaries.yml | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/publish-binaries.yml diff --git a/.github/workflows/publish-binaries.yml b/.github/workflows/publish-binaries.yml new file mode 100644 index 0000000..6d616bd --- /dev/null +++ b/.github/workflows/publish-binaries.yml @@ -0,0 +1,101 @@ +name: Publish Binaries + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + publish-binary: + strategy: + fail-fast: false + matrix: + package: [mdbook-tabs, mdbook-trunk] + target: + [ + aarch64-unknown-linux-gnu, + aarch64-unknown-linux-musl, + x86_64-unknown-linux-gnu, + x86_64-unknown-linux-musl, + aarch64-apple-darwin, + x86_64-apple-darwin, + x86_64-pc-windows-msvc, + ] + include: + - target: aarch64-unknown-linux-gnu + os: ubuntu-latest + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + - target: aarch64-apple-darwin + os: macos-latest + - target: x86_64-apple-darwin + os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest + + runs-on: ${{ matrix.os }} + name: Publish ${{ matrix.package }} for ${{ matrix.target }} + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1 + with: + components: clippy, llvm-tools-preview, rustfmt, rust-std + target: ${{ matrix.target }} + + - name: Set up target (*-musl) + if: ${{ endsWith(matrix.target, '-musl') }} + run: | + sudo apt update -y + sudo apt install -y musl-dev musl-tools + + - name: Set up target (aarch64-unknown-linux-gnu) + if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} + run: | + sudo apt update -y + sudo apt install -y gcc-aarch64-linux-gnu + echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc >> $GITHUB_ENV + + - name: Set up target (aarch64-unknown-linux-musl) + if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} + run: | + sudo apt update -y + sudo apt install -y clang llvm musl-dev musl-tools + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld" >> $GITHUB_ENV + echo CC_aarch64_unknown_linux_musl=clang >> $GITHUB_ENV + echo AR_aarch64_unknown_linux_musl=llvm-ar >> $GITHUB_ENV + + - name: Build + run: cargo build --bins --locked --release --target ${{ matrix.target }} + + - name: Archive (tar.gz) + if: ${{ !contains(matrix.target, '-windows-') }} + run: tar czf ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz ${{ matrix.package }} + working-directory: target/${{ matrix.target }}/release + + - name: Archive (zip) + if: ${{ contains(matrix.target, '-windows-') }} + run: 7z a ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip ${{ matrix.package }}.exe + working-directory: target/${{ matrix.target }}/release + + - name: Upload release asset (tar.gz) + if: ${{ !contains(matrix.target, '-windows-') }} + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 + with: + tag_name: ${{ needs.release.outputs.version }} + files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz + + - name: Upload release asset (zip) + if: ${{ contains(matrix.target, '-windows-') }} + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 + with: + tag_name: ${{ needs.release.outputs.version }} + files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip