|
1 | | -name: Create Release and build wheels |
| 1 | +name: Build Python Wheels |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | | - - '[0-9].*' |
| 6 | + - '\d+\.\d+\.[0-9a-z]+' |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + reason: |
| 11 | + description: 'Reason for running workflow' |
| 12 | + required: true |
7 | 13 |
|
8 | 14 | jobs: |
9 | | - do_release: |
10 | | - name: Create release and build manylinux wheels |
11 | | - runs-on: ubuntu-latest |
12 | | - |
| 15 | + build_wheels: |
| 16 | + name: Build Py3 Wheel on ${{ matrix.os }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest, macos-latest] |
| 21 | + |
13 | 22 | steps: |
14 | | - - name: Check out project |
| 23 | + |
| 24 | + - name: Log reason (manual run only) |
| 25 | + if: github.event_name == 'workflow_dispatch' |
| 26 | + run: | |
| 27 | + echo "Reason for triggering: ${{ github.event.inputs.reason }}" |
| 28 | +
|
| 29 | + - name: Check out |
15 | 30 | uses: actions/checkout@v2 |
16 | | - |
17 | | - - name: Get tag |
18 | | - id: get_tag |
19 | | - # strip 'refs/tags/' from ref, store in variable called VERSION |
20 | | - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
21 | | - |
22 | | - - name: Create Release |
23 | | - id: create_release |
24 | | - uses: actions/create-release@v1 |
25 | | - env: |
26 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
27 | 31 | with: |
28 | | - tag_name: ${{ steps.get_tag.outputs.VERSION }} # VERSION from get_tag step above |
29 | | - release_name: v${{ steps.get_tag.outputs.VERSION }} |
30 | | - draft: false |
31 | | - prerelease: true |
| 32 | + fetch-depth: 0 # unshallow fetch for setuptools-scm |
32 | 33 |
|
33 | | - - name: Set up Python |
34 | | - uses: actions/setup-python@v1 |
| 34 | + - name: Install Python 3.9 |
| 35 | + uses: actions/setup-python@v2 |
35 | 36 | with: |
36 | | - python-version: 3.7 |
| 37 | + python-version: '3.9' |
37 | 38 |
|
38 | | - - name: Install dependencies |
39 | | - run: | |
40 | | - python -m pip install --upgrade pip |
41 | | - pip install -r requirements.txt |
42 | | - pip install wheel setuptools_scm[toml]'>=3.4' |
43 | | - python setup.py download |
44 | | -
|
45 | | - - name: Build manylinux Python wheels |
46 | | - id: build_wheels |
47 | | - uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64 |
| 39 | + - name: Build wheel |
| 40 | + uses: pypa/cibuildwheel@v2.3.0 |
48 | 41 | with: |
49 | | - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39' |
50 | | - build-requirements: 'meson ninja' |
51 | | - system-packages: 'zlib-devel' |
52 | | - |
53 | | - - name: Attach wheel and sdist assets to release |
| 42 | + output-dir: dist |
54 | 43 | env: |
55 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-*" |
| 45 | + CIBW_ARCHS_MACOS: x86_64 universal2 |
| 46 | + CIBW_ARCHS_LINUX: x86_64 |
| 47 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 |
| 48 | + CIBW_SKIP: "*musllinux*" |
| 49 | + CIBW_BEFORE_ALL_LINUX: "yum install -y libuuid-devel" |
| 50 | + |
| 51 | + - name: Build sdist (Ubuntu only) |
| 52 | + if: matrix.os == 'ubuntu-latest' |
56 | 53 | run: | |
57 | | - mkdir -p dist |
58 | | - for audited in ./wheelhouse/*-manylinux*.whl; do |
59 | | - cp $audited dist |
60 | | - done |
61 | | - set -x |
62 | | - assets=() |
63 | | - for asset in ./dist/*; do |
64 | | - assets+=("-a" "$asset") |
65 | | - done |
66 | | - hub release edit "${assets[@]}" -m "${{ steps.get_tag.outputs.VERSION }}" "${{ steps.get_tag.outputs.VERSION }}" |
67 | | -
|
68 | | - do_mac_wheels: |
69 | | - needs: [do_release] |
70 | | - name: Build Mac wheels |
71 | | - runs-on: macos-latest |
72 | | - strategy: |
73 | | - matrix: |
74 | | - python-version: [3.6, 3.7, 3.8, 3.9] |
| 54 | + python setup.py sdist |
75 | 55 |
|
76 | | - steps: |
77 | | - - name: Check out project |
78 | | - uses: actions/checkout@v2 |
79 | | - |
80 | | - - name: Get tag |
81 | | - id: get_tag |
82 | | - # strip 'refs/tags/' from ref, store in variable called VERSION |
83 | | - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
84 | | - |
85 | | - - name: Set up Python ${{ matrix.python-version }} |
86 | | - uses: actions/setup-python@v1 |
| 56 | + - name: Upload build artifacts |
| 57 | + uses: actions/upload-artifact@v2 |
87 | 58 | with: |
88 | | - python-version: ${{ matrix.python-version }} |
| 59 | + name: wheelstorage |
| 60 | + path: ./dist/* |
| 61 | + if-no-files-found: error |
| 62 | + retention-days: 30 |
| 63 | + |
| 64 | + publish_release: |
| 65 | + name: Publish Release |
| 66 | + needs: build_wheels |
| 67 | + runs-on: ubuntu-latest |
89 | 68 |
|
90 | | - - name: Install dependencies, build wheels, and attach to release |
91 | | - env: |
92 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
93 | | - run: | |
94 | | - python -m pip install --upgrade pip |
95 | | - pip install -r requirements.txt |
96 | | - pip install wheel |
97 | | - python setup.py download |
98 | | - pip wheel . -w dist |
99 | | - for asset in ./dist/*.whl; do |
100 | | - assets+=("-a" "$asset") |
101 | | - done |
102 | | - hub release edit "${assets[@]}" -m "${{ steps.get_tag.outputs.VERSION }}" "${{ steps.get_tag.outputs.VERSION }}" |
103 | | -
|
104 | | - do_pypi_publish: |
105 | | - needs: [do_release, do_mac_wheels] # wait for the other jobs to complete |
106 | | - runs-on: ubuntu-latest # pypa/gh-action-pypi-publish only runs on Linux... |
107 | | - |
108 | 69 | steps: |
109 | | - - name: Check out project |
110 | | - uses: actions/checkout@v2 |
111 | | - |
112 | | - - name: Get tag |
113 | | - id: get_tag |
114 | | - # strip 'refs/tags/' from ref, store in variable called VERSION |
115 | | - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
116 | | - |
117 | | - - name: Set up Python 3.8 |
118 | | - uses: actions/setup-python@v1 |
119 | | - with: |
120 | | - python-version: 3.8 |
121 | 70 |
|
122 | | - - name: Build Python source tarball |
123 | | - # do this here, because we can't use the GitHub .tar.gz (no PKG-INFO) |
124 | | - # should go into 'dist' folder to be picked up when publishing to PyPI |
| 71 | + - name: Get date & flat tag |
| 72 | + id: date_tag |
125 | 73 | run: | |
126 | | - pip install wheel setuptools_scm[toml]'>=3.4' |
127 | | - python setup.py sdist |
| 74 | + export DATE=$(TZ=US/Pacific date +'%Y-%m-%d') |
| 75 | + echo $DATE |
| 76 | + export FLAT_TAG=$(echo ${GITHUB_REF##*/} | sed 's/\.//g') |
| 77 | + echo $FLAT_TAG |
| 78 | + echo ::set-output name=TODAY::$DATE |
| 79 | + echo ::set-output name=VERSION::$FLAT_TAG |
| 80 | + shell: bash |
128 | 81 |
|
129 | | - - name: Download .whl assets from release |
130 | | - env: |
131 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
132 | | - run: | |
133 | | - hub release download "${{ steps.get_tag.outputs.VERSION }}" |
134 | | - mkdir -p dist |
135 | | - cp *.whl dist # move .whl files to dist for publishing |
136 | | - |
137 | | - - name: Publish wheels to PyPI |
138 | | - uses: pypa/gh-action-pypi-publish@master |
| 82 | + - name: Download release assets |
| 83 | + uses: actions/download-artifact@v2 |
| 84 | + with: |
| 85 | + name: wheelstorage |
| 86 | + path: dist |
| 87 | + |
| 88 | + - name: Publish dist(s) to PyPI |
| 89 | + uses: pypa/gh-action-pypi-publish@release/v1 |
139 | 90 | with: |
140 | 91 | user: __token__ |
141 | 92 | password: ${{ secrets.pypi_password }} |
| 93 | + |
| 94 | + - name: Create GitHub Release |
| 95 | + uses: softprops/action-gh-release@v1 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + body: '{{ steps.date_tag.outputs.VERSION }}-released-${{ steps.date_tag.outputs.TODAY }}' |
| 100 | + prerelease: true |
| 101 | + files: ./dist/* |
0 commit comments