Skip to content

Commit 1cb070f

Browse files
authored
Update conda_build.yml
1 parent 4717ca0 commit 1cb070f

1 file changed

Lines changed: 125 additions & 119 deletions

File tree

.github/workflows/conda_build.yml

Lines changed: 125 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -17,136 +17,142 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest, windows-latest, macos-latest]
1919
python-version: ['3.10', '3.11', '3.12']
20-
20+
21+
# --- THIS IS A CRITICAL FIX ---
22+
# This block tells GitHub to start a Redis container alongside your job.
23+
# The Conda build's TEST phase can now connect to this service.
2124
services:
2225
redis:
2326
image: redis
2427
ports:
2528
- 6379:6379
26-
29+
2730
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v4
30-
31-
- name: Setup Miniconda
32-
uses: conda-incubator/setup-miniconda@v3
33-
with:
34-
auto-update-conda: true
35-
python-version: ${{ matrix.python-version }}
36-
channels: conda-forge,defaults
37-
channel-priority: strict
38-
39-
- name: Install conda-build and anaconda-client
40-
shell: bash -l {0}
41-
run: |
42-
conda install conda-build anaconda-client -y
43-
44-
if [ "${{ github.event_name }}" == "release" ]; then
45-
VERSION="${{ github.event.release.tag_name }}"
46-
VERSION="${VERSION#v}"
47-
else
48-
VERSION="${{ github.event.inputs.version }}"
49-
fi
50-
51-
# --- WAIT FOR PYPI THEN DOWNLOAD ---
52-
max_attempts=10
53-
attempt=1
54-
url="https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
55-
56-
echo "Waiting for PyPI package to be available..."
57-
sleep 60 # Initial wait
58-
59-
while [ $attempt -le $max_attempts ]; do
60-
curl -L --fail -o "omnipkg-$VERSION.tar.gz" "$url"
61-
62-
if [ $? -eq 0 ]; then
63-
echo "✅ Download successful on attempt $attempt."
64-
break
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Miniconda
35+
uses: conda-incubator/setup-miniconda@v3
36+
with:
37+
auto-update-conda: true
38+
python-version: ${{ matrix.python-version }}
39+
channels: conda-forge,defaults
40+
channel-priority: strict
41+
42+
- name: Install conda-build and anaconda-client
43+
shell: bash -l {0}
44+
run: conda install conda-build anaconda-client -y
45+
46+
- name: Wait for PyPI, Download Source, and Update meta.yaml
47+
shell: bash -l {0}
48+
run: |
49+
if [ "${{ github.event_name }}" == "release" ]; then
50+
VERSION="${{ github.event.release.tag_name }}"
51+
VERSION="${VERSION#v}"
6552
else
66-
echo "⚠️ Attempt $attempt failed. Retrying in 30 seconds..."
53+
VERSION="${{ github.event.inputs.version }}"
54+
fi
55+
56+
# --- RESILIENT RETRY LOOP ---
57+
max_attempts=15
58+
attempt=1
59+
url="https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
60+
61+
echo "🔍 Waiting for PyPI package to be available at: $url"
62+
sleep 45 # Initial wait for PyPI to process the new release
63+
64+
while [ $attempt -le $max_attempts ]; do
65+
echo "🚀 Attempt $attempt of $max_attempts..."
66+
# Use curl with --fail to get a non-zero exit on 404
67+
if curl -L --fail --connect-timeout 20 -o "omnipkg-$VERSION.tar.gz" "$url"; then
68+
echo "✅ Successfully downloaded package!"
69+
break
70+
fi
71+
72+
if [ $attempt -eq $max_attempts ]; then
73+
echo "💥 FAILED: Package not available on PyPI after $max_attempts attempts."
74+
exit 1
75+
fi
76+
77+
echo "⚠️ PyPI not ready yet. Retrying in 30 seconds..."
6778
sleep 30
6879
attempt=$((attempt + 1))
69-
fi
70-
done
71-
72-
if [ $attempt -gt $max_attempts ]; then
73-
echo "❌ Failed to download source after $max_attempts attempts. Aborting."
74-
exit 1
75-
fi
76-
77-
# Calculate SHA256
78-
SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
79-
80-
# Update meta.yaml
81-
if [[ "$RUNNER_OS" == "macOS" ]]; then
82-
sed -i '' "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" omnipkg/conda-recipe/meta.yaml
83-
sed -i '' "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
84-
else
85-
sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" omnipkg/conda-recipe/meta.yaml
86-
sed -i "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
87-
fi
88-
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"
94-
95-
# Show updated meta.yaml
96-
echo "=== Updated meta.yaml ==="
97-
head -15 omnipkg/conda-recipe/meta.yaml
98-
99-
- name: Build conda package
100-
shell: bash -l {0}
101-
run: |
102-
conda build omnipkg/conda-recipe --output-folder ./conda-dist
103-
104-
- name: Upload to Anaconda Cloud
105-
shell: bash -l {0}
106-
run: |
107-
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload ./conda-dist/**/*.tar.bz2 --force
108-
env:
109-
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
80+
done
81+
82+
echo "🔐 Calculating SHA256 hash..."
83+
SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
84+
85+
echo "🔧 Updating meta.yaml..."
86+
# Use more robust sed patterns
87+
sed -i.bak "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" omnipkg/conda-recipe/meta.yaml
88+
sed -i.bak "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
89+
90+
echo "✅ Updated version to $VERSION with SHA256: $SHA256"
91+
echo "=== Updated meta.yaml snippet ==="
92+
head -n 5 omnipkg/conda-recipe/meta.yaml
93+
94+
- name: Build conda package
95+
shell: bash -l {0}
96+
# Point to the correct Redis host for the test phase
97+
run: |
98+
export REDIS_HOST=localhost
99+
conda build omnipkg/conda-recipe --output-folder ./conda-dist
110100
101+
- name: Upload to Anaconda Cloud
102+
shell: bash -l {0}
103+
run: |
104+
# Use a robust glob pattern that works on all OSes
105+
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload conda-dist/**/*.tar.bz2 --force
106+
env:
107+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
108+
109+
# --- THIS IS THE SECOND JOB, CORRECTLY PLACED ---
111110
update-feedstock:
112111
runs-on: ubuntu-latest
113112
if: github.event_name == 'release'
113+
needs: build-and-upload # Optional: wait for the main build to succeed
114114
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-
122-
- name: Setup Python
123-
uses: actions/setup-python@v4
124-
with:
125-
python-version: '3.11'
126-
127-
- name: Install dependencies
128-
run: |
129-
pip install pyyaml requests
130-
131-
- name: Update feedstock
132-
run: |
133-
cd feedstock
134-
VERSION="${{ github.event.release.tag_name }}"
135-
VERSION="${VERSION#v}"
136-
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())")
142-
143-
# Update recipe/meta.yaml
144-
sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
145-
sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
146-
147-
# Commit and push
148-
git config --local user.email "action@github.com"
149-
git config --local user.name "GitHub Action"
150-
git add recipe/meta.yaml
151-
git commit -m "Update to version $VERSION" || exit 0
152-
git push
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+
122+
- name: Update feedstock recipe
123+
shell: bash -l {0}
124+
run: |
125+
cd feedstock
126+
VERSION="${{ github.event.release.tag_name }}"
127+
VERSION="${VERSION#v}"
128+
129+
# --- USE THE SAME RESILIENT RETRY LOOP ---
130+
max_attempts=10
131+
attempt=1
132+
url="https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
133+
echo "🔍 Waiting for PyPI package for feedstock: $url"
134+
sleep 60
135+
while [ $attempt -le $max_attempts ]; do
136+
if curl -L --fail -o "omnipkg-$VERSION.tar.gz" "$url"; then break; fi
137+
if [ $attempt -eq $max_attempts ]; then exit 1; fi
138+
echo "Feedstock: PyPI not ready. Retrying in 30 seconds..."
139+
sleep 30; attempt=$((attempt + 1));
140+
done
141+
142+
SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
143+
144+
# Update recipe/meta.yaml
145+
sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
146+
sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
147+
148+
# Commit and push
149+
git config --local user.email "action@github.com"
150+
git config --local user.name "GitHub Action"
151+
git add recipe/meta.yaml
152+
# Only commit if there are actual changes
153+
if ! git diff --staged --quiet; then
154+
git commit -m "Update to version $VERSION"
155+
git push
156+
else
157+
echo "No changes to feedstock recipe."
158+
fi

0 commit comments

Comments
 (0)