fcrypt 0.3.2

Cross-platform CLI for password-based file encryption and decryption
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  build:
    name: Build Binary (${{ matrix.platform }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            platform: linux-x64
            target: x86_64-unknown-linux-gnu
            bin: fcrypt
            artifact: fcrypt-linux-x64
          - os: ubuntu-24.04-arm
            platform: linux-arm64
            target: aarch64-unknown-linux-gnu
            bin: fcrypt
            artifact: fcrypt-linux-arm64
          - os: macos-15-intel
            platform: darwin-x64
            target: x86_64-apple-darwin
            bin: fcrypt
            artifact: fcrypt-darwin-x64
          - os: macos-latest
            platform: darwin-arm64
            target: aarch64-apple-darwin
            bin: fcrypt
            artifact: fcrypt-darwin-arm64
          - os: windows-latest
            platform: win32-x64
            target: x86_64-pc-windows-msvc
            bin: fcrypt.exe
            artifact: fcrypt-win32-x64.exe
          - os: windows-11-arm
            platform: win32-arm64
            target: aarch64-pc-windows-msvc
            bin: fcrypt.exe
            artifact: fcrypt-win32-arm64.exe

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache Cargo
        uses: Swatinem/rust-cache@v2

      - name: Build release binary
        if: matrix.target != 'aarch64-pc-windows-msvc'
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Build release binary (Windows ARM64)
        if: matrix.target == 'aarch64-pc-windows-msvc'
        env:
          OQS_PERMIT_UNSUPPORTED_ARCHITECTURE: "ON"
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Prepare binary artifact (Unix)
        if: runner.os != 'Windows'
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p dist
          cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "dist/${{ matrix.artifact }}"
          chmod 755 "dist/${{ matrix.artifact }}"
          if command -v sha256sum >/dev/null 2>&1; then
            sha256sum "dist/${{ matrix.artifact }}" > "dist/${{ matrix.artifact }}.sha256"
          else
            shasum -a 256 "dist/${{ matrix.artifact }}" | awk '{print tolower($1)"  ${{ matrix.artifact }}"}' > "dist/${{ matrix.artifact }}.sha256"
          fi

      - name: Prepare binary artifact (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Path dist -Force | Out-Null
          Copy-Item "target/${{ matrix.target }}/release/${{ matrix.bin }}" "dist/${{ matrix.artifact }}"
          $hash = (Get-FileHash -Algorithm SHA256 "dist/${{ matrix.artifact }}").Hash.ToLower()
          "$hash  ${{ matrix.artifact }}" | Out-File -Encoding ascii "dist/${{ matrix.artifact }}.sha256"

      - name: Upload binary artifacts
        uses: actions/upload-artifact@v7
        with:
          name: release-${{ matrix.platform }}
          path: dist/*

  publish:
    name: Publish GitHub Release
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v7
        with:
          pattern: release-*
          path: dist
          merge-multiple: true

      - name: Publish release
        uses: softprops/action-gh-release@v3
        with:
          generate_release_notes: true
          files: dist/*