chore: i figured out how to package a crate with files excluded from git #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: write | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
CARGO_TERM_COLOR: always | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | |
RUSTUP_MAX_RETRIES: 10 | |
jobs: | |
# run all cargo tests in workspace | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Restore Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Run Codegen | |
run: cargo xtask codegen | |
- name: Run Tests | |
run: cargo test --workspace --all-features | |
# build syntastica-js | |
build-js: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Prepare CI | |
run: | | |
bash _prepare_ci.sh | |
- name: Install Toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
target: wasm32-unknown-emscripten | |
- name: Setup NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Setup Emscripten | |
uses: mymindstorm/setup-emsdk@v11 | |
with: | |
actions-cache-folder: 'emsdk-cache' | |
- name: Restore Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Run Codegen | |
run: cargo xtask codegen | |
- name: Prepare CI | |
run: | | |
bash _prepare_ci.sh | |
- name: Build | |
run: | | |
cd syntastica-js | |
npm ci | |
npm run build | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: syntastica-js | |
path: syntastica-js/pkg | |
retention-days: 5 | |
# run and commit auto-generated code | |
codegen: | |
runs-on: ubuntu-latest | |
if: github.repository == 'RubixDev/syntastica' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Prepare CI | |
run: | | |
bash _prepare_ci.sh | |
- name: Install Toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install Jetbrains Mono | |
run: sudo apt update && sudo apt install -y fonts-jetbrains-mono | |
- name: Install Typst | |
uses: yusancky/setup-typst@v2 | |
with: | |
version: 'v0.8.0' | |
- name: Restore Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Create SVGs | |
run: cargo xtask theme-svgs | |
- name: Generate Code | |
run: cargo xtask codegen | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: | |
syntastica-queries/generated_queries syntastica-queries/src/lib.rs | |
syntastica-parsers/Cargo.toml syntastica-parsers-gitdep/Cargo.toml | |
syntastica-parsers*/README.md syntastica-js/src/index.ts | |
syntastica-themes/assets/theme-svgs syntastica-themes/theme_list.md | |
committer_name: github-actions[bot] | |
committer_email: 41898282+github-actions[bot]@users.noreply.github.com | |
message: 'chore: run codegen' | |
- name: Upload Queries as Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: queries | |
path: syntastica-queries/generated_queries | |
retention-days: 10 | |
- name: Upload Theme List as Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: theme-list-md | |
path: syntastica-themes/theme_list.md | |
retention-days: 1 | |
# build the gh-pages site | |
pages: | |
needs: [build-js, tests, codegen] | |
if: github.repository == 'RubixDev/syntastica' | |
continue-on-error: true | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: '--deny warnings' | |
DOCS_RS: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download syntastica-js build | |
uses: actions/download-artifact@v3 | |
with: | |
name: syntastica-js | |
path: syntastica-js/pkg | |
- name: Download theme_list.md | |
uses: actions/download-artifact@v3 | |
with: | |
name: theme-list-md | |
path: syntastica-themes/ | |
- name: Install Rust Toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Setup NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install Dioxus CLI | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: dioxus-cli | |
- name: Install wasm-pack | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: wasm-pack | |
- name: Restore Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-targets: false | |
cache-on-failure: true | |
- name: Run Codegen | |
run: cargo xtask codegen | |
- name: Build Rust Documentation | |
run: cargo doc --workspace --all-features --no-deps | |
- name: Build TypeScript Documentation | |
run: | | |
cd syntastica-js | |
npm ci | |
npm run doc | |
- name: Build Vite Demo | |
run: | | |
cd examples/wasm/vite | |
# set base directory to `/syntastica/demos/vite/` | |
sed -i 's#defineConfig({#\0base:"/syntastica/demos/vite/",#g' vite.config.ts | |
npm ci | |
npm run build | |
- name: Build Dioxus Demo | |
run: | | |
cd examples/wasm/dioxus | |
# set base directory to `/syntastica/demos/dioxus/` | |
sed -i -E 's#(\[web.app\])#\1\nbase_path = "syntastica/demos/dioxus"#g' Dioxus.toml | |
dx build --release | |
- name: Build wasm-pack + NPM Demo | |
run: | | |
cd examples/wasm/wasm-pack-with-npm-pkg | |
# set base directory to `/syntastica/demos/wasm-pack-npm/` | |
sed -i 's#defineConfig({#\0base:"/syntastica/demos/wasm-pack-npm/",#g' vite.config.ts | |
wasm-pack build --target web . | |
npm ci | |
npm run build | |
- name: Prepare GitHub Pages Deployment | |
run: | | |
# redirect to `syntastica` Rust docs from main page | |
echo '<meta http-equiv="Refresh" content="0; url=syntastica" />' >> target/doc/index.html | |
# copy over the TypeScript docs | |
cp -r syntastica-js/docs target/doc/js | |
# create the `demos` folder | |
mkdir -p target/doc/demos | |
# copy over the vite demo | |
cp -r examples/wasm/vite/dist target/doc/demos/vite | |
# copy over the dioxus demo | |
cp -r examples/wasm/dioxus/dist target/doc/demos/dioxus | |
# copy over the wasm-pack-npm demo | |
cp -r examples/wasm/wasm-pack-with-npm-pkg/dist target/doc/demos/wasm-pack-npm | |
- name: Deploy Docs | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: ./target/doc |