@@ -18,18 +18,11 @@ jobs:
1818 os : [ubuntu-latest, windows-latest, macos-latest]
1919 python-version : ['3.10', '3.11', '3.12']
2020
21- # Services should be at job level, not under strategy
2221 services :
2322 redis :
2423 image : redis
2524 ports :
2625 - 6379:6379
27- # Add health check for Redis
28- options : >-
29- --health-cmd "redis-cli ping"
30- --health-interval 10s
31- --health-timeout 5s
32- --health-retries 3
3326
3427 steps :
3528 - name : Checkout code
@@ -47,86 +40,44 @@ jobs:
4740 shell : bash -l {0}
4841 run : |
4942 conda install conda-build anaconda-client -y
50-
51- - name : Prepare package metadata
52- shell : bash -l {0}
53- run : |
54- # Determine version based on trigger event
43+
5544 if [ "${{ github.event_name }}" == "release" ]; then
5645 VERSION="${{ github.event.release.tag_name }}"
57- VERSION="${VERSION#v}" # Remove 'v' prefix if present
46+ VERSION="${VERSION#v}"
5847 else
5948 VERSION="${{ github.event.inputs.version }}"
6049 fi
6150
62- echo "Building version: $VERSION"
63- echo "VERSION=$VERSION" >> $GITHUB_ENV
64-
65- # Resilient download with retry logic
51+ # --- WAIT FOR PYPI THEN DOWNLOAD ---
6652 max_attempts=10
6753 attempt=1
6854 url="https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
6955
70- echo "Attempting to download source from $url..."
56+ echo "Waiting for PyPI package to be available..."
57+ sleep 60 # Initial wait
7158
7259 while [ $attempt -le $max_attempts ]; do
73- echo "Attempt $attempt of $max_attempts... "
60+ curl -L --fail -o "omnipkg-$VERSION.tar.gz" "$url "
7461
75- if curl -L --fail --connect-timeout 30 --max-time 300 -o "omnipkg-$VERSION.tar.gz" "$url" ; then
76- echo "✅ Download successful on attempt $attempt"
62+ if [ $? -eq 0 ] ; then
63+ echo "✅ Download successful on attempt $attempt. "
7764 break
7865 else
79- echo "⚠️ Attempt $attempt failed. PyPI might not be ready yet."
80- if [ $attempt -lt $max_attempts ]; then
81- echo "Retrying in 30 seconds..."
82- sleep 30
83- fi
66+ echo "⚠️ Attempt $attempt failed. Retrying in 30 seconds..."
67+ sleep 30
8468 attempt=$((attempt + 1))
8569 fi
8670 done
8771
8872 if [ $attempt -gt $max_attempts ]; then
89- echo "❌ Failed to download source after $max_attempts attempts"
90- exit 1
91- fi
92-
93- # Verify file was downloaded and calculate SHA256
94- if [ ! -f "omnipkg-$VERSION.tar.gz" ]; then
95- echo "❌ Downloaded file not found"
96- exit 1
97- fi
98-
99- file_size=$(wc -c < "omnipkg-$VERSION.tar.gz")
100- echo "Downloaded file size: $file_size bytes"
101-
102- if [ "$file_size" -lt 1000 ]; then
103- echo "❌ Downloaded file seems too small, might be an error page"
73+ echo "❌ Failed to download source after $max_attempts attempts. Aborting."
10474 exit 1
10575 fi
10676
107- # Calculate SHA256 using Python for cross-platform compatibility
108- echo "Calculating SHA256 hash..."
109- SHA256=$(python -c "
110- import hashlib
111- with open('omnipkg-$VERSION.tar.gz', 'rb') as f:
112- content = f.read()
113- print(hashlib.sha256(content).hexdigest())
114- ")
115-
116- echo "SHA256: $SHA256"
117- echo "SHA256=$SHA256" >> $GITHUB_ENV
118-
119- # Clean up downloaded file
120- rm "omnipkg-$VERSION.tar.gz"
121-
122- - name : Update conda recipe
123- shell : bash -l {0}
124- run : |
125- # Create recipe directory if it doesn't exist
126- mkdir -p omnipkg/conda-recipe
77+ # Calculate SHA256
78+ SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
12779
128- # Update meta.yaml with version and hash
129- # Handle different sed syntax for macOS vs Linux
80+ # Update meta.yaml
13081 if [[ "$RUNNER_OS" == "macOS" ]]; then
13182 sed -i '' "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" omnipkg/conda-recipe/meta.yaml
13283 sed -i '' "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
@@ -135,125 +86,67 @@ jobs:
13586 sed -i "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
13687 fi
13788
138- echo "Updated meta.yaml with version $VERSION and SHA256 $SHA256"
89+ echo "Updated version to $VERSION with SHA256: $SHA256"
90+ echo "VERSION=$VERSION" >> $GITHUB_ENV
91+
92+ # Clean up
93+ rm "omnipkg-$VERSION.tar.gz"
13994
140- # Display updated meta.yaml for verification
141- echo "=== Updated meta.yaml content ==="
142- head -20 omnipkg/conda-recipe/meta.yaml || echo "meta.yaml not found or empty"
95+ # Show updated meta.yaml
96+ echo "=== Updated meta.yaml ==="
97+ head -15 omnipkg/conda-recipe/meta.yaml
14398
14499 - name : Build conda package
145100 shell : bash -l {0}
146101 run : |
147- # Create output directory
148- mkdir -p ./conda-dist
149-
150- # Build the package
151- echo "Building conda package..."
152102 conda build omnipkg/conda-recipe --output-folder ./conda-dist
153-
154- # List built packages for verification
155- echo "=== Built packages ==="
156- find ./conda-dist -name "*.tar.bz2" -o -name "*.conda" | head -10
157103
158104 - name : Upload to Anaconda Cloud
159105 shell : bash -l {0}
160106 run : |
161- # Find all built packages
162- packages=$(find ./conda-dist -name "*.tar.bz2" -o -name "*.conda")
163-
164- if [ -z "$packages" ]; then
165- echo "❌ No conda packages found to upload"
166- exit 1
167- fi
168-
169- echo "Uploading packages to Anaconda Cloud..."
170- for package in $packages; do
171- echo "Uploading: $package"
172- anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload "$package" --force
173- done
107+ anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload ./conda-dist/**/*.tar.bz2 --force
174108 env :
175109 ANACONDA_TOKEN : ${{ secrets.ANACONDA_TOKEN }}
176110
177- # Separate job for conda-forge feedstock update
178111 update-feedstock :
179112 runs-on : ubuntu-latest
180113 if : github.event_name == 'release'
181- needs : build-and-upload # Wait for main build to complete
182-
183114 steps :
115+ - name : Checkout feedstock
116+ uses : actions/checkout@v4
117+ with :
118+ repository : conda-forge/omnipkg-feedstock
119+ token : ${{ secrets.FEEDSTOCK_TOKEN }}
120+ path : feedstock
121+
184122 - name : Setup Python
185123 uses : actions/setup-python@v4
186124 with :
187125 python-version : ' 3.11'
188126
189127 - name : Install dependencies
190128 run : |
191- pip install pyyaml requests packaging
192-
193- - name : Checkout feedstock
194- uses : actions/checkout@v4
195- with :
196- repository : conda-forge/omnipkg-feedstock
197- token : ${{ secrets.FEEDSTOCK_TOKEN }}
198- path : feedstock
129+ pip install pyyaml requests
199130
200- - name : Update feedstock recipe
131+ - name : Update feedstock
201132 run : |
202133 cd feedstock
203-
204- # Extract version from release tag
205134 VERSION="${{ github.event.release.tag_name }}"
206- VERSION="${VERSION#v}" # Remove 'v' prefix if present
207-
208- echo "Updating feedstock to version $VERSION"
135+ VERSION="${VERSION#v}"
209136
210- # Download source package to get SHA256
211- echo "Downloading source package..."
212- curl -L --fail --connect-timeout 30 --max-time 300 \
213- -o "omnipkg-$VERSION.tar.gz" \
214- "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
215-
216- # Calculate SHA256
217- SHA256=$(python -c "
218- import hashlib
219- with open('omnipkg-$VERSION.tar.gz', 'rb') as f:
220- content = f.read()
221- print(hashlib.sha256(content).hexdigest())
222- ")
223-
224- echo "Version: $VERSION"
225- echo "SHA256: $SHA256"
137+ # Wait and download
138+ echo "Waiting for PyPI..."
139+ sleep 60
140+ curl -L -o "omnipkg-$VERSION.tar.gz" "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
141+ SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
226142
227143 # Update recipe/meta.yaml
228- if [ -f "recipe/meta.yaml" ]; then
229- sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
230- sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
231-
232- echo "=== Updated recipe/meta.yaml ==="
233- head -20 recipe/meta.yaml
234- else
235- echo "❌ recipe/meta.yaml not found"
236- exit 1
237- fi
144+ sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
145+ sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
238146
239- # Clean up downloaded file
240- rm "omnipkg-$VERSION.tar.gz"
241-
242- - name : Commit and push changes
243- run : |
244- cd feedstock
245-
246- # Configure git
147+ # Commit and push
247148 git config --local user.email "action@github.com"
248149 git config --local user.name "GitHub Action"
249-
250- # Check if there are changes to commit
251- if git diff --quiet recipe/meta.yaml; then
252- echo "No changes to commit"
253- exit 0
254- fi
255-
256- # Commit and push changes
257150 git add recipe/meta.yaml
258- git commit -m "Update to version ${{ github.event.release.tag_name }}"
151+ git commit -m "Update to version $VERSION" || exit 0
259152 git push
0 commit comments