Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual build and deploy to help learning experience #117

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,70 @@ JupyterLite is being tested against modern web browsers:

Check out the guide on the JupyterLite documentation: https://jupyterlite.readthedocs.io/en/latest/quickstart/deploy.html

## Manual build and deploy to GitHub Pages

This section does the same as the Github Action based automatic build & deploy described in the previous one, but offers a step by step approach which possibly offers a better learning experience.

- git clone the repo:

```sh
mkdir work-zone # a working dir
cd work-zone

git clone https://github.com/jupyterlite/demo.git
cd demo
rm -rf .git
```

- Create a dedicated conda/mamba env:

```sh
conda create -n lite-demo python=3.10 -y
conda activate lite-demo
pip install -r requirements.txt
```

- Build jupyterlite static site:

```sh
# rm to start from clean sheet
rm ./.jupyterlite.doit.db
rm -rf ./dist
rm -rf ./lite/.cache

jupyter lite build --contents content --output-dir dist
```

- Serve static site in `./dist` locally:

```sh
python -m http.server -d dist 3000
```

Visit http://localhost:3000

- git commit and push to your repo:

```sh
git init
git add . && git commit -m "Init"
git remote add origin https://github.com/[YOURNAME]/jupyterlite-demo.git
git branch -M main
git push -u origin main
```

- Deploy static site in `./dist` to GitHub Pages:

```sh
# linux
. ./deploy-ghp.sh

# win
deploy-ghp.bath
```

Visit [gh-pages](https://docs.github.com/en/pages) static site: `https://[YOURNAME].github.io/[YOURREPO]`.

## Further Information and Updates

For more info, keep an eye on the JupyterLite documentation:
Expand Down
30 changes: 30 additions & 0 deletions deploy-ghp.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
REM make sure git is clear:
REM git status --porcelain

git push origin --delete gh-pages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gh-pages approach has the drawback of increasing the repo size quite significantly.

Also the GitHub Action to deploy to GitHub Pages will likely be default way soon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So not sure about recommending using gh-pages (even though it's been there for years)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not "Github Pages" and "gh-pages" the same thing ?
Any deployment must necessarily provide the static site somewhere, right ?
And the latest stage is enough - no need for history.
If so, this is what the deploy script does.

Now deploying on github is not a reco in my mind, just a fast way to test, available to anybody.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even faster is local deploy - added in the section - this brings attention to the dist repo.

git branch -D gh-pages

git checkout --orphan gh-pages

git rm --cached -rf .

git add deploy-ghp.sh
git commit -m "Add deploy script"

# git clean -n
git clean -f

git rm --cached deploy-ghp.sh
git commit -m "Remove deploy script"

REM remove all but deploy script
rm -rf .github content repl .gitignore .jupyterlite.doit.db deploy-ghp.sh README.md requirements.txt

REM only files/dir from ./dist will be commited
cp -r ./dist/* ./

git add .
git commit -m "Deploy"
git push --set-upstream origin gh-pages

git checkout main
32 changes: 32 additions & 0 deletions deploy-ghp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# make sure git is clear:
# git status --porcelain

git push origin --delete gh-pages
git branch -D gh-pages

git checkout --orphan gh-pages

git rm --cached -rf .

git add deploy-ghp.sh
git commit -m "Add deploy script"

# git clean -n
git clean -f

git rm --cached deploy-ghp.sh
git commit -m "Remove deploy script"

# remove all but deploy script
rm -rf .github content repl .gitignore .jupyterlite.doit.db deploy-ghp.bat README.md requirements.txt

# only files/dir from ./dist will be commited
cp -r ./dist/* ./

git add .
git commit -m "Deploy"
git push --set-upstream origin gh-pages

git checkout main