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

Skip to content

Commit 5437fb3

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 5437fb3

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/nightlies.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
echo "$(cat runs.json | \
39+
jq -c '[ .[] | select(.event == "push") | select(.status == "completed") ]'
40+
)" > runs.json
41+
# Get id of latest build of wheels
42+
RUN_ID=$(cat runs.json | \
43+
jq -c 'sort_by(.databaseId) | reverse | .[0].databaseId'
44+
)
45+
gh run --repo "${PROJECT_REPO}" \
46+
download "${RUN_ID}" --name "${ARTIFACT_NAME}"
47+
48+
mkdir dist
49+
mv *.whl dist/
50+
ls -l dist/
51+
52+
- name: Install anaconda-client
53+
run: |
54+
python -m pip install --upgrade pip setuptools wheel
55+
# c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/540
56+
python -m pip install git+https://github.com/Anaconda-Server/anaconda-client
57+
python -m pip list
58+
59+
- name: Upload wheels to Anaconda Cloud as nightlies
60+
run: |
61+
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \
62+
--user scipy-wheels-nightly \
63+
dist/matplotlib-*.whl

0 commit comments

Comments
 (0)
0