async-encrypted-stream 0.2.1

Async Read and Write wrappers around the chacha20 encryption primitives
Documentation
name: Publish

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+*'
  workflow_dispatch:
    inputs:
      tag:
        description: 'Tag to publish (e.g. v0.2.0)'
        required: true

env:
  CARGO_TERM_COLOR: always

jobs:
  prepare:
    name: Validate tag
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.parse.outputs.version }}
    steps:
      - uses: actions/checkout@v4
      - name: Parse and validate tag
        id: parse
        run: |
          TAG="${{ inputs.tag || github.ref_name }}"
          VERSION="${TAG#v}"
          CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
          if [ "$CARGO_VERSION" != "$VERSION" ]; then
            echo "ERROR: tag version $VERSION does not match Cargo.toml version $CARGO_VERSION"
            exit 1
          fi
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

  test:
    name: Test on ${{ matrix.os }}
    needs: prepare
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
      - uses: actions/checkout@v4
      - name: Clippy
        run: cargo clippy --all-features -- -D warnings
      - name: Build
        run: cargo build --release --all-features --verbose
      - name: Test
        run: cargo test --release --all-features --verbose

  publish:
    name: Publish
    needs: [prepare, test]
    runs-on: ubuntu-latest
    environment: crates-release
    env:
      CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - name: Publish
        run: cargo publish