name: Build and Release

on:
  push:
    branches: [main, next, beta]

permissions:
  contents: write

jobs:
  release:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Bun
        uses: oven-sh/setup-bun@v1
        with:
          bun-version: 'latest'

      - name: Cache Bun dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.bun
            node_modules
          key: ${{ runner.os }}-bun-cache-${{ hashFiles('**/bun.lockb') }}
          restore-keys: |
            ${{ runner.os }}-bun-cache-

      - name: Install deps
        run: bun install

      - name: Build
        run: bun run build

      - name: Release
        id: release
        run: bun run release
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
