Merge pull request #46 from microsoft/work/paulli/py13 #66
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: Python Extension | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the main branch | |
| push: | |
| branches: [ main, 'work/**' ] | |
| tags: ["v*.*.*"] | |
| pull_request: | |
| branches: [ main, 'work/**' ] | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| build: | |
| # The type of runner that the job will run on | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools | |
| pip install cibuildwheel | |
| pip install cython | |
| - name: Build Wheels | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| - name: Upload Wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vttcompilepy-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| - name: Build Source Distribution | |
| run: python setup.py sdist --formats=gztar | |
| - name: Upload Source Distribution | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: source-dist | |
| path: ./dist/*.tar.gz | |
| overwrite: true | |
| deploy: | |
| needs: [build] | |
| # only run if the commit is tagged... | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| # ... and all build jobs completed successfully | |
| runs-on: ubuntu-latest | |
| # Added permission for OIDC authentication | |
| permissions: | |
| id-token: write | |
| # Define environment variables | |
| env: | |
| PYPI_UPLOAD_URL: https://pypi.org/project/vttcompilepy/ | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install --upgrade setuptools cython wheel twine | |
| - name: Build Source Distribution | |
| run: python setup.py sdist --formats=gztar | |
| - name: Upload Source Distribution | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: source-dist | |
| path: ./dist/*.tar.gz | |
| overwrite: true | |
| - name: Download artifacts from build jobs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: wheelhouse/ | |
| - name: Move wheels and source dist to dist/ directory | |
| run: | | |
| ls wheelhouse/* | |
| mkdir -p dist/ | |
| mv wheelhouse/source-dist/*.tar.gz dist/ | |
| for wheel_dir in wheelhouse/vttcompilepy*/; do | |
| mv "${wheel_dir}"/*.whl dist/ | |
| done | |
| - name: Publish distribution 📦 to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |