|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 |
|
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 |
30 | 13 | strategy: |
31 | 14 | matrix: |
32 | | - python-version: [3.7, 3.8, 3.9, "3.10"] |
| 15 | + os: [ ubuntu, windows, macos ] |
33 | 16 |
|
34 | 17 | 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 |
62 | 19 |
|
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/* |
86 | 32 |
|
87 | 33 | Release: |
88 | | - needs: [Linux, MacOS, Windows] |
| 34 | + needs: [ build-wheel ] |
89 | 35 | runs-on: ubuntu-latest |
90 | 36 |
|
91 | 37 | steps: |
92 | 38 | - name: Checkout code |
93 | 39 | 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 |
100 | 43 | with: |
101 | | - name: pendulum-dist |
| 44 | + name: dist |
102 | 45 | path: dist |
103 | | - - name: Install and set up Poetry |
| 46 | + |
| 47 | + - name: Install Poetry |
104 | 48 | 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 | + |
111 | 57 | - name: Check distributions |
112 | 58 | run: | |
113 | 59 | 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 | + |
114 | 75 | - name: Publish to PyPI |
115 | 76 | env: |
116 | 77 | POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} |
117 | 78 | run: | |
118 | | - source $HOME/.poetry/env |
119 | 79 | 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