generated from jupyterlite/demo
-
-
Notifications
You must be signed in to change notification settings - Fork 7
131 lines (110 loc) · 4.3 KB
/
deploy.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
name: Build and Deploy
on:
push:
branches:
- main
pull_request:
branches:
- "*"
# First, grab pyodide-lock.json from the latest release in https://github.com/pyodide/pyodide-recipes,
# whichever it is. Store the Pyodide SymPy version in a variable.
# Similarly, grab the latest version of SymPy from PyPI and store it in a variable.
# If the SymPy version in Pyodide is older than the one that's available in PyPI,
# then we download the PyPI wheel and make it available to the next step.
jobs:
determine-sympy-version:
runs-on:
ubuntu-latest
steps:
- name: Grab pyodide-lock.json from latest pyodide-recipes release
run: |
gh release download \
--repo pyodide/pyodide-recipes \
--pattern "pyodide-lock.json" \
--dir .
- name: Get Pyodide and PyPI SymPy versions
run: |
PYODIDE_SYMPY_VERSION=$(jq -r '.packages.sympy.version' pyodide-lock.json)" >> $GITHUB_ENV
PYPI_SYMPY_VERSION=$(curl -s https://pypi.org/pypi/sympy/json | jq -r '.info.version' | grep -Ev 'alpha|a|beta|b|preview|pre|c|rc|dev') >> $GITHUB_ENV
- name: Install packaging
run: python -m pip install packaging
- name: Compare versions and download SymPy, if necessary
id: sympy-version-check
shell: python
run: |
import os
from packaging.version import Version
PYPI_SYMPY_VERSION = os.environ["PYPI_SYMPY_VERSION"]
PYODIDE_SYMPY_VERSION = os.environ["PYODIDE_SYMPY_VERSION"]
SHOULD_DOWNLOAD = Version(PYPI_SYMPY_VERSION) > Version(PYODIDE_SYMPY_VERSION)
if SHOULD_DOWNLOAD:
print("Downloading the latest version of SymPy from PyPI using the JSON API, excluding release candidates and pre-releases.")
import urllib.request
import json
url = "https://pypi.org/pypi/sympy/json"
response = urllib.request.urlopen(url)
data = json.loads(response.read())
urllib.request.urlretrieve(download_url, f"sympy-{PYPI_SYMPY_VERSION}-py3-none-any.whl")
else:
print("The SymPy version in Pyodide is up-to-date with the latest version in PyPI, no need to download.")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
f.write(f"should_download: {SHOULD_DOWNLOAD}\n")
- name: Upload the wheel, if downloaded
if: steps.sympy-version-check.outputs.should_download == 'True'
uses: actions/upload-artifact@v4
with:
name: sympy-wheel-${{ github.run_id }}
path: sympy-*-py3-none-any.whl
if-no-files-found: error
build-jupyterlite:
runs-on: ubuntu-latest
needs: [determine-sympy-version]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Download the wheel, if necessary
if: needs.determine-sympy-version.outputs.should_download == 'True'
uses: actions/download-artifact@v4
with:
name: sympy-wheel-${{ github.run_id }}
path: custom_wheels
merge-multiple: true
- name: Install the dependencies
run: |
python -m pip install -r requirements.txt
- name: Build the JupyterLite site
run: |
jupyter lite build
- name: Add custom index.html (live.sympy.org landing page) and static/ files
run: |
./generateindex.py
- name: Add CNAME file containing live.sympy.org
run: |
echo "live.sympy.org" > ./_output/CNAME
- name: Upload (dist)
uses: actions/upload-artifact@v4
with:
name: jupyterlite-demo-dist-${{ github.run_number }}
path: ./_output
if-no-files-found: error
deploy:
if: github.ref == 'refs/heads/main'
needs: [build-jupyterlite]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
- uses: actions/download-artifact@v4
with:
name: jupyterlite-demo-dist-${{ github.run_number }}
path: ./dist
merge-multiple: true
- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.3
with:
branch: gh-pages
folder: dist