name: 02-create_release
permissions: read-all
on:
  push:
    tags:
      - 'v*.*.*-rc.*'
jobs:
  retag:
    outputs:
      NEW_TAG: ${{ steps.tag-calculator.outputs.NEW_TAG }}
    runs-on: ubuntu22-core4-mem16-ssd150
    steps:
      - uses: actions/checkout@v4
      - id: tag-calculator
        uses: ./.github/actions/tag-action
        with:
          SUB_STRING: "-rc"
  binary-build:
    permissions:
      actions: read
      checks: read
      deployments: read
      discussions: read
      id-token: write
      issues: read
      packages: write
      pages: read
      pull-requests: read
      repository-projects: read
      security-events: read
      statuses: read
      contents: write
      attestations: write
    needs: [retag]
    uses: ./.github/workflows/b-binary-build-and-e2e-tests.yaml
    with:
      COMPONENT_NAME: kubescape
      CGO_ENABLED: 0
      GO111MODULE: ""
      GO_VERSION: "1.21"
      RELEASE: ${{ needs.retag.outputs.NEW_TAG }}
      CLIENT: release
    secrets: inherit
  create-release:
    permissions:
      actions: read
      checks: read
      contents: write
      deployments: read
      discussions: read
      id-token: write
      issues: read
      packages: read
      pages: read
      pull-requests: read
      repository-projects: read
      statuses: read
      security-events: read
      attestations: read
    needs: [retag, binary-build]
    uses: ./.github/workflows/c-create-release.yaml
    with:
      RELEASE_NAME: "Release ${{ needs.retag.outputs.NEW_TAG }}"
      TAG: ${{ needs.retag.outputs.NEW_TAG }}
      DRAFT: false
    secrets: inherit
  publish-image:
    permissions:
      actions: read
      checks: read
      deployments: read
      discussions: read
      id-token: write
      issues: read
      packages: write
      pages: read
      pull-requests: read
      repository-projects: read
      security-events: read
      statuses: read
      attestations: read
      contents: write
    uses: ./.github/workflows/d-publish-image.yaml
    needs: [create-release, retag]
    with:
      client: "image-release"
      image_name: "quay.io/${{ github.repository_owner }}/kubescape-cli"
      image_tag: ${{ needs.retag.outputs.NEW_TAG }}
      support_platforms: true
      cosign: true
    secrets: inherit
  post-release:
    permissions:
      actions: read
      checks: read
      deployments: read
      discussions: read
      id-token: write
      issues: read
      packages: write
      pages: read
      pull-requests: read
      repository-projects: read
      security-events: read
      statuses: read
      attestations: read
      contents: write
    uses: ./.github/workflows/e-post-release.yaml
    needs: [publish-image]
    with:
      TAG: ${{ needs.retag.outputs.NEW_TAG }}
    secrets: inherit
