name: "[CD] Create release"
on:
  push:
    tags:
      - "v1*"

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-latest
    if: github.repository == 'aws-cloudformation/cfn-lint'
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.13"
      - name: Build
        run: |
          pip install -e .
          scripts/release/generator.py
          scripts/release/changelog.py --version ${{ github.ref_name }}
      - name: Release
        uses: softprops/action-gh-release@v3
        if: startsWith(github.ref, 'refs/tags/v1')
        with:
          name: Release ${{ github.ref_name }}
          token: ${{ secrets.GH_PAT }}
          body_path: ${{ github.workspace }}/build/CHANGELOG.md
          files: |
            build/schemas-cfnlint.zip
            build/schemas-draft7.zip
