8000 CI: Add nightly upload of wheels to Anaconda Cloud · matplotlib/matplotlib@6d3d6fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d3d6fd

Browse files
CI: Add nightly upload of wheels to Anaconda Cloud
Add nightlies.yml GitHub Action workflow that uses the gh CLI API to download the 'wheels' artifact from the latest completed build of the cibuildwheel workflow from the 'main' branch. This is done by getting the fields 'event', 'status', and 'databaseId' from the output of `gh run list` as JSON and then using jq to filter for 'push' events (which correspond to merged PRs to the 'main' branch) that have completed runs. This is then sorted by the databaseIds in descending order to get the latest completed build run number. Then the 'wheels' artifact can be downloaded. The downloaded wheels are then uploaded to the scipy-wheels-nightly Anaconda Cloud organization (https://anaconda.org/scipy-wheels-nightly) using the anaconda-client CLI API.
1 parent da9533d commit 6d3d6fd

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/nightlies.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Upload nightly wheels to Anaconda Cloud
2+
3+
on:
4+
# Run daily at 1:23 UTC to upload nightly wheels to Anaconda Cloud
5+
schedule:
6+
- cron: '23 1 * * *'
7+
# Run on demand with workflow dispatch
8+
workflow_dispatch:
9+
10+
jobs:
11+
upload_nightly_wheels:
12+
name: Upload nightly wheels to Anaconda Cloud
13+
runs-on: ubuntu-latest
14+
if: github.repository_owner == 'matplotlib'
15+
16+
steps:
17+
- name: Install Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: '3.x'
21+
22+
# c.f. https://github.com/actions/download-artifact/issues/3#issuecomment-1017141067
23+
- name: Download wheel artifacts from last build on 'main'
24+
shell: bash
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
PROJECT_REPO="matplotlib/matplotlib"
29+
BRANCH="main"
30+
WORKFLOW_NAME="cibuildwheel.yml"
31+
ARTIFACT_NAME="wheels"
32+
33+
gh run --repo "${PROJECT_REPO}" \
34+
list --branch "${BRANCH}" \
35+
--workflow "${WORKFLOW_NAME}" \
36+
--json event,status,databaseId > runs.json
37+
# Filter on 'push' events to main (merged PRs) that have completed
38+
jq --compact-output \
39+
'[ .[] | select(.event == "push") | select(.status == "completed") ]' \
40+
runs.json > pushes.json
41+
# Get id of latest build of wheels
42+
RUN_ID=$(
43+
jq --compact-output \
44+
'sort_by(.databaseId) | reverse | .[0].databaseId' pushes.json
45+
)
46+
gh run --repo "${PROJECT_REPO}" \
47+
download "${RUN_ID}" --name "${ARTIFACT_NAME}"
48+
49+
mkdir dist
50+
mv *.whl dist/
51+
ls -l dist/
52+
53+
- name: Install anaconda-client
54+
run: |
55+
python -m pip install --upgrade pip setuptools wheel
56+
# c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/540
57+
python -m pip install git+https://github.com/Anaconda-Server/anaconda-client
58+
python -m pip list
59+
60+
- name: Upload wheels to Anaconda Cloud as nightlies
61+
run: |
62+
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \
63+
--user scipy-wheels-nightly \
64+
dist/matplotlib-*.whl

0 commit comments

Comments
 (0)
0