Skip to content

Commit 002403a

Browse files
committed
Combine artifacts for pypi upload
1 parent b8b018a commit 002403a

2 files changed

Lines changed: 193 additions & 0 deletions

File tree

.github/workflows/python-release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,69 @@ jobs:
287287
with:
288288
name: wheel-quantum-pecos
289289
path: python/quantum-pecos/dist/*.whl
290+
291+
collect_artifacts:
292+
needs: [build_wheels_pecos_rslib, build_sdist_quantum_pecos, build_wheels_quantum_pecos, test_abi3_wheels]
293+
runs-on: ubuntu-latest
294+
steps:
295+
- name: Create distribution directories
296+
run: |
297+
mkdir -p dist/pecos-rslib
298+
mkdir -p dist/quantum-pecos
299+
300+
# Download artifacts into temp directory first
301+
- name: Download all artifacts
302+
uses: actions/download-artifact@v4
303+
with:
304+
path: temp-artifacts/
305+
306+
- name: Organize distribution files
307+
run: |
308+
# Debug: Show what we downloaded
309+
echo "=== Downloaded artifacts structure ==="
310+
ls -la temp-artifacts/
311+
312+
# Move pecos-rslib wheels to distribution directory
313+
for artifact in temp-artifacts/wheel-pecos-rslib-*/; do
314+
if [ -d "$artifact" ]; then
315+
echo "Processing $artifact"
316+
mv "$artifact"*.whl dist/pecos-rslib/ 2>/dev/null || true
317+
fi
318+
done
319+
320+
# Move quantum-pecos files to distribution directory
321+
for artifact in temp-artifacts/*-quantum-pecos*/; do
322+
if [ -d "$artifact" ]; then
323+
echo "Processing $artifact"
324+
mv "$artifact"*.whl dist/quantum-pecos/ 2>/dev/null || true
325+
mv "$artifact"*.tar.gz dist/quantum-pecos/ 2>/dev/null || true
326+
fi
327+
done
328+
329+
# Clean up
330+
rm -rf temp-artifacts
331+
332+
- name: List all collected artifacts
333+
run: |
334+
echo "=== pecos-rslib artifacts ==="
335+
ls -la dist/pecos-rslib/
336+
echo ""
337+
echo "=== quantum-pecos artifacts ==="
338+
ls -la dist/quantum-pecos/
339+
echo ""
340+
echo "=== Summary ==="
341+
echo "pecos-rslib wheels: $(ls -1 dist/pecos-rslib/*.whl 2>/dev/null | wc -l)"
342+
echo "quantum-pecos distributions: $(ls -1 dist/quantum-pecos/* 2>/dev/null | wc -l)"
343+
344+
- name: Create release bundle
345+
run: |
346+
# Create a single zip containing both package directories
347+
zip -r pecos-distribution.zip dist/
348+
echo "Created pecos-distribution.zip containing:"
349+
unzip -l pecos-distribution.zip | grep -E "(pecos-rslib|quantum-pecos)/"
350+
351+
- name: Upload distribution bundle
352+
uses: actions/upload-artifact@v4
353+
with:
354+
name: pecos-distribution
355+
path: pecos-distribution.zip

