diff --git a/.github/workflows/single-file.yml b/.github/workflows/single-file.yml new file mode 100644 index 0000000..9e8d184 --- /dev/null +++ b/.github/workflows/single-file.yml @@ -0,0 +1,41 @@ +name: Create single file build + +on: + push: + branches: ["*"] + workflow_dispatch: + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" # Using latest Node 22 for 2026 compatibility + + - name: Install dependencies + working-directory: Build + run: npm i + + - name: Build + working-directory: Build + run: npm run build:single + + - name: Rename for distribution + working-directory: Build/dist + run: mv index.html HTMLRunner.html + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: HTMLRunner-Standalone + path: Build/dist/HTMLRunner.html + if-no-files-found: error diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index f1d3dcb..6418d8b 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -1,45 +1,43 @@ -# .github/workflows/static.yml -name: Deploy static content to Pages +# Simple workflow for deploying static content to GitHub Pages +name: Deploy browser build to GitHub Pages on: push: branches: ["main"] workflow_dispatch: +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read - pages: write - id-token: write + contents: write +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" - cancel-in-progress: true + cancel-in-progress: false jobs: deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js + - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: "20" - - name: Run build script - run: | - chmod +x Build/Buildscripts/build.sh - ./Build/Buildscripts/build.sh + - name: Install dependencies + working-directory: Build + run: npm i - - name: Upload GitHub Pages artifact - uses: actions/upload-pages-artifact@v3 - with: - path: 'Build/dist' + - name: Build + working-directory: Build + run: npm run build - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - name: Deploy browser build to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: Build/dist diff --git a/Build/Buildscripts/build-all.sh b/Build/Buildscripts/build-all.sh deleted file mode 100755 index 7ac046f..0000000 --- a/Build/Buildscripts/build-all.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e # Exit immediately on error - -echo "Starting full build..." -echo "" - -# Determine the directory of this script -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# Run each script relative to this directory -"$SCRIPT_DIR/build.sh" -echo "" -"$SCRIPT_DIR/build-inline.sh" -echo "" - -echo "Full build completed." diff --git a/Build/Buildscripts/build-inline.sh b/Build/Buildscripts/build-inline.sh deleted file mode 100755 index 0b06d26..0000000 --- a/Build/Buildscripts/build-inline.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -set -euo pipefail - -echo "Starting inlining process..." - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -DIST_DIR="$SCRIPT_DIR/../dist" - -HTML_FILE="$DIST_DIR/index.html" -CSS_FILE="$DIST_DIR/styles.css" -JS_FILE="$DIST_DIR/main.js" -OUTPUT_FILE="$DIST_DIR/index-inline.html" - -# Check that required files exist -if [[ ! -f "$HTML_FILE" || ! -f "$CSS_FILE" || ! -f "$JS_FILE" ]]; then - echo "Missing one or more required files in $DIST_DIR." - exit 1 -fi - -# Step 1: Create a backup of the original HTML -cp "$HTML_FILE" "$OUTPUT_FILE" - -# Step 2: Read and indent CSS and JS -INDENTED_CSS=$(sed 's/^/ /' "$CSS_FILE") -INDENTED_JS=$(sed 's/^/ /' "$JS_FILE") - -# Step 3: Replace and |@@INLINE_JS@@|g' "$OUTPUT_FILE" -sed -i.bak "s||@@INLINE_JS@@|g" "$OUTPUT_FILE" - -# Step 4: Write indented CSS and JS to temporary files -INLINE_CSS_FILE=$(mktemp) -INLINE_JS_FILE=$(mktemp) - -{ - echo " " -} > "$INLINE_CSS_FILE" - -{ - echo " " -} > "$INLINE_JS_FILE" - -# Step 5: Replace placeholders with inline content -awk -v css="$INLINE_CSS_FILE" -v js="$INLINE_JS_FILE" ' -/@@INLINE_CSS@@/ { - while ((getline line < css) > 0) print line - close(css) - next -} -/@@INLINE_JS@@/ { - while ((getline line < js) > 0) print line - close(js) - next -} -{ print } -' "$OUTPUT_FILE" > "$OUTPUT_FILE.tmp" && mv "$OUTPUT_FILE.tmp" "$OUTPUT_FILE" - -# Clean up -rm -f "$INLINE_CSS_FILE" "$INLINE_JS_FILE" "$OUTPUT_FILE.bak" - -echo "Inlined output written to $OUTPUT_FILE" diff --git a/Build/Buildscripts/build.sh b/Build/Buildscripts/build.sh deleted file mode 100755 index 15690e0..0000000 --- a/Build/Buildscripts/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -echo "Building HTMLRunner" - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" # project root -BUILD_DIR="$ROOT_DIR/Build" # e.g., Build/ -DIST_DIR="$BUILD_DIR/dist" # final output - -cd "$BUILD_DIR" - -npm install -npm run build - -echo "Copying extra files..." -cp "$ROOT_DIR/favicon.png" "$DIST_DIR/" -cp "$ROOT_DIR/manifest.json" "$DIST_DIR/" -cp "$ROOT_DIR/service-worker.js" "$DIST_DIR/" - -echo "Build completed." diff --git a/index.html b/Build/index.html similarity index 50% rename from index.html rename to Build/index.html index 36e8835..82c702f 100644 --- a/index.html +++ b/Build/index.html @@ -4,22 +4,8 @@