1111 type : string
1212
1313jobs :
14- # First job: Wait for PyPI to have the package
15- wait-for-pypi :
16- runs-on : ubuntu-latest
17- outputs :
18- version : ${{ steps.get-version.outputs.version }}
19- sha256 : ${{ steps.get-sha.outputs.sha256 }}
20- steps :
21- - name : Get version
22- id : get-version
23- run : |
24- if [ "${{ github.event_name }}" == "release" ]; then
25- VERSION="${{ github.event.release.tag_name }}"
26- VERSION="${VERSION#v}"
27- else
28- VERSION="${{ github.event.inputs.version }}"
29- fi
30- echo "version=$VERSION" >> $GITHUB_OUTPUT
31- echo "Waiting for version: $VERSION"
32-
33- - name : Wait for PyPI package availability
34- id : wait-pypi
35- run : |
36- VERSION="${{ steps.get-version.outputs.version }}"
37- MAX_ATTEMPTS=20
38- SLEEP_TIME=30
39-
40- echo "Checking for omnipkg version $VERSION on PyPI..."
41-
42- for i in $(seq 1 $MAX_ATTEMPTS); do
43- echo "Attempt $i/$MAX_ATTEMPTS..."
44-
45- # Check PyPI JSON API first (most reliable)
46- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
47- "https://pypi.org/pypi/omnipkg/$VERSION/json")
48-
49- if [ "$HTTP_CODE" = "200" ]; then
50- echo "✓ Package version found on PyPI API!"
51-
52- # Also verify the tar.gz file is downloadable
53- DOWNLOAD_URL="https://files.pythonhosted.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
54- DOWNLOAD_CODE=$(curl -s -o /dev/null -w "%{http_code}" -I "$DOWNLOAD_URL")
55-
56- if [ "$DOWNLOAD_CODE" = "200" ] || [ "$DOWNLOAD_CODE" = "302" ]; then
57- echo "✓ Package file is downloadable!"
58- break
59- else
60- echo "⚠ Package found in API but file not yet available (HTTP $DOWNLOAD_CODE)"
61- fi
62- else
63- echo "Package not yet available (HTTP $HTTP_CODE)"
64- fi
65-
66- if [ $i -eq $MAX_ATTEMPTS ]; then
67- echo "✗ Package not found after $MAX_ATTEMPTS attempts"
68- echo "Check: https://pypi.org/project/omnipkg/$VERSION/"
69- exit 1
70- fi
71-
72- echo "Waiting ${SLEEP_TIME}s..."
73- sleep $SLEEP_TIME
74- done
75-
76- - name : Download and calculate SHA256
77- id : get-sha
78- run : |
79- VERSION="${{ steps.get-version.outputs.version }}"
80-
81- echo "Downloading package from PyPI..."
82- # Try the files.pythonhosted.org URL first (CDN)
83- if ! curl -L -f -o "omnipkg-$VERSION.tar.gz" \
84- "https://files.pythonhosted.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"; then
85- # Fallback to pypi.org URL
86- echo "CDN failed, trying pypi.org..."
87- curl -L -f -o "omnipkg-$VERSION.tar.gz" \
88- "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
89- fi
90-
91- # Verify file size
92- FILE_SIZE=$(wc -c < "omnipkg-$VERSION.tar.gz")
93- echo "File size: $FILE_SIZE bytes"
94-
95- if [ "$FILE_SIZE" -lt 10000 ]; then
96- echo "Error: File too small ($FILE_SIZE bytes)"
97- exit 1
98- fi
99-
100- echo "Calculating SHA256..."
101- if command -v sha256sum &> /dev/null; then
102- SHA256=$(sha256sum "omnipkg-$VERSION.tar.gz" | cut -d' ' -f1)
103- elif command -v shasum &> /dev/null; then
104- SHA256=$(shasum -a 256 "omnipkg-$VERSION.tar.gz" | cut -d' ' -f1)
105- else
106- SHA256=$(python3 -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
107- fi
108-
109- echo "sha256=$SHA256" >> $GITHUB_OUTPUT
110- echo "SHA256: $SHA256"
111-
112- # Second job: Update conda-forge feedstock
113- update-feedstock :
114- needs : wait-for-pypi
115- runs-on : ubuntu-latest
116- if : github.event_name == 'release'
117- steps :
118- - name : Checkout your feedstock fork
119- uses : actions/checkout@v4
120- with :
121- repository : 1minds3t/omnipkg-feedstock
122- token : ${{ secrets.GITHUB_TOKEN }}
123- path : feedstock
124-
125- - name : Setup Python
126- uses : actions/setup-python@v5
127- with :
128- python-version : ' 3.11'
129-
130- - name : Update feedstock meta.yaml
131- run : |
132- cd feedstock
133- VERSION="${{ needs.wait-for-pypi.outputs.version }}"
134- SHA256="${{ needs.wait-for-pypi.outputs.sha256 }}"
135-
136- echo "Updating recipe/meta.yaml to version $VERSION with SHA256: $SHA256"
137-
138- # Update version and sha256 in meta.yaml
139- sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
140- sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
141-
142- # Show the changes
143- echo "=== Updated meta.yaml (first 30 lines) ==="
144- head -30 recipe/meta.yaml
145-
146- - name : Commit and push to fork
147- run : |
148- cd feedstock
149- VERSION="${{ needs.wait-for-pypi.outputs.version }}"
150-
151- git config --local user.email "action@github.com"
152- git config --local user.name "GitHub Action"
153- git add recipe/meta.yaml
154-
155- if git diff --staged --quiet; then
156- echo "No changes to commit"
157- else
158- git commit -m "Update omnipkg to version $VERSION"
159- git push
160- echo "✓ Changes pushed to fork"
161- fi
162-
163- - name : Create Pull Request to conda-forge
164- uses : peter-evans/create-pull-request@v5
165- with :
166- token : ${{ secrets.FEEDSTOCK_TOKEN }}
167- path : feedstock
168- commit-message : " Update omnipkg to version ${{ needs.wait-for-pypi.outputs.version }}"
169- title : " Update omnipkg to version ${{ needs.wait-for-pypi.outputs.version }}"
170- body : |
171- Automated update to omnipkg version ${{ needs.wait-for-pypi.outputs.version }}
172-
173- - Updated version in meta.yaml
174- - Updated SHA256 hash: ${{ needs.wait-for-pypi.outputs.sha256 }}
175-
176- Changes were automatically generated by GitHub Actions after PyPI release.
177- branch : " update-v${{ needs.wait-for-pypi.outputs.version }}"
178- base : main
179- push-to-fork : 1minds3t/omnipkg-feedstock
180-
181- # Third job: Build conda packages for your own channel
18214 build-and-upload :
183- needs : wait-for-pypi
18415 runs-on : ${{ matrix.os }}
18516 strategy :
18617 matrix :
@@ -203,14 +34,23 @@ jobs:
20334 shell : bash -l {0}
20435 run : |
20536 conda install conda-build anaconda-client -y
206-
20737 - name : Update meta.yaml version and hash
20838 shell : bash -l {0}
20939 run : |
210- VERSION="${{ needs.wait-for-pypi.outputs.version }}"
211- SHA256="${{ needs.wait-for-pypi.outputs.sha256 }}"
40+ if [ "${{ github.event_name }}" == "release" ]; then
41+ VERSION="${{ github.event.release.tag_name }}"
42+ VERSION="${VERSION#v}" # Remove 'v' prefix if present
43+ else
44+ VERSION="${{ github.event.inputs.version }}"
45+ fi
21246
213- echo "Using version $VERSION with SHA256: $SHA256"
47+ # Use curl for all platforms for consistency.
48+ echo "Downloading omnipkg version $VERSION..."
49+ curl -L -o "omnipkg-$VERSION.tar.gz" "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
50+
51+ # Use Python for a truly cross-platform SHA256 calculation.
52+ echo "Calculating SHA256 hash..."
53+ SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
21454
21555 # Update the version and sha256 in meta.yaml (cross-platform sed)
21656 if [[ "$RUNNER_OS" == "macOS" ]]; then
@@ -221,21 +61,67 @@ jobs:
22161 sed -i "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
22262 fi
22363
224- echo "Updated meta.yaml:"
64+ echo "Updated version to $VERSION with SHA256: $SHA256"
65+ echo "VERSION=$VERSION" >> $GITHUB_ENV
66+
67+ # Show the updated meta.yaml for debugging
68+ echo "=== Updated meta.yaml ==="
22569 head -15 omnipkg/conda-recipe/meta.yaml
226-
22770 - name : Build conda package
22871 shell : bash -l {0}
22972 run : |
23073 export PYTHONIOENCODING=UTF-8
23174 conda build omnipkg/conda-recipe --output-folder ./conda-dist
232-
23375 - name : Upload to Anaconda Cloud
23476 shell : bash -l {0}
23577 run : |
78+ # Upload both .conda and .tar.bz2 files (conda-build may produce either format)
79+ # Use find to locate the actual files and upload them
23680 find ./conda-dist -name "*.conda" -o -name "*.tar.bz2" | while read file; do
23781 echo "Uploading $file"
23882 anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload "$file" --force
23983 done
24084 env :
24185 ANACONDA_TOKEN : ${{ secrets.ANACONDA_TOKEN }}
86+
87+ # Alternative job for conda-forge feedstock update
88+ update-feedstock :
89+ runs-on : ubuntu-latest
90+ if : github.event_name == 'release'
91+ steps :
92+ - name : Checkout feedstock
93+ uses : actions/checkout@v4
94+ with :
95+ repository : conda-forge/omnipkg-feedstock
96+ token : ${{ secrets.FEEDSTOCK_TOKEN }}
97+ path : feedstock
98+
99+ - name : Setup Python
100+ uses : actions/setup-python@v4
101+ with :
102+ python-version : ' 3.11'
103+
104+ - name : Install dependencies
105+ run : |
106+ pip install pyyaml requests
107+ - name : Update feedstock
108+ run : |
109+ cd feedstock
110+ VERSION="${{ github.event.release.tag_name }}"
111+ VERSION="${VERSION#v}"
112+
113+ # Use curl and Python for consistency and reliability.
114+ echo "Downloading source to get SHA256..."
115+ curl -L -o "omnipkg-$VERSION.tar.gz" "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
116+ SHA256=$(python -c "import hashlib; print(hashlib.sha256(open('omnipkg-$VERSION.tar.gz', 'rb').read()).hexdigest())")
117+
118+ # Update recipe/meta.yaml
119+ sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
120+ sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
121+
122+ # Commit and push
123+ git config --local user.email "action@github.com"
124+ git config --local user.name "GitHub Action"
125+ git add recipe/meta.yaml
126+ git commit -m "Update to version $VERSION" || exit 0
127+ git push
0 commit comments