ci: add pypi publish #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Build | |
| # Add explicit permissions for the entire workflow | |
| permissions: | |
| contents: write | |
| discussions: write | |
| packages: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: 'pyproject.toml' | |
| cache: "poetry" | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| version: 2.0.0 | |
| - name: Install dependencies | |
| run: | | |
| poetry install --extras dev --no-interaction | |
| source $VENV | |
| - name: Build with PyInstaller | |
| run: | | |
| source $VENV | |
| poetry run pyinstaller ./async_rutube_downloader/run_ui.py --path ./async_rutube_downloader/ --clean --onefile --noconsole --add-data "locales:locales" | |
| - name: Rename binary for Windows | |
| if: matrix.os == 'windows-latest' | |
| run: mv dist/run_ui.exe dist/rutube_downloader.exe | |
| - name: Rename binary for Unix | |
| if: matrix.os == 'ubuntu-latest' | |
| run: mv dist/run_ui dist/rutube_downloader | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.os }} | |
| path: dist/rutube_downloader* | |
| retention-days: 1 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| binaries-*/rutube_downloader* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| tag_name: ${{ github.ref_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| version: 2.0.0 | |
| - name: Install dependencies | |
| run: | | |
| poetry install --extras dev --no-interaction | |
| source $VENV | |
| - name: Build | |
| run: poetry build | |
| - name: Publish | |
| env: | |
| POETRY_PYPI_TOKEN_ASYNC_RUTUBE_DOWNLOADER: ${{ secrets.POETRY_PYPI_TOKEN_ASYNC_RUTUBE_DOWNLOADER }} | |
| run: poetry publish |