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

Skip to content

Commit d6c09af

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 'status' and 'databaseId' from the output of `gh run list` as JSON and then using jq to filter for completed runs and then sort 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 a395083 commit d6c09af

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/nightlies.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
15+
steps:
16+
- name: Install Python
17+
uses: actions/setup-python@v3
18+
with:
19+
python-version: '3.x'
20+
21+
# c.f. https://github.com/actions/download-artifact/issues/3#issuecomment-1017141067
22+
- name: Download wheel artifacts from last build on 'main'
23+
shell: bash
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
PROJECT_REPO=matplotlib/matplotlib
28+
BRANCH=main
29+
WORKFLOW_NAME="cibuildwheel.yml"
30+
ARTIFACT_NAME=wheels
31+
32+
gh run --repo "${PROJECT_REPO}" list --branch "${BRANCH}" --workflow "${WORKFLOW_NAME}" --json status,databaseId > runs.json
33+
# Get latest completed build of wheels
34+
RUN_ID=$(cat runs.json | jq -c '[ .[] | select(.status == "completed") ] | sort_by(.databaseId) | reverse | .[0].databaseId')
35+
gh run --repo "${PROJECT_REPO}" download "${RUN_ID}" --name "${ARTIFACT_NAME}"
36+
37+
mkdir dist
38+
mv *.whl dist/
39+
ls -l dist/
40+
41+
- name: Install anaconda-client
42+
run: |
43+
python -m pip install --upgrade pip setuptools wheel
44+
# c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/540
45+
python -m pip install git+https://github.com/Anaconda-Server/anaconda-client
46+
python -m pip list
47+
48+
- name: Upload wheels to Anaconda Cloud as nightlies
49+
run: |
50+
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \
51+
--user scipy-wheels-nightly \
52+
dist/matplotlib-*.whl

0 commit comments

Comments
 (0)
0