Skip to content

Commit d39ab42

Browse files
committed
Build wheels via cibuildwheel
1 parent 42865d6 commit d39ab42

File tree

1 file changed

+47
-97
lines changed

1 file changed

+47
-97
lines changed

.github/workflows/release.yml

Lines changed: 47 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -7,123 +7,73 @@ on:
77

88
jobs:
99

10-
Linux:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- uses: actions/checkout@v3
15-
- name: Get tag
16-
id: tag
17-
run: |
18-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
19-
- name: Building release
20-
run: |
21-
make linux_release
22-
- name: Upload distributions artifacts
23-
uses: actions/upload-artifact@v2
24-
with:
25-
name: pendulum-dist
26-
path: dist/wheelhouse
27-
28-
MacOS:
29-
runs-on: macos-latest
10+
build:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}-latest
3013
strategy:
3114
matrix:
32-
python-version: [3.7, 3.8, 3.9, "3.10"]
15+
os: [ ubuntu, windows, macos ]
3316

3417
steps:
35-
- uses: actions/checkout@v2
36-
- name: Get tag
37-
id: tag
38-
run: |
39-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
40-
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v2
42-
with:
43-
python-version: ${{ matrix.python-version }}
44-
- name: Install and set up Poetry
45-
run: |
46-
curl -fsS https://install.python-poetry.org | python - --preview -y
47-
- name: Build distributions
48-
run: |
49-
source $HOME/.poetry/env
50-
poetry build -vvv
51-
- name: Upload distribution artifacts
52-
uses: actions/upload-artifact@v2
53-
with:
54-
name: pendulum-dist
55-
path: dist
56-
57-
Windows:
58-
runs-on: windows-latest
59-
strategy:
60-
matrix:
61-
python-version: [3.7, 3.8, 3.9, "3.10"]
18+
- uses: actions/checkout@v3
6219

63-
steps:
64-
- uses: actions/checkout@v2
65-
- name: Get tag
66-
id: tag
67-
shell: bash
68-
run: |
69-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
70-
- name: Set up Python ${{ matrix.python-version }}
71-
uses: actions/setup-python@v2
72-
with:
73-
python-version: ${{ matrix.python-version }}
74-
- name: Install and setup Poetry
75-
run: |
76-
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - --preview -y
77-
- name: Build distributions
78-
run: |
79-
$env:Path += ";$env:Userprofile\.poetry\bin"
80-
poetry build -vvv
81-
- name: Upload distribution artifact
82-
uses: actions/upload-artifact@v2
83-
with:
84-
name: pendulum-dist
85-
path: dist
20+
- name: Build wheels
21+
uses: pypa/cibuildwheel@v2.10.1
22+
env:
23+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
24+
with:
25+
package-dir: .
26+
output-dir: dist
27+
28+
- uses: actions/upload-artifact@v3
29+
with:
30+
name: dist
31+
path: ./dist/*
8632

8733
Release:
88-
needs: [Linux, MacOS, Windows]
34+
needs: [ build-wheel ]
8935
runs-on: ubuntu-latest
9036

9137
steps:
9238
- name: Checkout code
9339
uses: actions/checkout@v2
94-
- name: Get tag
95-
id: tag
96-
run: |
97-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
98-
- name: Download distribution artifact
99-
uses: actions/download-artifact@master
40+
41+
- name: Download artifacts
42+
uses: actions/download-artifact@v3
10043
with:
101-
name: pendulum-dist
44+
name: dist
10245
path: dist
103-
- name: Install and set up Poetry
46+
47+
- name: Install Poetry
10448
run: |
105-
curl -fsS https://install.python-poetry.org | python - --preview -y
106-
- name: Set up cache
107-
uses: actions/cache@v2
108-
with:
109-
path: .venv
110-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
49+
curl -fsS https://install.python-poetry.org | python - -y
50+
51+
- name: Update PATH
52+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
53+
54+
- name: Build sdist
55+
run: poetry build --format sdist
56+
11157
- name: Check distributions
11258
run: |
11359
ls -la dist
60+
61+
- name: Check Version
62+
id: check-version
63+
run: |
64+
[[ "${GITHUB_REF#refs/tags/}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
65+
|| echo ::set-output name=prerelease::true
66+
67+
- name: Create Release
68+
uses: ncipollo/release-action@v1
69+
with:
70+
artifacts: "dist/*"
71+
token: ${{ secrets.GITHUB_TOKEN }}
72+
draft: false
73+
prerelease: steps.check-version.outputs.prerelease == 'true'
74+
11475
- name: Publish to PyPI
11576
env:
11677
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
11778
run: |
118-
source $HOME/.poetry/env
11979
poetry publish
120-
- name: Create Release
121-
id: create_release
122-
uses: actions/create-release@v1
123-
env:
124-
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
125-
with:
126-
tag_name: ${{ steps.tag.outputs.tag }}
127-
release_name: ${{ steps.tag.outputs.tag }}
128-
draft: false
129-
prerelease: false

0 commit comments

Comments
 (0)