scripts/publish-wheels.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
# Script to help publish PECOS wheels to PyPI from GitHub Actions artifacts
3+
4+
set -e
5+
6+
# Colors for output
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m' # No Color
11+
12+
# Default values
13+
ZIP_FILE="pecos-distribution.zip"
14+
DRY_RUN=false
15+
PACKAGE=""
16+
17+
# Parse command line arguments
18+
while [[ $# -gt 0 ]]; do
19+
case $1 in
20+
-f|--file)
21+
ZIP_FILE="$2"
22+
shift 2
23+
;;
24+
-p|--package)
25+
PACKAGE="$2"
26+
shift 2
27+
;;
28+
--dry-run)
29+
DRY_RUN=true
30+
shift
31+
;;
32+
-h|--help)
33+
echo "Usage: $0 [OPTIONS]"
34+
echo ""
35+
echo "Options:"
36+
echo " -f, --file FILE Path to the distribution zip file (default: pecos-distribution.zip)"
37+
echo " -p, --package PKG Publish only specific package (pecos-rslib or quantum-pecos)"
38+
echo " --dry-run Show what would be uploaded without actually uploading"
39+
echo " -h, --help Show this help message"
40+
echo ""
41+
echo "Examples:"
42+
echo " $0 # Publish all packages"
43+
echo " $0 -p pecos-rslib # Publish only pecos-rslib"
44+
echo " $0 -p quantum-pecos --dry-run # Dry run for quantum-pecos"
45+
exit 0
46+
;;
47+
*)
48+
echo -e "${RED}Unknown option: $1${NC}"
49+
exit 1
50+
;;
51+
esac
52+
done
53+
54+
# Check if zip file exists
55+
if [ ! -f "$ZIP_FILE" ]; then
56+
echo -e "${RED}Error: Distribution file '$ZIP_FILE' not found!${NC}"
57+
echo "Please download the 'pecos-distribution' artifact from GitHub Actions."
58+
exit 1
59+
fi
60+
61+
# Check if twine is installed
62+
if ! command -v twine &> /dev/null; then
63+
echo -e "${RED}Error: twine is not installed!${NC}"
64+
echo "Install it with: pip install twine"
65+
exit 1
66+
fi
67+
68+
# Create temporary directory
69+
TEMP_DIR=$(mktemp -d)
70+
trap "rm -rf $TEMP_DIR" EXIT
71+
72+
echo -e "${GREEN}Extracting distribution bundle...${NC}"
73+
unzip -q "$ZIP_FILE" -d "$TEMP_DIR"
74+
75+
# Function to publish a package
76+
publish_package() {
77+
local package_name=$1
78+
local package_dir="$TEMP_DIR/dist/$package_name"
79+
80+
if [ ! -d "$package_dir" ]; then
81+
echo -e "${YELLOW}Warning: $package_name directory not found in distribution${NC}"
82+
return
83+
fi
84+
85+
local file_count=$(ls -1 "$package_dir" | wc -l)
86+
if [ "$file_count" -eq 0 ]; then
87+
echo -e "${YELLOW}Warning: No files found in $package_name directory${NC}"
88+
return
89+
fi
90+
91+
echo -e "\n${GREEN}=== Publishing $package_name ===${NC}"
92+
echo "Found $file_count distribution file(s):"
93+
ls -la "$package_dir"
94+
95+
if [ "$DRY_RUN" = true ]; then
96+
echo -e "\n${YELLOW}DRY RUN: Would upload the following files:${NC}"
97+
ls -1 "$package_dir"
98+
else
99+
echo -e "\n${GREEN}Uploading to PyPI...${NC}"
100+
read -p "Are you sure you want to upload $package_name to PyPI? (y/N) " -n 1 -r
101+
echo
102+
if [[ $REPLY =~ ^[Yy]$ ]]; then
103+
twine upload "$package_dir"/*
104+
echo -e "${GREEN}Successfully uploaded $package_name!${NC}"
105+
else
106+
echo -e "${YELLOW}Skipped uploading $package_name${NC}"
107+
fi
108+
fi
109+
}
110+
111+
# Main execution
112+
if [ -n "$PACKAGE" ]; then
113+
# Publish specific package
114+
if [[ "$PACKAGE" != "pecos-rslib" && "$PACKAGE" != "quantum-pecos" ]]; then
115+
echo -e "${RED}Error: Invalid package name '$PACKAGE'${NC}"
116+
echo "Valid options are: pecos-rslib, quantum-pecos"
117+
exit 1
118+
fi
119+
publish_package "$PACKAGE"
120+
else
121+
# Publish all packages
122+
echo -e "${GREEN}Publishing all PECOS packages${NC}"
123+
publish_package "pecos-rslib"
124+
publish_package "quantum-pecos"
125+
fi
126+
127+
echo -e "\n${GREEN}Done!${NC}"

0 commit comments

Comments
 (0)