name: Bazel Release

on:
  release:
    types: [published]

jobs:
  # A release archive is required for bzlmod
  # See: https://blog.bazel.build/2023/02/15/github-archive-checksum.html
  bazel-release-archive:
    runs-on: ubuntu-latest
    continue-on-error: true
    permissions:
      contents: write
    steps:
      - uses: actions/setup-go@v5
      - run: go install github.com/bazelbuild/buildtools/buildozer@latest
      - uses: actions/checkout@v4
      - run: ./scripts/sync_bzlmod_version.sh
      - run: git archive $GITHUB_REF -o "entt-${GITHUB_REF:10}.tar.gz"
      - run: gh release upload ${GITHUB_REF:10} "entt-${GITHUB_REF:10}.tar.gz"
        env:
          GH_TOKEN: ${{ github.token }}
