| 1 |
name: Deploy to PyPI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
tags: |
| 6 |
- v* |
| 7 |
|
| 8 |
jobs: |
| 9 |
build_wheels: |
| 10 |
name: Build wheels on ${{ matrix.os }} |
| 11 |
runs-on: ${{ matrix.os }} |
| 12 |
strategy: |
| 13 |
matrix: |
| 14 |
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ] |
| 15 |
|
| 16 |
steps: |
| 17 |
- name: Checkout repo |
| 18 |
uses: actions/checkout@v4 |
| 19 |
|
| 20 |
- uses: actions/setup-python@v5 |
| 21 |
name: Install Python |
| 22 |
with: |
| 23 |
python-version: '3.10' |
| 24 |
|
| 25 |
- name: Set up QEMU |
| 26 |
if: runner.os == 'Linux' |
| 27 |
uses: docker/setup-qemu-action@v3 |
| 28 |
with: |
| 29 |
platforms: all |
| 30 |
|
| 31 |
- name: Build wheels |
| 32 |
uses: pypa/[email protected] |
| 33 |
env: |
| 34 |
CIBW_TEST_COMMAND: "python -VV && python -m unittest discover -f -s {project}/tests/test_unit/" |
| 35 |
CIBW_TEST_EXTRAS: "full" |
| 36 |
CIBW_SKIP: "pp* cp27-* cp33-* cp34-* cp35-* cp36-* cp37-* cp38-* *-win32 *-musllinux_* *-manylinux_i686" |
| 37 |
CIBW_ARCHS_MACOS: x86_64 arm64 universal2 |
| 38 |
CIBW_ARCHS_LINUX: auto aarch64 |
| 39 |
|
| 40 |
- uses: actions/upload-artifact@v4 |
| 41 |
with: |
| 42 |
path: ./wheelhouse/*.whl |
| 43 |
name: dist-${{ matrix.os }}-${{ matrix.python-version }} |
| 44 |
|
| 45 |
build_sdist: |
| 46 |
name: Build source distribution |
| 47 |
runs-on: ubuntu-latest |
| 48 |
steps: |
| 49 |
- uses: actions/checkout@v4 |
| 50 |
name: Checkout repo |
| 51 |
|
| 52 |
- uses: actions/setup-python@v5 |
| 53 |
name: Install Python |
| 54 |
with: |
| 55 |
python-version: '3.10' |
| 56 |
|
| 57 |
- name: Update setuptools and build |
| 58 |
run: pip install -U setuptools build |
| 59 |
|
| 60 |
- name: Build sdist |
| 61 |
run: python -m build --sdist |
| 62 |
|
| 63 |
- uses: actions/upload-artifact@v4 |
| 64 |
with: |
| 65 |
path: dist/*.tar.gz |
| 66 |
name: dist-source |
| 67 |
|
| 68 |
upload_testpypi: |
| 69 |
needs: [build_wheels, build_sdist] |
| 70 |
runs-on: ubuntu-latest |
| 71 |
|
| 72 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && contains(github.event.ref, '-rc.') |
| 73 |
|
| 74 |
environment: |
| 75 |
name: testpypi |
| 76 |
url: https://test.pypi.org/p/clevercsv |
| 77 |
|
| 78 |
permissions: |
| 79 |
id-token: write |
| 80 |
|
| 81 |
steps: |
| 82 |
- name: Download all the dists |
| 83 |
uses: actions/download-artifact@v4 |
| 84 |
with: |
| 85 |
pattern: dist-* |
| 86 |
merge-multiple: true |
| 87 |
path: dist/ |
| 88 |
|
| 89 |
- name: Publish distribution to TestPyPI |
| 90 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 91 |
with: |
| 92 |
repository-url: https://test.pypi.org/legacy/ |
| 93 |
verbose: true |
| 94 |
|
| 95 |
upload_pypi: |
| 96 |
needs: [build_wheels, build_sdist] |
| 97 |
runs-on: ubuntu-latest |
| 98 |
|
| 99 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && !contains(github.event.ref, '-rc.') |
| 100 |
|
| 101 |
environment: |
| 102 |
name: pypi |
| 103 |
url: https://pypi.org/p/clevercsv |
| 104 |
|
| 105 |
permissions: |
| 106 |
id-token: write |
| 107 |
|
| 108 |
steps: |
| 109 |
- name: Download all the dists |
| 110 |
uses: actions/download-artifact@v4 |
| 111 |
with: |
| 112 |
pattern: dist-* |
| 113 |
merge-multiple: true |
| 114 |
path: dist/ |
| 115 |
|
| 116 |
- name: Publish distribution to PyPI |
| 117 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 118 |
with: |
| 119 |
verbose: true |
| 120 |
|
| 121 |
github-release: |
| 122 |
name: >- |
| 123 |
Sign the Python 🐍 distribution 📦 with Sigstore |
| 124 |
and upload the files to GitHub Release |
| 125 |
needs: |
| 126 |
- upload_pypi |
| 127 |
runs-on: ubuntu-latest |
| 128 |
|
| 129 |
permissions: |
| 130 |
contents: write |
| 131 |
id-token: write |
| 132 |
|
| 133 |
steps: |
| 134 |
- name: Checkout repo |
| 135 |
uses: actions/checkout@v4 |
| 136 |
|
| 137 |
- name: Download all the dists |
| 138 |
uses: actions/download-artifact@v4 |
| 139 |
with: |
| 140 |
pattern: dist-* |
| 141 |
merge-multiple: true |
| 142 |
path: dist/ |
| 143 |
|
| 144 |
- name: Sign the dists with Sigstore |
| 145 |
uses: sigstore/[email protected] |
| 146 |
with: |
| 147 |
inputs: >- |
| 148 |
./dist/*.tar.gz |
| 149 |
./dist/*.whl |
| 150 |
|
| 151 |
- name: Create GitHub Release |
| 152 |
env: |
| 153 |
GITHUB_TOKEN: ${{ github.token }} |
| 154 |
run: >- |
| 155 |
gh release create |
| 156 |
'${{ github.ref_name }}' |
| 157 |
--notes "" |
| 158 |
|
| 159 |
- name: Upload artifact signatures to GitHub Release |
| 160 |
env: |
| 161 |
GITHUB_TOKEN: ${{ github.token }} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
run: >- |
| 166 |
gh release upload |
| 167 |
'${{ github.ref_name }}' dist/** |
| 168 |
--repo '${{ github.repository }}' |