name: Publish to crates.io

on:
  push:
    tags:
      - 'v*'

defaults:
  run:
    shell: bash

jobs:
  publish:
    name: Publish crates
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v3

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      - name: Publish storekey-derive to crates.io
        run: cargo publish -p storekey-derive
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

      - name: Publish storekey to crates.io
        run: cargo publish -p storekey
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
