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

ci: github actions #23

Merged
merged 12 commits into from
Feb 7, 2023
70 changes: 70 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: publish

on:
pull_request:
branches: [master]
push:
branches: [master]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
checks:
if: github.event_name != 'push'
LeoDog896 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- name: Setup wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
version: 'latest'
- name: Install Task
uses: arduino/setup-task@v1
- name: Run Build
run: task
gh-release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment:
name: github-pages
LeoDog896 marked this conversation as resolved.
Show resolved Hide resolved
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- name: Setup wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
version: 'latest'
- name: Install Task
uses: arduino/setup-task@v1
- name: Run Build
run: task
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'www'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
**/*.rs.bk
Cargo.lock
www/
.task
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "book"]
path = book
url = https://github.com/pest-parser/book
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@

This repo contains the source code for https://pest.rs

You can build it with [wasm-pack](https://github.com/rustwasm/wasm-pack):
To build it, you need [task](https://taskfile.dev/), [wasm-pack](https://rustwasm.github.io/wasm-pack/), and [mdbook](https://rust-lang.github.io/mdBook/):

```sh
# Create an empty directory to hold the output (and remove any old files)
mkdir -p www
rm -rf www/*

# Build and copy in the JS and WASM from Pest
wasm-pack build --target web
cp pkg/*.js www/
cp pkg/*.wasm www/

# Copy in authored files
cp -R static/* www/
# run the taskfile (this may be go-task)
task
```

You can then test the site by serving the `www` directory with your dev server
You can then test the site by serving the built `www` directory with your dev server
of choice. For example:

```sh
Expand Down
25 changes: 23 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,32 @@ vars:
WEBROOT: "./www"

tasks:
default:
book:
dir: ./book
cmds:
- mdbook build

clean:
cmds:
- mkdir -p www
- mkdir -p {{.WEBROOT}}
- rm -rf {{.WEBROOT}}/*
- mkdir -p {{.WEBROOT}}/book

pack:
cmds:
- wasm-pack build --target web
generates:
- pkg/**
- target/**
sources:
- Cargo.toml
- Cargo.lock
- src/**

default:
deps: [clean, book, pack]
cmds:
- cp -R book/book/* {{.WEBROOT}}/book
- cp -R static/* {{.WEBROOT}}/
- cp pkg/*.js {{.WEBROOT}}
- cp pkg/*.wasm {{.WEBROOT}}
1 change: 1 addition & 0 deletions book
Submodule book added at c3fb50