name: 'tagged-release'

on:
  push:
    tags:
      - 'v*'

jobs:
  tagged-release:
    name: 'Tagged Release'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install PlatformIO
        run: |
          python -m pip install --upgrade pip
          pip install -U platformio
          platformio upgrade
          pio pkg update

      - name: Build WebUI
        run: |
          cd interface
          yarn install
          yarn typesafe-i18n --no-watch
          sed -i "s/= 'pl'/= 'en'/" ./src/i18n/i18n-util.ts
          yarn build
          yarn webUI

      - name: Build firmware
        run: |
          platformio run -e ci

      - name: Build S3 firmware
        run: |
          platformio run -e ci_s3

      - name: Release
        uses: 'marvinpinto/action-automatic-releases@latest'
        with:
          repo_token: '${{ secrets.GITHUB_TOKEN }}'
          prerelease: false
          files: |
            CHANGELOG.md
            ./build/firmware/*.*
