name: Release cache build
on:
  push:
    tags:
      - "**[0-9]+.[0-9]+.[0-9]+*"
permissions:
  contents: read
jobs:
  nix-build-cache:
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner: ubuntu-latest
            system: x86_64-linux
          - runner: ubuntu-24.04-arm
            system: aarch64-linux
          - runner: macos-15-intel
            system: x86_64-darwin
          - runner: macos-15
            system: aarch64-darwin
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@v4
      - name: Install Nix
        uses: cachix/install-nix-action@v27
        with:
          install_url: https://nixos.org/releases/nix/nix-2.32.2/install
          nix_path: nixpkgs=channel:nixos-unstable
          extra_nix_config: |
            experimental-features = nix-command flakes
      - uses: cachix/cachix-action@v14
        with:
          name: flk-cache
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
      - name: Build flake package
        run: nix build .#flk --impure
