name: Build and Release

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.GIT_PAT }}
        with:
      - name: Build and release binaries
        uses: bearmetal/ci-actions/deno-publish@main
        with:
          entrypoint: main.ts
          compile-flags: "--allow-read --allow-write --allow-env --allow-net"

  publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.GIT_PAT }}
      - name: Set up Deno
        uses: denoland/setup-deno@v1
        with:
          deno-version: 2.3.1

      - name: Publish to JSR
        run: deno publish --token ${{ secrets.JSR_TOKEN }}
