name: Publish to Crates.io

on:
  push:
    tags:
      - 'v*.*.*' # Akan jalan otomatis kalau kamu buat tag seperti v0.1.0, v1.0.0, dll.

jobs:
  publish:
    name: Publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cargo Publish
        run: cargo publish
        env:
          # Pastikan kamu sudah setting secret CARGO_REGISTRY_TOKEN di Settings GitHub
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
