human-errors 0.2.3

An error library focused on providing your users with relevant advice for any problem.
Documentation
name: Publish Crate
on:
  release:
    types: [released]

jobs:
  prepare:
    name: Prepare
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v6

      - name: Generate Package Version
        shell: pwsh
        run: |
          $VERSION="$('${{ github.event.release.tag_name }}'.substring(1))"
          Add-Content -Path $env:GITHUB_ENV -Value "VERSION=$VERSION"
          Write-Host $VERSION

      - name: Set Package Version
        run: sed -i "s/^version\s*=\s*\".*\"/version = \"$VERSION\"/g" Cargo.toml

      - name: Stash Versioned Cargo.toml
        uses: actions/upload-artifact@v6
        with:
          name: cargofile
          path: Cargo.toml

  publish-cargo:
    name: Publish to Cargo
    runs-on: ubuntu-latest
    needs:
      - prepare
    steps:
      - name: Get Rust Stable
        id: rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true

      - uses: Swatinem/rust-cache@v2

      - name: Check out code
        uses: actions/checkout@v6

      - name: Fetch Versioned Cargo.toml
        uses: actions/download-artifact@v7.0.0
        with:
          name: cargofile

      - name: Login to Cargo
        run: |
          cargo login ${CRATES_IO_TOKEN}
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

      - name: Publish to Cargo
        run: cargo publish --allow-dirty