Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 85 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// This file was automatically generated with PreTeXt 2.23.0.
// If you modify this file, PreTeXt will no longer automatically update it.
//
//////////////////////////////////////////////////////////////
//
// This file provides configuration options so that a PreTeXt
// project can be edited and built using GitHub's Codespaces.
// It is recommended to keep this in your repository even if you
// do not use this feature, as it will allow other to explore
// your project easily.
// This file will be automatically generated by PreTeXt with the
// latest updates unless you remove the first comment line above.
//
///////////////////////////////////////////////////////////////
{
"image": "oscarlevin/pretext-full", // uses latest image from https://hub.docker.com/r/oscarlevin/pretext-full/tags
// If you don't need sagemath, you can use a smaller base image. Comment out the line above and uncomment the line below to use a smaller image.
// "image": "oscarlevin/pretext",
"features": {"ghcr.io/devcontainers/features/github-cli": {}},

// The pretext-full image above includes pretext, prefigure, and enough parts of latex and sagemath for most cases. If there are errors with sage, you can install the full sagemath package through Conda by running ./.devcontainer/installSage.sh, or uncommenting that line and rebuilding the container.
"postCreateCommand": {
// "install sagemath": "bash ./.devcontainer/installSage.sh",
"install pandoc": "bash ./.devcontainer/installPandoc.sh",
"mark repo as safe": "git config --global --add safe.directory $(pwd)"
},


// Port forwarding
// ---------------
// This is needed by the CodeChat Server.
"forwardPorts": [
// The port used for a Thrift connection between the VSCode CodeChat
// extension and the CodeChat Server.
27376,
// The port used for an HTTP connection from the CodeChat Client to
// the CodeChat Server.
27377,
// The port used by a websocket connection between the CodeChat
// Server and the CodeChat Client.
27378
],
// See the [docs](https://containers.dev/implementors/json_reference/#port-attributes).
"portsAttributes": {
"27376": {
"label": "VSCode extension <-> CodeChat Server",
"requireLocalPort": true
},
"27377": {
"label": "CodeChat Client",
"requireLocalPort": true
},
"27378": {
"label": "CodeChat Client<->Server websocket",
"requireLocalPort": true
// This port needs to be public; however, there's no way to specify port visibility here. See `server.py` in the CodeChat Server for details.
}
},


// Configure tool-specific properties.
"customizations": {
"codespaces": {
"openFiles": ["source/main.ptx"]
},
"vscode": {
"settings": {
"editor.quickSuggestions": {
"other": "off"
},
"files.autoSave": "onFocusChange",
"editor.snippetSuggestions": "bottom",
"xml.validation.enabled": true,
"redhat.telemetry.enabled": false,
"CodeChat.CodeChatServer.Command": "CodeChat_Server"
},
"extensions": [
"oscarlevin.pretext-tools",
"CodeChat.codechat",
"streetsidesoftware.code-spell-checker",
"alpinebuster.vscode-latex-table-editor"
]
}
}
}
17 changes: 17 additions & 0 deletions .devcontainer/installPandoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.23.0.
# If you modify this file, PreTeXt will no longer automatically update it.

wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb

# wait for 60 second and then double check that no other script is using apt-get:
sleep 60
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
echo "Waiting for apt-get to be free..."
sleep 15
done
# Install pandoc
sudo apt-get install -y --no-install-recommends ./pandoc.deb

rm pandoc.deb
21 changes: 21 additions & 0 deletions .devcontainer/installSage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.23.0.
# If you modify this file, PreTeXt will no longer automatically update it.

# Conda should already be installed in the codespace. We need to add the conda-forge channel

conda config --add channels conda-forge
conda config --set channel_priority strict

# We don't want conda to open the base environment always:
conda config --set auto_activate_base false

# Now create a conda environment for sage (called sage):
conda create --yes -n sage sage python=3.12

conda init

echo 'conda activate sage' >> ~/.bashrc

source ~/.bashrc
112 changes: 112 additions & 0 deletions .github/workflows/pretext-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This file was automatically generated with PreTeXt 2.23.0.
# If you modify this file, PreTeXt will no longer automatically update it.
#
# This workflow file can be used to automatically build a project and create
# an artifact for deployment. It can also be used to deploy the project to
# GitHub Pages or Cloudflare Pages.
#
# The workflow is triggered on pull requests or can be run manually. You can uncomment
# the `push` event to have it run on pushes to the main branch as well.
name: PreTeXt-CLI Actions
on:
# Runs on pull requests
pull_request:
branches: ["*"]
## Runs on pushes to main
#push:
# branches: ["main"]
# Runs on demand
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext-full

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: install deps
run: pip install -r requirements.txt

- name: install local ptx files
run: pretext --version

- name: build deploy targets
run: |
version="$(pretext --version)"
major="$(echo $version | cut -d '.' -f 1)"
minor="$(echo $version | cut -d '.' -f 2)"
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
echo "PreTeXt version is 2.5 or greater; using new build command"
pretext build --deploys
else
echo "PreTeXt version is less than 2.5, using old build command"
pretext build
fi
- name: stage deployment
run: pretext deploy --stage-only

- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: output/stage

deploy-cloudflare:
runs-on: ubuntu-latest
needs: build
if: vars.CLOUDFLARE_PROJECT_NAME != ''
permissions:
contents: read
deployments: write

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Create 404.html
run: echo "404 page not found" >> deploy/404.html
- name: Publish to Cloudflare
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
directory: deploy

deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "page"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
64 changes: 64 additions & 0 deletions .github/workflows/pretext-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file was automatically generated with PreTeXt 2.23.0.
# If you modify this file, PreTeXt will no longer automatically update it.
#

name: Build and Deploy
on:
# Currently, this workflow only runs when manually selected (the `workflow_dispatch` event).
# If you would like it to run on other events, uncomment some of the lines below.

# # Runs on pull requests
# pull_request:
# branches: ["*"]

# Runs on pushes to main
push:
branches: ["main"]

# # Runs every day at 00:00 UTC
# schedule:
# - cron: '0 0 * * *'

# Runs on demand
workflow_dispatch:

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
container: oscarlevin/pretext-full

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: add gh-cli
run: |
apt-get update
apt-get install gh jq -y

- name: setup git config
run: |
git config --global --add safe.directory $(pwd)
git config user.name "${{ github.actor }} via GitHub Actions"
git config user.email "${{ github.actor }}@github_actions.no_reply"

- name: install deps
run: pip install -r requirements.txt --break-system-packages

- name: install local ptx files
run: pretext --version

- name: build deploy targets
run: pretext build --deploys

- name: run deploy
run: pretext deploy --no-push

- name: push gh-pages branch
run: git push origin gh-pages --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Loading