|
1 | | -name: "Build wheels for macOS (+optional release)" |
2 | | -# Hybrid approach: try to build with brew lzo, fall back to included sources |
| 1 | +name: "Build wheels for macOS" |
3 | 2 |
|
4 | 3 | on: |
5 | 4 | workflow_dispatch: |
6 | | - inputs: |
7 | | - tag: |
8 | | - description: > |
9 | | - Release tag — optional (e.g. v1.16). |
10 | | - Leave blank to build wheels only (no release will be created). |
11 | | - Existing tag → wheels are replaced on the existing release. |
12 | | - New tag → git tag is created from HEAD and a new release is published. |
13 | | - Format: vMAJOR.MINOR[.PATCH][-prerelease] |
14 | | - required: false |
15 | | - type: string |
16 | | - default: "" |
17 | | - publish_to_testpypi: |
18 | | - description: 'Publish wheels to TestPyPI' |
19 | | - type: boolean |
20 | | - default: false |
| 5 | + workflow_call: |
21 | 6 | push: |
22 | 7 | tags: |
23 | 8 | - v* |
24 | 9 |
|
25 | | -permissions: |
26 | | - contents: write # required to create tags, releases |
27 | | - |
28 | 10 | jobs: |
29 | | - # ─────────────────────────────────────────────────────────────────────────── |
30 | | - # VALIDATE INPUT |
31 | | - # ─────────────────────────────────────────────────────────────────────────── |
32 | | - validate-tag: |
33 | | - runs-on: ubuntu-latest |
34 | | - # Skip this job when the tag input is blank — no release |
35 | | - if: inputs.tag != '' |
36 | | - steps: |
37 | | - - name: Check tag format |
38 | | - run: | |
39 | | - TAG="${{ inputs.tag }}" |
40 | | - if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z0-9._-]+)?$ ]]; then |
41 | | - echo "::error::Tag '${TAG}' is not valid. Must match vMAJOR.MINOR[.PATCH][-prerelease]" |
42 | | - exit 1 |
43 | | - fi |
44 | | - echo "Tag '${TAG}' is valid." |
45 | | -
|
46 | | - # ─────────────────────────────────────────────────────────────────────────── |
47 | | - # BUILD |
48 | | - # ─────────────────────────────────────────────────────────────────────────── |
49 | 11 | build: |
50 | | - # When no tag is provided, validate-tag is skipped (result = 'skipped'), |
51 | | - needs: validate-tag |
52 | | - if: always() && (needs.validate-tag.result == 'success' || needs.validate-tag.result == 'skipped') |
53 | 12 | runs-on: ${{ matrix.os }} |
54 | 13 | strategy: |
55 | 14 | fail-fast: false |
56 | 15 | matrix: |
57 | 16 | python-version: |
58 | | -# - "3.8" |
59 | | -# - "3.9" |
60 | 17 | - "3.10" |
61 | 18 | - "3.11" |
62 | 19 | - "3.12" |
@@ -142,91 +99,3 @@ jobs: |
142 | 99 | name: wheel-py-${{ matrix.os }}-${{ matrix.python-version }} |
143 | 100 | path: dist/*.whl |
144 | 101 | if-no-files-found: error |
145 | | - |
146 | | - # ─────────────────────────────────────────────────────────────────────────── |
147 | | - # PUBLISH — collect wheels, tag if needed, make the release. |
148 | | - # Skip if no tag |
149 | | - # ─────────────────────────────────────────────────────────────────────────── |
150 | | - publish: |
151 | | - name: Publish GitHub release |
152 | | - needs: build |
153 | | - # Skip when tag is blank — build-only run, no release wanted. |
154 | | - if: always() && inputs.tag != '' && needs.build.result == 'success' |
155 | | - runs-on: ubuntu-latest |
156 | | - env: |
157 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
158 | | - TAG: ${{ inputs.tag }} |
159 | | - steps: |
160 | | - - name: Checkout repo |
161 | | - uses: actions/checkout@v6 |
162 | | - with: |
163 | | - # must fetch full history so a new tag can be created if it does not exist |
164 | | - fetch-depth: 0 |
165 | | - persist-credentials: true |
166 | | - |
167 | | - - name: Download all wheel artifacts |
168 | | - uses: actions/download-artifact@v7 |
169 | | - with: |
170 | | - pattern: wheel-py* |
171 | | - merge-multiple: true |
172 | | - path: dist/ |
173 | | - |
174 | | - - name: List wheels to publish |
175 | | - run: ls -lh dist/ |
176 | | - |
177 | | - - name: Create git tag if it does not exist |
178 | | - run: | |
179 | | - if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then |
180 | | - echo "Tag ${TAG} already exists — skipping tag creation." |
181 | | - else |
182 | | - echo "Tag ${TAG} does not exist — creating it from HEAD." |
183 | | - git config user.name "github-actions[bot]" |
184 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
185 | | - git tag -a "${TAG}" -m "Release ${TAG}" |
186 | | - git push origin "${TAG}" |
187 | | - echo "Tag ${TAG} pushed." |
188 | | - fi |
189 | | -
|
190 | | - - name: Create or update GitHub release |
191 | | - # gh release create → used when no release exists yet for this tag. |
192 | | - # • Automatically uses the tag that was pushed (or the existing one). |
193 | | - # • --generate-notes asks GitHub to auto-fill the release notes from |
194 | | - # commits since the previous release. |
195 | | - # |
196 | | - # gh release upload --clobber → used when a release already exists. |
197 | | - # • --clobber deletes any asset with the same filename before |
198 | | - # re-uploading, giving us idempotent replace semantics. |
199 | | - # • WARNING: gh documents that if the upload fails after --clobber, |
200 | | - # the original asset is gone. Acceptable here because we always |
201 | | - # have the artifact zip as a fallback. |
202 | | - run: | |
203 | | - if gh release view "${TAG}" > /dev/null 2>&1; then |
204 | | - echo "Release for ${TAG} already exists — replacing assets." |
205 | | - gh release upload "${TAG}" dist/*.whl --clobber |
206 | | - else |
207 | | - echo "No release for ${TAG} yet — creating release and uploading assets." |
208 | | - gh release create "${TAG}" dist/*.whl \ |
209 | | - --title "${TAG}" \ |
210 | | - --generate-notes |
211 | | - fi |
212 | | -
|
213 | | - publish-testpypi: |
214 | | - name: Publish to TestPyPI |
215 | | - needs: [build] |
216 | | - if: inputs.publish_to_testpypi && needs.build.result == 'success' |
217 | | - runs-on: ubuntu-latest |
218 | | - environment: |
219 | | - name: release |
220 | | - url: https://test.pypi.org/p/python-lzo |
221 | | - permissions: |
222 | | - id-token: write |
223 | | - steps: |
224 | | - - uses: actions/download-artifact@v6 |
225 | | - with: |
226 | | - path: dist |
227 | | - - run: | |
228 | | - mv dist/*/*.whl dist/ 2>/dev/null || true |
229 | | - find dist -mindepth 1 -type d -delete |
230 | | - - uses: pypa/gh-action-pypi-publish@release/v1 |
231 | | - with: |
232 | | - repository-url: https://test.pypi.org/legacy/ |
0 commit comments