Skip to content

Commit b0ec7d6

Browse files
authored
Merge pull request #105 from jd-boyd/jdb_testpypi_reorg_pub
Try to fix publishing to testpypi.
2 parents 6dee6dd + 392f34a commit b0ec7d6

4 files changed

Lines changed: 140 additions & 225 deletions

File tree

.github/workflows/build-linux.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ name: Build wheels for Linux
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
publish_to_testpypi:
7-
description: 'Publish wheels/sdist to TestPyPI'
8-
type: boolean
9-
default: false
5+
workflow_call:
106
push:
117
tags:
128
- v*
@@ -154,25 +150,3 @@ jobs:
154150
name: sdist
155151
path: dist/*.tar.gz
156152
if-no-files-found: error
157-
158-
publish-testpypi:
159-
name: Publish to TestPyPI
160-
needs: [build-wheels-native, build-wheels-aarch64, build-wheels-ppc64le, build-wheels-s390x, build-wheels-armv7l, sdist]
161-
if: inputs.publish_to_testpypi
162-
runs-on: ubuntu-latest
163-
environment:
164-
name: release
165-
url: https://test.pypi.org/p/python-lzo
166-
permissions:
167-
id-token: write
168-
steps:
169-
- uses: actions/download-artifact@v6
170-
with:
171-
path: dist
172-
- run: |
173-
mv dist/*/*.whl dist/ 2>/dev/null || true
174-
mv dist/*/*.tar.gz dist/ 2>/dev/null || true
175-
find dist -mindepth 1 -type d -delete
176-
- uses: pypa/gh-action-pypi-publish@release/v1
177-
with:
178-
repository-url: https://test.pypi.org/legacy/

.github/workflows/build-macos.yml

Lines changed: 2 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,19 @@
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"
32

43
on:
54
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:
216
push:
227
tags:
238
- v*
249

25-
permissions:
26-
contents: write # required to create tags, releases
27-
2810
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-
# ───────────────────────────────────────────────────────────────────────────
4911
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')
5312
runs-on: ${{ matrix.os }}
5413
strategy:
5514
fail-fast: false
5615
matrix:
5716
python-version:
58-
# - "3.8"
59-
# - "3.9"
6017
- "3.10"
6118
- "3.11"
6219
- "3.12"
@@ -142,91 +99,3 @@ jobs:
14299
name: wheel-py-${{ matrix.os }}-${{ matrix.python-version }}
143100
path: dist/*.whl
144101
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/
Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
name: Build/release wheels for Windows
1+
name: Build wheels for Windows
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
custom_ref:
7-
description: 'custom ref/tag'
8-
required: false
9-
do_release:
10-
description: 'Creating release from artifacts: type "y" to enable'
11-
required: false
12-
publish_to_testpypi:
13-
description: 'Publish wheels to TestPyPI'
14-
type: boolean
15-
default: false
5+
workflow_call:
166
push:
177
tags:
188
- v*
9+
1910
jobs:
2011
build:
2112
runs-on: ${{ matrix.os }}
@@ -55,56 +46,3 @@ jobs:
5546
path: dist\*.whl
5647
overwrite: true
5748
if-no-files-found: error
58-
59-
release:
60-
if: ${{ github.event.inputs.do_release == 'y' && github.event.inputs.custom_ref != '' }}
61-
needs: [build]
62-
runs-on: ubuntu-latest
63-
permissions:
64-
contents: write
65-
66-
env:
67-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68-
69-
steps:
70-
- name: Download artifacts
71-
uses: actions/download-artifact@v4
72-
with:
73-
path: ./artifacts
74-
merge-multiple: true
75-
76-
- name: List all files
77-
run: ls -R ./artifacts
78-
79-
- name: do release
80-
run: |
81-
gh release create '${{ github.event.inputs.custom_ref}}' \
82-
-t '${{ github.event.inputs.custom_ref}}' \
83-
--title "${{ github.event.repository.name }}-${{ github.event.inputs.custom_ref}}" \
84-
--target '${{ github.ref_name }}' \
85-
--latest=true \
86-
--generate-notes \
87-
--repo ${GITHUB_REPOSITORY}
88-
gh release upload '${{ github.event.inputs.custom_ref}}' --repo ${GITHUB_REPOSITORY} --clobber \
89-
./artifacts/*
90-
91-
publish-testpypi:
92-
name: Publish to TestPyPI
93-
needs: [build]
94-
if: inputs.publish_to_testpypi
95-
runs-on: ubuntu-latest
96-
environment:
97-
name: release
98-
url: https://test.pypi.org/p/python-lzo
99-
permissions:
100-
id-token: write
101-
steps:
102-
- uses: actions/download-artifact@v6
103-
with:
104-
path: dist
105-
- run: |
106-
mv dist/*/*.whl dist/ 2>/dev/null || true
107-
find dist -mindepth 1 -type d -delete
108-
- uses: pypa/gh-action-pypi-publish@release/v1
109-
with:
110-
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)