|
1 | | -name: Test |
| 1 | +name: Test-Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: ['master'] |
| 6 | + tags: |
| 7 | + - 'v*' # only publish when pushing version tags (e.g., v1.0.0) |
6 | 8 | pull_request: |
7 | 9 | workflow_dispatch: |
8 | 10 |
|
|
12 | 14 | timeout-minutes: 30 |
13 | 15 | strategy: |
14 | 16 | matrix: |
15 | | - python-version: ['3.10', '3.12'] |
| 17 | + python-version: ['3.10', '3.12', '3.13'] |
16 | 18 | os: ['ubuntu-latest', 'windows-latest'] |
17 | | - omc-version: ['stable'] |
| 19 | + omc-version: ['stable', 'nightly'] |
18 | 20 |
|
19 | 21 | steps: |
20 | 22 | - uses: actions/checkout@v5 |
|
27 | 29 |
|
28 | 30 | - name: Install dependencies |
29 | 31 | run: | |
30 | | - python -m pip install --upgrade pip |
| 32 | + python -m pip install --upgrade pip build setuptools wheel twine |
31 | 33 | pip install . pytest pytest-md pytest-emoji pre-commit |
32 | 34 |
|
33 | 35 | - name: Set timezone |
|
39 | 41 | run: 'pre-commit run --all-files' |
40 | 42 |
|
41 | 43 | - name: "Set up OpenModelica Compiler" |
42 | | - uses: OpenModelica/[email protected] |
| 44 | + uses: OpenModelica/[email protected].2 |
43 | 45 | with: |
44 | 46 | version: ${{ matrix.omc-version }} |
45 | 47 | packages: | |
|
52 | 54 | if: runner.os != 'Windows' |
53 | 55 | run: docker pull openmodelica/openmodelica:v1.25.0-minimal |
54 | 56 |
|
| 57 | + - name: Build wheel and sdist packages |
| 58 | + run: python -m build --wheel --sdist --outdir dist |
| 59 | + |
| 60 | + - name: Check twine |
| 61 | + run: python -m twine check dist/* |
| 62 | + |
55 | 63 | - name: Run pytest |
56 | 64 | uses: pavelzw/pytest-action@v2 |
57 | 65 | with: |
|
61 | 69 | custom-arguments: '-v ' |
62 | 70 | click-to-expand: true |
63 | 71 | report-title: 'Test Report' |
| 72 | + |
| 73 | + Publish: |
| 74 | + name: Publish to PyPI |
| 75 | + runs-on: ${{ matrix.os }} |
| 76 | + needs: test |
| 77 | + strategy: |
| 78 | + matrix: |
| 79 | + python-version: ['3.10'] |
| 80 | + os: ['ubuntu-latest'] |
| 81 | + if: startsWith(github.ref, 'refs/tags/') |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v5 |
| 84 | + |
| 85 | + - name: Set up Python ${{ matrix.python-version }} |
| 86 | + uses: actions/setup-python@v5 |
| 87 | + with: |
| 88 | + python-version: ${{ matrix.python-version }} |
| 89 | + architecture: 'x64' |
| 90 | + |
| 91 | + - name: Install dependencies |
| 92 | + run: | |
| 93 | + python -m pip install --upgrade pip build setuptools wheel twine |
| 94 | +
|
| 95 | + - name: Build wheel and sdist packages |
| 96 | + run: python -m build --wheel --sdist --outdir dist |
| 97 | + |
| 98 | + - name: Publish wheel and sdist packages to PyPI |
| 99 | + env: |
| 100 | + TWINE_USERNAME: __token__ |
| 101 | + TWINE_PASSWORD: ${{ secrets.PYPI_OMPYTHON_API_TOKEN }} |
| 102 | + run: | |
| 103 | + python -m twine upload dist/* --skip-existing |
0 commit comments