Merge pull request #20 from basler/feature/Add_Release_CI #15
Workflow file for this run
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: Build and Test | |
| on: | |
| # Trigger the workflow on pushes to main and on version tags in the format X.Y.Z.* | |
| # and on pull requests to main | |
| push: | |
| branches: [main] | |
| tags: ["*.*.*"] | |
| pull_request: | |
| branches: [ main ] | |
| types: [ opened, synchronize, reopened ] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_release_build: ${{ env.RELEASE_BUILD == '1' }} | |
| steps: | |
| - name: Check for release build | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| echo "Build release for $GITHUB_REF" | |
| echo "RELEASE_BUILD=1" >> $GITHUB_ENV | |
| build: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event_name != 'pull_request' || | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build tools | |
| run: pip install build setuptools-scm | |
| - name: Build wheel | |
| run: python -m build --wheel | |
| - name: Upload wheel | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pypylon-contrib-wheel | |
| path: dist/*.whl | |
| - name: Upload Release Asset | |
| if: needs.setup.outputs.is_release_build == 'true' | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| files: dist/* | |
| - name: Publish package to PyPI | |
| if: needs.setup.outputs.is_release_build == 'true' && startsWith( matrix.p, 'manylinux' ) | |
| run: | | |
| sudo pip3 install twine | |
| python3 -m twine upload --non-interactive --skip-existing dist/* | |
| test: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ".[dev]" | |
| - name: Run tests | |
| run: | | |
| pytest tests | |
| lint: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [ "3.9", "3.10", "3.11", "3.12" ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ".[dev]" | |
| - name: Run pylint | |
| run: | | |
| pylint src --fail-under=10.0 | |
| - name: Run ruff | |
| run: | | |
| ruff check src --output-format=github | |