keynest 0.4.3

Simple, offline, cross-platform secrets manager written in Rust
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    name: Build release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: keynest-x86_64-unknown-linux-gnu.tar.gz
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            artifact: keynest-x86_64-unknown-linux-musl.tar.gz
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact: keynest-x86_64-apple-darwin.tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: keynest-aarch64-apple-darwin.tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: keynest-x86_64-pc-windows-msvc.zip

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

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

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

      - name: Build release
        run: cargo build --locked --release --target ${{ matrix.target }}

      - name: Create artifact (Unix)
        if: matrix.os != 'windows-latest'
        shell: bash
        run: |
          cd target/${{ matrix.target }}/release
          tar -czvf ${{ matrix.artifact }} keynest

      - name: Create Windows artifact
        if: matrix.os == 'windows-latest'
        shell: pwsh
        run: Compress-Archive -Path "target/${{ matrix.target }}/release/keynest.exe" -DestinationPath ${{ matrix.artifact }}

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: keynest-${{ matrix.target }}
          path: target/${{ matrix.target }}/release/${{ matrix.artifact }}

  publish:
    name: Publish to crates.io
    needs: build
    runs-on: ubuntu-latest

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

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Publish
        run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  release:
    name: Create release
    needs: publish
    runs-on: ubuntu-latest

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

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Flatten artifacts
        run: |
          cp artifacts/*/* artifacts/
          find artifacts -maxdepth 1 -type d ! -name artifacts -exec rm -rf {} \;

      - name: Generate checksums
        run: |
          cd artifacts
          find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec sha256sum {} \; | sed 's|./||' > checksums.txt

      - name: Print checksums
        run: |
          cd artifacts
          sha256sum *.tar.gz *.zip 2>/dev/null || true

      - name: Print checksums by platform
        run: |
          cd artifacts
          echo "=== Linux ===" && sha256sum *linux*.tar.gz 2>/dev/null || true
          echo "=== macOS ===" && sha256sum *apple-darwin.tar.gz 2>/dev/null || true
          echo "=== Windows ===" && sha256sum *.zip 2>/dev/null || true

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          files: |
            artifacts/*.tar.gz
            artifacts/*.zip
            artifacts/checksums.txt
          generate_release_notes: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}