|
| 1 | +name: 'Test and Release PyDSDL' |
| 2 | +on: push |
| 3 | + |
| 4 | +# Ensures that only one workflow is running at a time |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow_sha }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +jobs: |
| 10 | + pydsdl-test: |
| 11 | + name: Test PyDSDL |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [ ubuntu-latest, macos-latest ] |
| 16 | + python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] |
| 17 | + include: |
| 18 | + - os: windows-2019 |
| 19 | + python: '3.10' |
| 20 | + - os: macos-latest |
| 21 | + python: '3.9' |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - name: Check out pydsdl |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Check out public_regulated_data_types |
| 28 | + uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + repository: OpenCyphal/public_regulated_data_types |
| 31 | + path: .dsdl-test |
| 32 | + |
| 33 | + - name: Install Python3 |
| 34 | + uses: actions/setup-python@v4 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python }} |
| 37 | + |
| 38 | + - name: Log Python version |
| 39 | + run: python --version |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: | |
| 43 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 44 | + sudo apt-get --ignore-missing update || true |
| 45 | + sudo apt-get install -y linux-*-extra-$(uname -r) graphviz |
| 46 | + fi |
| 47 | + python -m pip install --upgrade pip setuptools nox typed_ast |
| 48 | + shell: bash |
| 49 | + |
| 50 | + - name: Run build and test |
| 51 | + run: | |
| 52 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 53 | + nox --non-interactive --error-on-missing-interpreters --session test test_eol pristine lint --python ${{ matrix.python }} |
| 54 | + nox --non-interactive --session docs |
| 55 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 56 | + nox --forcecolor --non-interactive --error-on-missing-interpreters --session test test_eol pristine lint |
| 57 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 58 | + nox --non-interactive --error-on-missing-interpreters --session test test_eol pristine lint --python ${{ matrix.python }} |
| 59 | + else |
| 60 | + echo "${{ runner.os }} not supported" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | + python -c "import pydsdl; pydsdl.read_namespace('.dsdl-test/uavcan', [])" |
| 64 | + shell: bash |
| 65 | + |
| 66 | + pydsdl-release: |
| 67 | + name: Release PyDSDL |
| 68 | + if: contains(github.event.head_commit.message, '#release') || contains(github.ref, '/master') |
| 69 | + needs: pydsdl-test |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Check out |
| 73 | + uses: actions/checkout@v3 |
| 74 | + |
| 75 | + - name: Build distribution |
| 76 | + run: | |
| 77 | + python -m pip install --upgrade pip setuptools wheel twine |
| 78 | + python setup.py sdist bdist_wheel |
| 79 | +
|
| 80 | + - name: Get release version |
| 81 | + run: echo "pydsdl_version=$(python3 -c 'import pydsdl; print(pydsdl.__version__)')" >> $GITHUB_ENV |
| 82 | + |
| 83 | + - name: Upload distribution |
| 84 | + run: | |
| 85 | + python -m twine upload dist/* |
| 86 | + env: |
| 87 | + TWINE_USERNAME: __token__ |
| 88 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN_PYDSDL }} |
| 89 | + |
| 90 | + - name: Push version tag |
| 91 | + uses: mathieudutour/[email protected] |
| 92 | + with: |
| 93 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + custom_tag: ${{ env.pydsdl_version }} |
| 95 | + tag_prefix: '' |
0 commit comments