name: Build or Publish on: workflow_dispatch: inputs: publish_pypi: description: 'Pubblicare su PyPI (true) o compilare eseguibili? (false)' required: true default: 'false' type: choice options: - 'true' - 'false' push: tags: - "v*.*" jobs: publish: if: (startsWith(github.ref_name, 'v') || github.event_name == 'workflow_dispatch') && github.event.inputs.publish_pypi == 'true' runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get the latest tag id: get_latest_tag run: echo "latest_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install packaging dependencies run: | python -m pip install --upgrade pip python -m pip install setuptools wheel twine - name: Build package run: python setup.py sdist bdist_wheel - name: Upload to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: twine upload dist/* build: if: (startsWith(github.ref_name, 'v') || github.event_name == 'workflow_dispatch') && github.event.inputs.publish_pypi == 'false' strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get the latest tag id: get_latest_tag shell: pwsh run: | $latestTag = git describe --tags --abbrev=0 echo "latest_tag=$latestTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt python -m pip install pyinstaller - name: Build executable with PyInstaller (Windows) if: matrix.os == 'windows-latest' shell: pwsh run: | pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator ` --hidden-import=qbittorrentapi --hidden-import=qbittorrent ` --hidden-import=bs4 --hidden-import=httpx --hidden-import=rich --hidden-import=tqdm ` --hidden-import=m3u8 --hidden-import=psutil --hidden-import=unidecode ` --hidden-import=jsbeautifier --hidden-import=jsbeautifier.core ` --hidden-import=jsbeautifier.javascript --hidden-import=jsbeautifier.javascript.beautifier ` --hidden-import=jsbeautifier.unpackers --hidden-import=jsbeautifier.unpackers.packer ` --hidden-import=jsbeautifier.unpackers.javascriptobfuscator ` --hidden-import=jsbeautifier.unpackers.myobfuscate ` --hidden-import=jsbeautifier.unpackers.urlencode ` --hidden-import=jsbeautifier.unpackers.meshim ` --hidden-import=editorconfig --hidden-import=editorconfig.handlers ` --hidden-import=six --hidden-import=pathvalidate ` --hidden-import=Cryptodome.Cipher --hidden-import=Cryptodome.Cipher.AES ` --hidden-import=Cryptodome.Util --hidden-import=Cryptodome.Util.Padding ` --hidden-import=Cryptodome.Random ` --hidden-import=telebot ` --additional-hooks-dir=pyinstaller/hooks ` --add-data "StreamingCommunity;StreamingCommunity" ` --name=StreamingCommunity_win --icon=".github/media/logo.ico" test_run.py - name: Build executable with PyInstaller (Linux) if: matrix.os == 'ubuntu-latest' run: | pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator \ --hidden-import=qbittorrentapi --hidden-import=qbittorrent \ --hidden-import=bs4 --hidden-import=httpx --hidden-import=rich --hidden-import=tqdm \ --hidden-import=m3u8 --hidden-import=psutil --hidden-import=unidecode \ --hidden-import=jsbeautifier --hidden-import=jsbeautifier.core \ --hidden-import=jsbeautifier.javascript --hidden-import=jsbeautifier.javascript.beautifier \ --hidden-import=jsbeautifier.unpackers --hidden-import=jsbeautifier.unpackers.packer \ --hidden-import=jsbeautifier.unpackers.javascriptobfuscator \ --hidden-import=jsbeautifier.unpackers.myobfuscate \ --hidden-import=jsbeautifier.unpackers.urlencode \ --hidden-import=jsbeautifier.unpackers.meshim \ --hidden-import=editorconfig --hidden-import=editorconfig.handlers \ --hidden-import=six --hidden-import=pathvalidate \ --hidden-import=Cryptodome.Cipher --hidden-import=Cryptodome.Cipher.AES \ --hidden-import=Cryptodome.Util --hidden-import=Cryptodome.Util.Padding \ --hidden-import=Cryptodome.Random \ --hidden-import=telebot \ --additional-hooks-dir=pyinstaller/hooks \ --add-data "StreamingCommunity:StreamingCommunity" \ --name=StreamingCommunity_linux test_run.py - name: Build executable with PyInstaller (macOS) if: matrix.os == 'macos-latest' run: | pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator \ --hidden-import=qbittorrentapi --hidden-import=qbittorrent \ --hidden-import=bs4 --hidden-import=httpx --hidden-import=rich --hidden-import=tqdm \ --hidden-import=m3u8 --hidden-import=psutil --hidden-import=unidecode \ --hidden-import=jsbeautifier --hidden-import=jsbeautifier.core \ --hidden-import=jsbeautifier.javascript --hidden-import=jsbeautifier.javascript.beautifier \ --hidden-import=jsbeautifier.unpackers --hidden-import=jsbeautifier.unpackers.packer \ --hidden-import=jsbeautifier.unpackers.javascriptobfuscator \ --hidden-import=jsbeautifier.unpackers.myobfuscate \ --hidden-import=jsbeautifier.unpackers.urlencode \ --hidden-import=jsbeautifier.unpackers.meshim \ --hidden-import=editorconfig --hidden-import=editorconfig.handlers \ --hidden-import=six --hidden-import=pathvalidate \ --hidden-import=Cryptodome.Cipher --hidden-import=Cryptodome.Cipher.AES \ --hidden-import=Cryptodome.Util --hidden-import=Cryptodome.Util.Padding \ --hidden-import=Cryptodome.Random \ --hidden-import=telebot \ --additional-hooks-dir=pyinstaller/hooks \ --add-data "StreamingCommunity:StreamingCommunity" \ --name=StreamingCommunity_mac test_run.py - name: Upload executable (Windows) if: matrix.os == 'windows-latest' uses: actions/upload-artifact@v4 with: name: StreamingCommunity_win path: dist/StreamingCommunity_win.exe - name: Upload executable (Linux) if: matrix.os == 'ubuntu-latest' uses: actions/upload-artifact@v4 with: name: StreamingCommunity_linux path: dist/StreamingCommunity_linux - name: Upload executable (macOS) if: matrix.os == 'macos-latest' uses: actions/upload-artifact@v4 with: name: StreamingCommunity_mac path: dist/StreamingCommunity_mac - name: Create or update release uses: softprops/action-gh-release@v1 with: tag_name: ${{ env.latest_tag }} files: | dist/StreamingCommunity_win.exe dist/StreamingCommunity_linux dist/StreamingCommunity_mac env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}