name: Build App
on:
  push:
    branches:
      - '**'
  pull_request:
    branches: 
      - '**'

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  APP_NAME: ${{ github.event.repository.name }}

jobs:
  refs:
    name: Prepare CI Environment
    runs-on: ubuntu-22.04
    outputs:
      sha_short: ${{ steps.refs.outputs.sha_short }}
      short_ref: ${{ steps.refs.outputs.short_ref }}
      version: ${{ steps.refs.outputs.version }}
      new_release: ${{ steps.refs.outputs.new_release }}
    steps:
      - name: Source checkout
        uses: actions/checkout@v4
      - name: Semantic Release
        id: semantic
        if: github.ref == 'refs/heads/main' || github.ref_name == 'alpha'
        uses: cycjimmy/semantic-release-action@v4
        with:
          dry_run: true
          semantic_version: 21
          extra_plugins: |
            @semantic-release/changelog
            @semantic-release/git
            conventional-changelog-conventionalcommits@7
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Set outputs
        id: refs
        run: |
          export BRANCH=${GITHUB_REF#refs/*/}
          echo "branch: ${BRANCH}"
          export BRANCHTRANSLATED=$(echo ${BRANCH} | tr '/' '_')
          echo "short_ref: ${BRANCHTRANSLATED}"
          export VERSION=""
          if ${{ steps.semantic.outputs.new_release_published == 'true' }}; then
            export VERSION=${{ steps.semantic.outputs.new_release_version }}
          else
            export VERSION=${BRANCHTRANSLATED}_$(git rev-parse --short=12 HEAD)
          fi
          echo "new_release=${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_OUTPUT
          echo "short_ref=${BRANCHTRANSLATED}" >> $GITHUB_OUTPUT
          echo "sha_short=SHA-$(git rev-parse --short=12 HEAD)" >> $GITHUB_OUTPUT
          echo "version=${VERSION}" >> $GITHUB_OUTPUT

  build2:
    name: Build Simulator
    needs: refs
    runs-on: windows-2022

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Checkout berry submodule
      run: |
        git submodule update --init --recursive libraries/berry

    - name: Setup MSBuild
      uses: microsoft/setup-msbuild@v2

    - name: Checkout simulator repository
      run: |
        git clone https://github.com/openshwprojects/obkSimulator
        mkdir -p ./libs_for_simulator
        cp -r ./obkSimulator/simulator/libs_for_simulator/* ./libs_for_simulator

    - name: Build project
      run: msbuild openBeken_win32_mvsc2017.vcxproj /p:Configuration=Release /p:PlatformToolset=v143
    - name: Flatten build assets
      run: |
        mkdir -p flat
        cp ./Release/openBeken_win32.exe flat/
        cp ./obkSimulator/simulator/*.dll flat/
        cp ./run_*.bat flat/
        mkdir -p flat/examples
        cp -r ./obkSimulator/examples/* flat/examples/
    - name: Run unit tests
      run: |
        ./flat/openBeken_win32.exe -runUnitTests 2
    - name: Compress build assets
      run: |
        Compress-Archive -Path flat/* -DestinationPath obkSimulator_win32_${{ needs.refs.outputs.version }}.zip
    - name: Copy build assets
      run: |
        mkdir -Force output/${{ needs.refs.outputs.version }}
        cp obkSimulator_win32_${{ needs.refs.outputs.version }}.zip output/${{ needs.refs.outputs.version }}/obkSimulator_${{ needs.refs.outputs.version }}.zip
    - name: Upload build assets
      uses: actions/upload-artifact@v4
      with:
        name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_sim
        path: output/${{ needs.refs.outputs.version }}/obkSimulator_${{ needs.refs.outputs.version }}.zip

  build_asan:
    name: Build Linux Simulator and Run Tests With Address Sanitizer
    needs: refs
    runs-on: ubuntu-22.04

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Checkout berry submodule
      run: |
        git submodule update --init --recursive libraries/berry
        mkdir -p libraries/berry/generate
        ./libraries/berry/tools/coc/coc -o libraries/berry/generate libraries/berry/src src/berry/modules -c include/berry_conf.h

    - name: Build project
      run: ASAN=1 make -f custom.mk
    - name: Run unit tests
      run: |
        export LSAN_OPTIONS=suppressions=platforms/linux/asan.suppressions
        ./build/win_main -runUnitTests 2

  build_ubsan:
    name: Build Linux Simulator and Run Tests With Undefined Behavior Sanitizer
    needs: refs
    runs-on: ubuntu-22.04

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Checkout berry submodule
      run: |
        git submodule update --init --recursive libraries/berry
        mkdir -p libraries/berry/generate
        ./libraries/berry/tools/coc/coc -o libraries/berry/generate libraries/berry/src src/berry/modules -c include/berry_conf.h

    - name: Build project
      run: UBSAN=1 make -f custom.mk
    - name: Run unit tests
      run: |
        export UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=platforms/linux/ubsan.suppressions
        ./build/win_main -runUnitTests 2

  build:
    name: Build
    needs: refs
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false
      matrix:
        include:
          # default for all platforms
          - platform: OpenBK7231T
            variant: default
          - platform: OpenBK7231N
            variant: default
          - platform: OpenXR809
            variant: default
            gcc: 8-2019-q3
          - platform: OpenXR806
            variant: default
            gcc: 8-2019-q3
          - platform: OpenXR872
            variant: default
            gcc: 8-2019-q3
          - platform: OpenBL602
            variant: default
          - platform: OpenW800
            variant: default
          - platform: OpenW600
            variant: default
          - platform: OpenLN882H
            variant: default
            gcc: 10.3-2021.10
          - platform: OpenTR6260
            variant: default
          - platform: OpenRTL8710A
            variant: default
            gcc: 8-2019-q3
          - platform: OpenRTL8710B
            variant: default
            gcc: 8-2019-q3
          - platform: OpenRTL87X0C
            variant: default
            gcc: apt
          - platform: OpenRTL8720D
            variant: default
            gcc: 10.3-2021.10
          - platform: OpenECR6600
            variant: default
          - platform: OpenRDA5981
            variant: default
            gcc: 6-2017-q2
          - platform: OpenRTL8721DA
            variant: default
          - platform: OpenRTL8720E
            variant: default

          # extras for BK7231T
          - platform: OpenBK7231T
            variant: berry
          - platform: OpenBK7231T
            variant: tuyaMCU
          - platform: OpenBK7231T
            variant: powerMetering
          - platform: OpenBK7231T
            variant: irRemoteESP
          - platform: OpenBK7231T
            variant: sensors

          # extras for BK7231N
          - platform: OpenBK7231N
            variant: berry
          - platform: OpenBK7231N
            variant: tuyaMCU
          - platform: OpenBK7231N
            variant: powerMetering
          - platform: OpenBK7231N
            variant: irRemoteESP
          - platform: OpenBK7231N
            variant: sensors
          - platform: OpenBK7231N
            variant: hlw8112
            
          - platform: OpenBL602
            variant: berry

          # ALT firmware
          - platform: OpenBK7231N_ALT
            variant: default
            gcc: apt
          - platform: OpenBK7231T_ALT
            variant: default
            gcc: apt
          - platform: OpenBK7231U
            variant: default
            gcc: apt
          - platform: OpenBK7238
            variant: default
            gcc: apt
          - platform: OpenBK7252
            variant: default
            gcc: apt
          - platform: OpenBK7252N
            variant: default
            gcc: apt
          # extras for BK7238
          - platform: OpenBK7238
            variant: berry
            gcc: apt
          - platform: OpenBK7238
            variant: irRemoteESP
            gcc: apt
    steps:
      - name: Source checkout
        uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        if: ${{ matrix.platform == 'OpenBL602' || matrix.platform == 'OpenRTL8721DA' || matrix.platform == 'OpenRTL8720E' }}
        with:
          python-version: '3.10'
          architecture: 'x64'
          cache: 'pip'

      - name: Install dependencies
        if: ${{ matrix.platform == 'OpenLN882H' }}
        uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: cmake
          version: 1.0

      - name: Install arm-none-eabi-gcc
        if: ${{ matrix.gcc && matrix.gcc != 'apt' }}
        uses: carlosperate/arm-none-eabi-gcc-action@v1
        with:
          release: ${{ matrix.gcc }}
          path-env-var: ARM_NONE_EABI_GCC_PATH

      - name: Install arm-none-eabi-gcc
        if: ${{ matrix.gcc == 'apt' }}
        run: |
          curl -sL https://raw.githubusercontent.com/ilikenwf/apt-fast/master/quick-install.sh | sudo bash
          sudo apt-get update
          sudo apt-fast install -y gcc-arm-none-eabi

      - run: ls -la
  
      - name: Run make
        run: make APP_VERSION=${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }} APP_NAME=${{ matrix.platform }} VARIANT="${{ matrix.variant }}" ${{ matrix.platform }}

      - name: Save build assets
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}
          path: |
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_UA_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_UG_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_QIO_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/OpenBK7231M_QIO_${{ needs.refs.outputs.version }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/OpenBK7231M_ALT_QIO_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.rbl
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.img
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.fls
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_ota.img
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_gz.img
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_OTA.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_OTA.bin.xz
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_OTA.bin.xz.ota
          if-no-files-found: warn

  build_idf:
    name: Build IDF
    needs: refs
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: OpenESP32C2
            variant: 2M
            version: v5.5.1
          - platform: OpenESP32C3
            variant: 2M
            version: v5.5.1

          - platform: OpenESP32
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32C2
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32C3
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32C6
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32S3
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32S2
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32C5
            variant: 4M
            version: v5.5.1
          - platform: OpenESP32C61
            variant: 4M
            version: v5.5.1
    steps:
      - name: Source checkout
        uses: actions/checkout@v4
      - name: SDK checkout
        uses: actions/checkout@v4
        with:
          repository: espressif/esp-idf
          path: sdk/esp-idf
          ref: ${{ matrix.version }}
          submodules: recursive
      - uses: actions/setup-python@v5
        id: pysetup
        with:
          python-version: '3.10'
          architecture: 'x64'
          cache: 'pip'
      - name: Install dependencies
        uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: cmake
          version: 1.0
      - name: Cache toolchain
        id: cache-toolchain
        uses: actions/cache@v4
        with:
          path: ~/.espressif # cache whole folder, not just dist
          key: ESP-IDF_toolchain_${{ matrix.version }}_${{ steps.pysetup.outputs.python-version }}
      - name: Get toolchain
        if: steps.cache-toolchain.outputs.cache-hit != 'true'
        run: |
          cd sdk/esp-idf
          ./install.sh
      - name: Run make
        run: |
          cd sdk/esp-idf
          . ./export.sh
          . ./add_path.sh
          cd ../..
          make APP_VERSION=${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }} APP_NAME=${{ matrix.platform }} VARIANT="${{ matrix.variant }}" ${{ matrix.platform }}
      - name: Save build assets
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}
          path: |
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.img
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.factory.bin
          if-no-files-found: warn

  build_8266:
    name: Build ESP8266
    needs: refs
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
    container:
      image: coatldev/six:latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: OpenESP8266
            variant: default
    steps:
      - name: Source checkout
        uses: actions/checkout@v4
      - name: SDK checkout
        uses: actions/checkout@v4
        with:
          repository: espressif/ESP8266_RTOS_SDK
          path: sdk/ESP8266_RTOS_SDK
          ref: release/v3.4
          submodules: false
          fetch-tags: true
          fetch-depth: '200'
      - name: Install dependencies
        run: |
          git config --global user.name github-actions
          git config --global user.email github-actions@github.com
          apt-get update && apt-get -y install cmake
          pip2 install virtualenv
          cd sdk/ESP8266_RTOS_SDK
          git checkout c965e03d2b7418b085c394dc98c6a0d3371c2abd
          patch -p1 -d . < ../../platforms/ESP8266/sdk.patch
          git revert 0325f833aac7b34d7627619499949331a98fc3ab --no-edit
          git submodule update --init components/coap/libcoap
          cd components/coap/libcoap
          git fetch
          git checkout 017528d7d96dca2318ed587b5fd3c0d57a89e49a
          cd ../../..
          git add .
          git commit -m "upd"
          git submodule update --init --recursive
          cd ../..
          python2 -m pip install --user -r sdk/ESP8266_RTOS_SDK/requirements.txt
          python3 -m pip install esptool
      - name: Run make
        run: |
          cd sdk/ESP8266_RTOS_SDK
          ./install.sh > /dev/null
          . ./export.sh
          . ./add_path.sh
          cd ../..
          make APP_VERSION=${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }} APP_NAME=${{ matrix.platform }} VARIANT="${{ matrix.variant }}" ${{ matrix.platform }}
      - name: Save build assets
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}
          path: |
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.img
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_2MB_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.factory.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_1MB_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.factory.bin
          if-no-files-found: warn

  build_txw81x:
    name: Build TXW81X
    needs: refs
    runs-on: windows-latest
    defaults:
      run:
        shell: wsl-bash {0}
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: OpenTXW81X
            variant: default
    steps:
      - name: Source checkout
        uses: actions/checkout@v4
      - uses: Vampire/setup-wsl@v6
        with:
          wsl-version: 1
          distribution: Ubuntu-22.04
          additional-packages: make
      - name: Run make
        run: |
          make APP_VERSION=${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }} APP_NAME=${{ matrix.platform }} VARIANT="${{ matrix.variant }}" ${{ matrix.platform }}
      - name: Save build assets
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}
          path: |
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.bin
            output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}_ota.img
          if-no-files-found: warn

  merge:
    name: Merge Artifacts
    runs-on: ubuntu-22.04
    needs: [refs, build, build2, build_idf, build_8266, build_txw81x]
    #if: always() && needs.refs.outputs.new_release == 'true' && (github.ref == 'refs/heads/main' || github.ref_name == 'alpha')
    steps:
      - name: Merge Artifacts
        uses: actions/upload-artifact/merge@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
          #delete-merged: true

  release:
    name: Semantic Release Images and Artifacts
    runs-on: ubuntu-22.04
    needs: [merge, refs]
    if: always() && needs.refs.outputs.new_release == 'true' && (github.ref == 'refs/heads/main' || github.ref_name == 'alpha')
    steps:
      - name: Source checkout
        uses: actions/checkout@v4
      - name: Fetch build assets
        uses: actions/download-artifact@v4
        with:
          name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
          path: output/${{ needs.refs.outputs.version }}
      - name: Run Semantic Release
        id: semantic
        uses: cycjimmy/semantic-release-action@v4
        with:
          dry_run: false
          semantic_version: 21
          extra_plugins: |
            @semantic-release/changelog
            @semantic-release/git
            conventional-changelog-conventionalcommits@7
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Echo Semantic Release Versions
        if: steps.semantic.outputs.new_release_published == 'true'
        run: |
          echo ${{ steps.semantic.outputs.new_release_version }}
          echo ${{ steps.semantic.outputs.new_release_major_version }}
          echo ${{ steps.semantic.outputs.new_release_minor_version }}
          echo ${{ steps.semantic.outputs.new_release_patch_version }}
