aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/pip.yml
blob: 4414a12ee467d53de3e32e262770d973d8acbac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Pip

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
    - master
    - stable
    - v*
  release:
    types:
    - published

jobs:
  # This builds the sdists and wheels and makes sure the files are exactly as
  # expected. Using Windows and Python 2.7, since that is often the most
  # challenging matrix element.
  test-packaging:
    name: 🐍 2.7 • 📦 tests • windows-latest
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup 🐍 2.7
      uses: actions/setup-python@v2
      with:
        python-version: 2.7

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt --prefer-binary

    - name: Python Packaging tests
      run: pytest tests/extra_python_package/


  # This runs the packaging tests and also builds and saves the packages as
  # artifacts.
  packaging:
    name: 🐍 3.8 • 📦 & 📦 tests • ubuntu-latest
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup 🐍 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt build twine --prefer-binary

    - name: Python Packaging tests
      run: pytest tests/extra_python_package/

    - name: Build SDist and wheels
      run: |
        python -m build
        PYBIND11_GLOBAL_SDIST=1 python -m build

    - name: Check metadata
      run: twine check dist/*

    - name: Save standard package
      uses: actions/upload-artifact@v2
      with:
        name: standard
        path: dist/pybind11-*

    - name: Save global package
      uses: actions/upload-artifact@v2
      with:
        name: global
        path: dist/pybind11_global-*



  # When a GitHub release is made, upload the artifacts to PyPI
  upload:
    name: Upload to PyPI
    runs-on: ubuntu-latest
    if: github.event_name == 'release' && github.event.action == 'published'
    needs: [packaging]

    steps:
    - uses: actions/setup-python@v2

    # Downloads all to directories matching the artifact names
    - uses: actions/download-artifact@v2

    - name: Publish standard package
      uses: pypa/gh-action-pypi-publish@v1.4.1
      with:
        password: ${{ secrets.pypi_password }}
        packages_dir: standard/

    - name: Publish global package
      uses: pypa/gh-action-pypi-publish@v1.4.1
      with:
        password: ${{ secrets.pypi_password_global }}
        packages_dir: global/