beaconcrypt 0.4.3

Cryptographic transport for C2 channels
Documentation
name: Release

on:
  push:

env:
  CARGO_TERM_COLOR: always
  CAPNP_VERSION: 1.5.0

jobs:
  unix-build:
    strategy:
      matrix:
        os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel]
    runs-on: ${{ matrix.os }}
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v7
      with:
        submodules: recursive
    - name: Restore cached cap'n proto
      id: cache-capnproto
      uses: actions/cache@v6
      with:
        path: ~/.local/capnproto
        key: capnproto-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.CAPNP_VERSION }}
    - name: Build cap'n proto
      if: steps.cache-capnproto.outputs.cache-hit != 'true'
      run: |
        curl --fail --location --output "capnproto-c++-${CAPNP_VERSION}.tar.gz" "https://capnproto.org/capnproto-c++-${CAPNP_VERSION}.tar.gz"
        tar zxf "capnproto-c++-${CAPNP_VERSION}.tar.gz"
        cd "capnproto-c++-${CAPNP_VERSION}"
        ./configure --prefix="$HOME/.local/capnproto"
        make -j4 check
        make install
    - name: Add cap'n proto to PATH
      run: echo "$HOME/.local/capnproto/bin" >> "$GITHUB_PATH"
    - name: Build
      run: |
        rustup component add rust-src --toolchain nightly
        cargo +nightly rustc --release -Z build-std=std,panic_abort --no-default-features --features gobinds --crate-type=staticlib
        mv target/release/libbeaconcrypt.a target/release/libbeaconcrypt-gobinds-${{ matrix.os }}.a
        cargo +nightly rustc --release -Z build-std=std,panic_abort --no-default-features --features beacon --crate-type=staticlib
        mv target/release/libbeaconcrypt.a target/release/libbeaconcrypt-beacon-${{ matrix.os }}.a
    - name: Run tests
      run: cargo test --verbose
    - name: Upload release artifact
      uses: actions/upload-artifact@v7
      with:
        name: beaconcrypt-static-${{ matrix.os }}
        path: target/release/libbeaconcrypt-*.a
        retention-days: 1

  windows-build:
    strategy:
      matrix:
        os: [windows-latest]
    runs-on: ${{ matrix.os }}
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v7
      with:
        submodules: recursive
    - name: Install cap'n proto
      run: |
        curl.exe -O https://capnproto.org/capnproto-c++-win32-1.5.0.zip
        Expand-Archive capnproto-c++-win32-1.5.0.zip
    - name: Build
      run: |
        $env:Path = "$env:Path;$(join-path $pwd '\capnproto-c++-win32-1.5.0\capnproto-tools-win32-1.5.0')"
        rustup component add rust-src --toolchain nightly-msvc
        cargo +nightly rustc --release -Z build-std=std,panic_abort --no-default-features --features gobinds --crate-type=staticlib
        mv target/release/beaconcrypt.lib target/release/beaconcrypt-gobinds-${{ matrix.os }}.lib
        cargo +nightly rustc --release -Z build-std=std,panic_abort --no-default-features --features beacon --crate-type=staticlib
        mv target/release/beaconcrypt.lib target/release/beaconcrypt-beacon-${{ matrix.os }}.lib
        ls target/release
    - name: Run tests
      run: |
        $env:Path = "$env:Path;$(join-path $pwd '\capnproto-c++-win32-1.5.0\capnproto-tools-win32-1.5.0')"
        cargo test --verbose
    - name: Upload release artifact
      uses: actions/upload-artifact@v7
      with:
        name: beaconcrypt-static-${{ matrix.os }}
        path: target/release/beaconcrypt-*.lib
        retention-days: 1

  windows-mingw-build:
    runs-on: windows-latest
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v7
      with:
        submodules: recursive
    - name: Set up MinGW
      uses: msys2/setup-msys2@v2
      with:
        install: mingw-w64-x86_64-gcc
    - name: Install cap'n proto
      run: |
        "C:\msys64\mingw64\bin" >> $env:GITHUB_PATH
        curl.exe -O https://capnproto.org/capnproto-c++-win32-1.5.0.zip
        Expand-Archive capnproto-c++-win32-1.5.0.zip
        "$pwd\capnproto-c++-win32-1.5.0\capnproto-tools-win32-1.5.0" >> $env:GITHUB_PATH
    - name: Build
      env:
        CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc
      run: |
        rustup target add x86_64-pc-windows-gnu --toolchain nightly
        rustup component add rust-src --toolchain nightly
        cargo +nightly rustc --release -Z build-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features gobinds --crate-type=staticlib
        mv target/x86_64-pc-windows-gnu/release/libbeaconcrypt.a target/x86_64-pc-windows-gnu/release/libbeaconcrypt-gobinds-windows-mingw-x86_64.a
        cargo +nightly rustc --release -Z build-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features beacon --crate-type=staticlib
        mv target/x86_64-pc-windows-gnu/release/libbeaconcrypt.a target/x86_64-pc-windows-gnu/release/libbeaconcrypt-beacon-windows-mingw-x86_64.a
        ls target/x86_64-pc-windows-gnu/release
    - name: Run tests
      env:
        CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc
      run: cargo test --verbose --target x86_64-pc-windows-gnu
    - name: Upload release artifact
      uses: actions/upload-artifact@v7
      with:
        name: beaconcrypt-static-windows-mingw-x86_64
        path: target/x86_64-pc-windows-gnu/release/libbeaconcrypt-*.a
        retention-days: 1

  release:
    needs: [unix-build, windows-build, windows-mingw-build]
    if: ${{ github.ref_type == 'tag' }}
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v7
    - name: Download release artifact
      uses: actions/download-artifact@v8
      with:
        path: ./dist
        merge-multiple: true
    - name: Publish built binary to GitHub releases
      run: |
        gh release create ${{ github.ref_name }} --notes-from-tag ./dist/*
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}