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=30
38+ SLEEP_TIME=60
39+
40+ echo "Waiting for omnipkg version $VERSION to be available on PyPI..."
41+
42+ for i in $(seq 1 $MAX_ATTEMPTS); do
43+ echo "Attempt $i/$MAX_ATTEMPTS..."
44+
45+ # Check if the package exists on PyPI
46+ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
47+ "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz")
48+
49+ if [ "$HTTP_CODE" = "200" ]; then
50+ echo "✓ Package found on PyPI!"
51+ break
52+ elif [ $i -eq $MAX_ATTEMPTS ]; then
53+ echo "✗ Package not found after $MAX_ATTEMPTS attempts"
54+ exit 1
55+ else
56+ echo "Package not yet available (HTTP $HTTP_CODE). Waiting ${SLEEP_TIME}s..."
57+ sleep $SLEEP_TIME
58+ fi
59+ done
60+
61+ - name : Download and calculate SHA256
62+ id : get-sha
63+ run : |
64+ VERSION="${{ steps.get-version.outputs.version }}"
65+
66+ echo "Downloading package from PyPI..."
67+ curl -L -o "omnipkg-$VERSION.tar.gz" \
68+ "https://pypi.org/packages/source/o/omnipkg/omnipkg-$VERSION.tar.gz"
69+
70+ echo "Calculating SHA256..."
71+ if command -v sha256sum &> /dev/null; then
72+ SHA256=$(sha256sum "omnipkg-$VERSION.tar.gz" | cut -d' ' -f1)
73+ else
74+ SHA256=$(shasum -a 256 "omnipkg-$VERSION.tar.gz" | cut -d' ' -f1)
75+ fi
76+
77+ echo "sha256=$SHA256" >> $GITHUB_OUTPUT
78+ echo "SHA256: $SHA256"
79+
80+ # Second job: Update conda-forge feedstock
81+ update-feedstock :
82+ needs : wait-for-pypi
83+ runs-on : ubuntu-latest
84+ if : github.event_name == 'release'
85+ steps :
86+ - name : Checkout your feedstock fork
87+ uses : actions/checkout@v4
88+ with :
89+ repository : 1minds3t/omnipkg-feedstock
90+ token : ${{ secrets.GITHUB_TOKEN }}
91+ path : feedstock
92+
93+ - name : Setup Python
94+ uses : actions/setup-python@v5
95+ with :
96+ python-version : ' 3.11'
97+
98+ - name : Update feedstock meta.yaml
99+ run : |
100+ cd feedstock
101+ VERSION="${{ needs.wait-for-pypi.outputs.version }}"
102+ SHA256="${{ needs.wait-for-pypi.outputs.sha256 }}"
103+
104+ echo "Updating recipe/meta.yaml to version $VERSION with SHA256: $SHA256"
105+
106+ # Update version and sha256 in meta.yaml
107+ sed -i "s/{% set version = \".*\" %}/{% set version = \"$VERSION\" %}/" recipe/meta.yaml
108+ sed -i "s/sha256: .*/sha256: $SHA256/" recipe/meta.yaml
109+
110+ # Show the changes
111+ echo "=== Updated meta.yaml (first 30 lines) ==="
112+ head -30 recipe/meta.yaml
113+
114+ - name : Commit and push to fork
115+ run : |
116+ cd feedstock
117+ VERSION="${{ needs.wait-for-pypi.outputs.version }}"
118+
119+ git config --local user.email "action@github.com"
120+ git config --local user.name "GitHub Action"
121+ git add recipe/meta.yaml
122+
123+ if git diff --staged --quiet; then
124+ echo "No changes to commit"
125+ else
126+ git commit -m "Update omnipkg to version $VERSION"
127+ git push
128+ echo "✓ Changes pushed to fork"
129+ fi
130+
131+ - name : Create Pull Request to conda-forge
132+ uses : peter-evans/create-pull-request@v5
133+ with :
134+ token : ${{ secrets.FEEDSTOCK_TOKEN }}
135+ path : feedstock
136+ commit-message : " Update omnipkg to version ${{ needs.wait-for-pypi.outputs.version }}"
137+ title : " Update omnipkg to version ${{ needs.wait-for-pypi.outputs.version }}"
138+ body : |
139+ Automated update to omnipkg version ${{ needs.wait-for-pypi.outputs.version }}
140+
141+ - Updated version in meta.yaml
142+ - Updated SHA256 hash
143+
144+ Changes were automatically generated by GitHub Actions after PyPI release.
145+ branch : " update-v${{ needs.wait-for-pypi.outputs.version }}"
146+ base : main
147+ push-to-fork : 1minds3t/omnipkg-feedstock
148+
149+ # Third job: Build conda packages for your own channel
14150 build-and-upload :
151+ needs : wait-for-pypi
15152 runs-on : ${{ matrix.os }}
16153 strategy :
17154 matrix :
@@ -34,23 +171,14 @@ jobs:
34171 shell : bash -l {0}
35172 run : |
36173 conda install conda-build anaconda-client -y
174+
37175 - name : Update meta.yaml version and hash
38176 shell : bash -l {0}
39177 run : |
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
46-
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"
178+ VERSION="${{ needs.wait-for-pypi.outputs.version }}"
179+ SHA256="${{ needs.wait-for-pypi.outputs.sha256 }}"
50180
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())")
181+ echo "Using version $VERSION with SHA256: $SHA256"
54182
55183 # Update the version and sha256 in meta.yaml (cross-platform sed)
56184 if [[ "$RUNNER_OS" == "macOS" ]]; then
@@ -61,67 +189,21 @@ jobs:
61189 sed -i "s/sha256: .*/sha256: $SHA256/" omnipkg/conda-recipe/meta.yaml
62190 fi
63191
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 ==="
192+ echo "Updated meta.yaml:"
69193 head -15 omnipkg/conda-recipe/meta.yaml
194+
70195 - name : Build conda package
71196 shell : bash -l {0}
72197 run : |
73198 export PYTHONIOENCODING=UTF-8
74199 conda build omnipkg/conda-recipe --output-folder ./conda-dist
200+
75201 - name : Upload to Anaconda Cloud
76202 shell : bash -l {0}
77203 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
80204 find ./conda-dist -name "*.conda" -o -name "*.tar.bz2" | while read file; do
81205 echo "Uploading $file"
82206 anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload "$file" --force
83207 done
84208 env :
85209 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