forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (74 loc) · 3.1 KB
/
nightlies.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Upload nightly wheels to Anaconda Cloud
on:
# Run daily at 1:23 UTC to upload nightly wheels to Anaconda Cloud
schedule:
- cron: '23 1 * * *'
# Run on demand with workflow dispatch
workflow_dispatch:
jobs:
upload_nightly_wheels:
name: Upload nightly wheels to Anaconda Cloud
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
if: github.repository_owner == 'matplotlib'
steps:
# c.f. https://github.com/actions/download-artifact/issues/3#issuecomment-1017141067
- name: Download wheel artifacts from last build on 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PROJECT_REPO="matplotlib/matplotlib"
BRANCH="main"
WORKFLOW_NAME="cibuildwheel.yml"
ARTIFACT_NAME="wheels"
gh run --repo "${PROJECT_REPO}" \
list --branch "${BRANCH}" \
--workflow "${WORKFLOW_NAME}" \
--json event,status,databaseId > runs.json
# Filter on 'push' events to main (merged PRs) that have completed
jq --compact-output \
'[ .[] | select(.event == "push") | select(.status == "completed") ]' \
runs.json > pushes.json
# Get id of latest build of wheels
RUN_ID=$(
jq --compact-output \
'sort_by(.databaseId) | reverse | .[0].databaseId' pushes.json
)
gh run --repo "${PROJECT_REPO}" \
download "${RUN_ID}" --name "${ARTIFACT_NAME}"
mkdir dist
mv *.whl dist/
ls -l dist/
# N.B. anaconda-client is only maintained on the main channel
- name: Install anaconda-client
uses: mamba-org/provision-with-micromamba@v12
with:
environment-file: false
environment-name: nightlies
extra-specs: anaconda-client=1.10.0
channels: main
- name: Upload wheels to Anaconda Cloud as nightlies
run: |
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \
--user scipy-wheels-nightly \
--skip-existing \
dist/matplotlib-*.whl
- name: Remove old uploads to save space
run: |
N_LATEST_UPLOADS=5
# Remove all _but_ the last "${N_LATEST_UPLOADS}" package versions
# N.B.: `anaconda show` places the newest packages at the bottom of the output
# of the 'Versions' section and package versions are preceded with a ' + '.
anaconda show scipy-wheels-nightly/matplotlib &> >(grep '+') | \
sed 's/.* + //' | \
head --lines "-${N_LATEST_UPLOADS}" > remove-package-versions.txt
if [ -s remove-package-versions.txt ]; then
while LANG=C IFS= read -r package_version ; do
echo "# Removing scipy-wheels-nightly/matplotlib/${package_version}"
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} remove \
--force \
"scipy-wheels-nightly/matplotlib/${package_version}"
done <remove-package-versions.txt
fi