literate 0.5.1

A literate programming tool that extracts code written in your Markdown files.
Documentation
name: Add Tag

on:
  push:
    branches: [ main ]
    paths: [ "Cargo.toml" ]
  workflow_dispatch: {}

jobs:
  tag:
    name: Define Tags for version in Cargo.toml
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Create Tag
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          TAG=v$(cargo metadata --no-deps --quiet | jq -r '.packages[0] | .version')

          git fetch --tags

          if [ $(git tag -l $TAG) ]
          then
            echo "Git tag $TAG already exists."
          else
            git config user.name "Add Tag from CI"
            git config user.email ""
            git tag $TAG
            git push --tags
          fi

          gh release view $TAG &> /dev/null || gh release create $TAG -d --notes $TAG