rusty-duplication 0.6.1

Capture the screen on Windows using the Desktop Duplication API in Rust, with shared memory support.
Documentation
name: Publish

on:
  push:
    tags:
      - "v*.*.*"
  workflow_dispatch:
    inputs:
      version:
        description: "Version of the release, should match an existing tag name. E.g. v0.1.0"
        required: true

jobs:
  publish:
    runs-on: windows-2022
    steps:
      - uses: actions/checkout@v4

      # set the version to the input. if the input is not set (triggered by tag), it will be the tag name
      - shell: bash
        run: echo "VERSION=${{ inputs.version || github.ref_name }}" >> $GITHUB_ENV

      # validate crate version
      - shell: bash
        run: |

          VERSION=`cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"'`
          [ "v$VERSION" = "${{ env.VERSION }}" ] || (echo "Version mismatch" && exit 1)

      # validate CHANGELOG version
      # TODO: use a CHANGELOG linter
      - shell: bash
        run: |

          VERSION=`cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"'`
          grep -q "## \[$VERSION\]" CHANGELOG.md || (echo "Version not found in CHANGELOG" && exit 1)

      - uses: actions-rust-lang/setup-rust-toolchain@v1

      - run: cargo fmt --check

      - run: cargo clippy -- -D warnings

      - run: cargo check --examples

      - run: cargo doc
        env:
          RUSTDOCFLAGS: -D warnings

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

      # create the release
      - run: gh release create ${{ env.VERSION }} -t ${{ env.VERSION }} --verify-tag -n "See [CHANGELOG.md](https://github.com/DiscreteTom/rusty-duplication/blob/main/CHANGELOG.md)."
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}