on:
  pull_request: {}
  push:
    # Sequence of patterns matched against refs/tags
    tags:
      - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Release

jobs:
  build:
    name: Create Release ${{ github.event_name == 'pull_request' && '(dry-run)' }}
    if: github.repository == 'cilium/cilium-cli'
    runs-on: ubuntu-24.04
    steps:
      - name: Cleanup Disk space in runner
        uses: cilium/cilium/.github/actions/disk-cleanup@71eacde5bfbe4a904f35728dc0aee626d8c3810c # main

      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Set up Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
        with:
          # renovate: datasource=golang-version depName=go
          go-version: 1.26.2

      - name: Generate the artifacts
        run: make release

      - name: Create Release
        if: github.event_name == 'push'
        uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          name: Release ${{ github.ref_name }}
          draft: true
          prerelease: false
          generate_release_notes: true
          files: 'release/*'
