textblocks 0.1.1

A library for working with text blocks.
Documentation
name: Rust Release

on:
  workflow_dispatch:
  push:
    branches: ["main"]
    tags:
      - "v*.*.*"
    paths:
      # NOTE: Path filters are ignored for tag pushes
      - "src/**"
      - "Cargo.toml"
  pull_request:
    branches: ["main"]
    paths:
      - "src/**"
      - "Cargo.toml"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Clippy
        run: cargo clippy --all-targets --all-features -- -D warnings
      - name: Build
        run: cargo build --all-targets --all-features --verbose
      - name: Run tests
        run: cargo test --all-targets --all-features --verbose

  release:
    if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
    needs: [test]
    runs-on: ubuntu-latest
    steps:
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          name: ${{ github.ref_name }}
          draft: ${{ github.event_name == 'workflow_dispatch' }}

  publish:
    if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
    needs: [test]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        continue-on-error: true