-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (133 loc) · 5.27 KB
/
gh-pages.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Build and Deploy
on:
push:
branches:
- main
release:
branch: main
types: [released]
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12.7'
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v2
- name: Install the dependencies
run: |
python -m pip install -r requirements.txt
- name: Get the current branch name
uses: tj-actions/branch-names@v8
id: branch
- name: Compute the current version name
run: echo "CLIMETLAB_VERSION=${{ steps.branch.outputs.current_branch || steps.branch.outputs.tag }}" >> $GITHUB_ENV
- name: Check the Pyodide version
run: |
echo "PYODIDE_SHA_SHORT=$(git submodule status pyodide | cut -c 2-8)" >> $GITHUB_ENV
- name: Cache the Pyodide build
uses: actions/cache@v4
with:
path: ./pyodide
key: pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
restore-keys: |
pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
pyodide-${{ github.ref }}
pyodide-refs/heads/main
- name: Ensure Pyodide source files are fresh
run: |
cd pyodide
git status
git diff --name-only | xargs git checkout --
git clean -df
echo ======
git status
- name: Cache the Pyodide Docker image
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-pyodide-${{ hashFiles('pyodide/Dockerfile') }}
- name: Discover the cached Pyodide Docker image
run: echo "PYODIDE_DOCKER_IMAGE=$(docker images climet-eu/pyodide --format '{{.ID}}')" >> $GITHUB_ENV
- name: Build the Pyodide Docker image
if: ${{ env.PYODIDE_DOCKER_IMAGE == '' }}
run: |
cd pyodide
docker build -t climet-eu/pyodide .
echo "PYODIDE_DOCKER_IMAGE=$(docker build . -q)" >> $GITHUB_ENV
- name: Build Pyodide and all required packages
run: |
cd pyodide
./run_docker \
--non-interactive \
PYODIDE_PACKAGES="aiohttp,basemap,cdsapi,cfgrib,cf-units,cf-xarray,cmcrameri,dask,earthkit,ecmwf-api-client,ecmwf-opendata,field-compression-benchmark,fsspec,git2,gribscan,healpy,h5netcdf,intake,intake-esm,intake-xarray,ipyfilite,ipython,kerchunk,lzma,matplotlib,MetPy,netcdf4,numcodecs,numpy,pandas,pint,pooch,pyarrow,pyicon-diagnostics,pystac,regex,requests,rich,scipy,shapely,sympy,s3fs,xarray,xeofs,zarr" \
make
- name: Extract the requirements.txt file
continue-on-error: ${{ github.event_name != 'release' }}
run: python tools/requirements.py
- name: Extract the PyPa simple repository API
run: python tools/pypa-simple.py https://lab.climet.eu/${{ env.CLIMETLAB_VERSION }}/static/pyodide/
- name: Clean up the pyodide build
run: |
cd pyodide
find . -name jupyter-lite.json -delete
find . -name jupyter_lite_config.json -delete
mkdir -p packages/numpy/build
touch packages/numpy/build/ls-success
ls -d packages/*/build/* | xargs rm -r
- name: Check the validity of the requirements.txt file
continue-on-error: ${{ github.event_name != 'release' }}
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
python -m pip install -r files/requirements.txt --dry-run --ignore-installed
deactivate
rm -rf venv
- name: Check the validity of the constraints.txt and requirements.in files
continue-on-error: ${{ github.event_name != 'release' }}
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
python -m pip install -r files/constraints.txt -r files/requirements.in --dry-run --ignore-installed
deactivate
rm -rf venv
- name: Build the JupyterLite site
run: |
rm -f files/README.md && cp ./README.md files/
mkdir -p static
mv pyodide/dist static/pyodide
python tools/clean-dist.py static/pyodide
rm -f static/pyodide/tsconfig.tsbuildinfo
jupyter lite build --output-dir staging
cp static/favicons/favicon.ico staging/
find staging/ -name favicon.ico | xargs -L1 cp -f static/favicons/favicon.ico
mv pypa staging/
rm -rf static
- name: Checkout the previous dist branch
uses: actions/checkout@v4
with:
ref: dist
path: dist
continue-on-error: ${{ github.event_name != 'release' }}
- name: Merge the different dist versions
run: |
mkdir -p dist
rm -rf dist/${{ env.CLIMETLAB_VERSION }}
mv staging dist/${{ env.CLIMETLAB_VERSION }}
- name: Deploy to dist branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: dist
publish_dir: ./dist
keep_files: false
force_orphan: true