<commit_before># Signs windows and macOS binaries and installers
name: Master branch build/release (signed)
defaults:
  run:
    shell: bash
on:
  push:
    branches: [ master, main ]
  release:
    types: [ created ]

env:
  BUILDKIT_PROGRESS: plain
  DOCKER_CLI_EXPERIMENTAL: enabled
  DDEV_DEBUG: true
  GITHUB_REPOSITORY_OWNER: ${{ secrets.GITHUB_REPOSITORY_OWNER }}
  DDEV_WINDOWS_SIGN: ${{ secrets.DDEV_WINDOWS_SIGN }}

jobs:
  build-most:
    name: Build DDEV executables except Windows
    runs-on: ubuntu-20.04
    env:
      SegmentKey: ${{ secrets.SEGMENTKEY }}

    steps:
      - uses: actions/checkout@v3
        with:
          # We need to get all branches and tags for git describe to work properly
          fetch-depth: 0

      - name: Install Docker and deps
        run: ./.github/workflows/linux-setup.sh

      - name: Install build tools
        run: ./.github/workflows/linux-build-setup.sh

      - uses: actions/setup-go@v3
        with:
          go-version: '>=1.18.0'

      - name: Build DDEV executables
        run: make linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 completions mkcert

      - name: "Verify that SegmentKey is working (Linux amd64)"
        run: |
          export PATH=".gotmp/bin/linux_amd64:$PATH"
          echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
          if [ -z "${SegmentKey}" ]; then echo "SegmentKey is not set"; exit 1; fi
          ddev config global --instrumentation-opt-in=true
          ddev config global | grep instrumentation-opt-in=true
          ddev config global | grep -v "SegmentKey is not available."
          ddev config global --instrumentation-opt-in=false


      - name: save build results to cache
        uses: actions/cache@v3
        with:
          path: .gotmp/bin
          key: ${{ github.sha }}-${{ github.ref }}-build-most

  # This Windows self-hosted runner has to be set up with gnu tar and zstd.exe, or
  # this step will fail to properly create the cache.
  # Make sure gnu tar is the tar used here. System PATH should have C:\program files\gnu\usr\bin near top
  # Get zstd.exe from https://github.com/facebook/zstd/releases - I put it into C:\program files\gnu\usr\bin
  # so it would be in PATH
  # See https://github.com/actions/cache/issues/580
  # Run the Windows action with debug enabled to be able to see which tar is in use, etc.
  sign-windows:
    name: Build and Sign Windows binaries
    runs-on: [ self-hosted, windows-signer ]
    env:
      SegmentKey: ${{ secrets.SEGMENTKEY }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Build and sign windows binaries and installer
        shell: bash
        run: |
          if [ "${DDEV_WINDOWS_SIGN}" != "true" ]; then echo "Warning: DDEV_WINDOWS_SIGN is not true"; fi
          make windows_install
      - name: Show github.ref
        run: echo ${{ github.ref }}
      - name: Build chocolatey on release
        if: startsWith( github.ref, 'refs/tags/v1')
        run: make chocolatey

      - name: "Verify that SegmentKey is working (Windows)"
        run: |
          export PATH=".gotmp/bin/windows_amd64:$PATH"
          echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
          if [ -z "${SegmentKey}" ]; then echo "SegmentKey is not set"; exit 1; fi
          ddev config global --instrumentation-opt-in=true
          ddev config global | grep instrumentation-opt-in=true
          ddev config global | grep -v "SegmentKey is not available."
          ddev config global --instrumentation-opt-in=false

      - name: Cache signed binaries
        uses: actions/cache@v3
        with:
          path: .gotmp/bin/windows_amd64
          key: ${{ github.sha }}-${{ github.ref }}-signed-windows-binaries

  notarize-macos:
    name: Sign and Notarize ddev on macOS
    runs-on: macos-latest
    needs: build-most
    steps:
      - name: "setup macOS"
        run: |
          brew install coreutils gnu-getopt jq
          pip3 install yq
      - uses: actions/checkout@v3
        with:
          # We need to get all branches and tags for git describe to work properly<commit_msg>Try to fix master build with freezing actions/cache on windows<commit_after># Signs windows and macOS binaries and installers
name: Master branch build/release (signed)
defaults:
  run:
    shell: bash
on:
  push:
    branches: [ master, main ]
  release:
    types: [ created ]

env:
  BUILDKIT_PROGRESS: plain
  DOCKER_CLI_EXPERIMENTAL: enabled
  DDEV_DEBUG: true
  GITHUB_REPOSITORY_OWNER: ${{ secrets.GITHUB_REPOSITORY_OWNER }}
  DDEV_WINDOWS_SIGN: ${{ secrets.DDEV_WINDOWS_SIGN }}

jobs:
  build-most:
    name: Build DDEV executables except Windows
    runs-on: ubuntu-20.04
    env:
      SegmentKey: ${{ secrets.SEGMENTKEY }}

    steps:
      - uses: actions/checkout@v3
        with:
          # We need to get all branches and tags for git describe to work properly
          fetch-depth: 0

      - name: Install Docker and deps
        run: ./.github/workflows/linux-setup.sh

      - name: Install build tools
        run: ./.github/workflows/linux-build-setup.sh

      - uses: actions/setup-go@v3
        with:
          go-version: '>=1.18.0'

      - name: Build DDEV executables
        run: make linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 completions mkcert

      - name: "Verify that SegmentKey is working (Linux amd64)"
        run: |
          export PATH=".gotmp/bin/linux_amd64:$PATH"
          echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
          if [ -z "${SegmentKey}" ]; then echo "SegmentKey is not set"; exit 1; fi
          ddev config global --instrumentation-opt-in=true
          ddev config global | grep instrumentation-opt-in=true
          ddev config global | grep -v "SegmentKey is not available."
          ddev config global --instrumentation-opt-in=false


      - name: save build results to cache
        uses: actions/cache@v3
        with:
          path: .gotmp/bin
          key: ${{ github.sha }}-${{ github.ref }}-build-most

  # This Windows self-hosted runner has to be set up with gnu tar and zstd.exe, or
  # this step will fail to properly create the cache.
  # Make sure gnu tar is the tar used here. System PATH should have C:\program files\gnu\usr\bin near top
  # Get zstd.exe from https://github.com/facebook/zstd/releases - I put it into C:\program files\gnu\usr\bin
  # so it would be in PATH
  # See https://github.com/actions/cache/issues/580
  # Run the Windows action with debug enabled to be able to see which tar is in use, etc.
  sign-windows:
    name: Build and Sign Windows binaries
    runs-on: [ self-hosted, windows-signer ]
    env:
      SegmentKey: ${{ secrets.SEGMENTKEY }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Build and sign windows binaries and installer
        shell: bash
        run: |
          if [ "${DDEV_WINDOWS_SIGN}" != "true" ]; then echo "Warning: DDEV_WINDOWS_SIGN is not true"; fi
          make windows_install
      - name: Show github.ref
        run: echo ${{ github.ref }}
      - name: Build chocolatey on release
        if: startsWith( github.ref, 'refs/tags/v1')
        run: make chocolatey

      - name: "Verify that SegmentKey is working (Windows)"
        run: |
          export PATH=".gotmp/bin/windows_amd64:$PATH"
          echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
          if [ -z "${SegmentKey}" ]; then echo "SegmentKey is not set"; exit 1; fi
          ddev config global --instrumentation-opt-in=true
          ddev config global | grep instrumentation-opt-in=true
          ddev config global | grep -v "SegmentKey is not available."
          ddev config global --instrumentation-opt-in=false

      - name: Cache signed binaries
        # It seems past 3.0.5 they're using zstdmt which is not available on Windows
        # See https://github.com/actions/cache/issues/891
        uses: actions/cache@v3.0.5
        with:
          path: .gotmp/bin/windows_amd64
          key: ${{ github.sha }}-${{ github.ref }}-signed-windows-binaries

  notarize-macos:
    name: Sign and Notarize ddev on macOS
    runs-on: macos-latest
    needs: build-most
    steps:
      - name: "setup macOS"
        run: |
          brew install coreutils gnu-getopt jq
          pip3 install yq
      - uses: actions/checkout@v3
        with:
          # We need to get all branches and tags for git describe to work properly
{'fraction_non_alphanumeric': 0.09501299929094777, 'fraction_numerical': 0.010163082013708344, 'mean_word_length': 2.3543400713436387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '953003', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2567, 'n_words': 823}