name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  create-release:
    if: github.repository_owner == 'taiki-e'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: taiki-e/github-actions/create-release@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish:
    if: github.repository_owner == 'taiki-e'
    needs:
      - create-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: taiki-e/github-actions/install-rust@main
      - run: |
          cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
