File size: 2,392 Bytes
3040ac4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: PyPI Release
on:
  release:
    types: [published]

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        platform: [ubuntu-latest]
        python-version: ["3.9", "3.10", "3.11"]

    runs-on: ${{ matrix.platform }}
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive

    - uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Upgrade setuptools and wheel
      run: |
        pip install --upgrade setuptools wheel

    - name: Install dependencies on Ubuntu
      if: runner.os == 'Linux'
      run: |
        sudo apt-get update
        sudo apt-get install libopencv-dev -y

    - name: Install dependencies on macOS
      if: runner.os == 'macOS'
      run: |
        brew update
        brew install opencv

    - name: Install dependencies on Windows
      if: runner.os == 'Windows'
      run: |
        choco install opencv -y

    - name: Add requirements
      run: python -m pip install --upgrade setuptools wheel build

    - name: Install Python dependencies
      run: |
        pip install pytest
        pip install -r requirements.txt
        sudo apt-get update && sudo apt-get install ffmpeg libsm6 libxext6 -y

    - name: Build source distribution
      run: |
        python -m build --outdir dist/
        ls -lh dist/

    - name: Upload to GitHub Release
      if: matrix.python-version == '3.10' && github.event_name == 'release'
      uses: softprops/action-gh-release@v2
      with:
        files: dist/*.whl
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Archive wheels
      if: matrix.python-version == '3.10' && github.event_name == 'release'
      uses: actions/upload-artifact@v4
      with:
        name: dist
        path: dist/*.whl


  pypi-publish:
    name: upload release to PyPI
    needs: build
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      # IMPORTANT: this permission is mandatory for Trusted Publishing
      id-token: write
    steps:
      # retrieve your distributions here
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist

      - name: List dist directory
        run: ls -lh dist/

      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1