diff --git a/.github/workflows/.trigger b/.github/workflows/.trigger new file mode 100644 index 0000000..5375178 --- /dev/null +++ b/.github/workflows/.trigger @@ -0,0 +1,2 @@ +# Edit this file to manually trigger the workflow - just increase the number +1 diff --git a/.github/workflows/build_static_site.sh b/.github/workflows/build_static_site.sh new file mode 100644 index 0000000..95068ac --- /dev/null +++ b/.github/workflows/build_static_site.sh @@ -0,0 +1,124 @@ +set -e +#build_static_site.sh + +# Do we need to build? +cd ./splashkitonline +# only build if the SplashKitWasm folder has changed, or if this was a push to a branch (so branches always build) +if ! git diff --quiet $(git merge-base "origin/main" "$1").."$1" -- SplashKitWasm &>/dev/null || [ "$2" == "push" ]; then + cd ../ + + echo "========================================" + echo "Downloading Compilation Pre-builts (To improve...these should be buildable too)" + echo "========================================" + mkdir -p ./splashkitonline/SplashKitWasm/prebuilt/cxx/compiler/ + cd ./splashkitonline/SplashKitWasm/prebuilt/cxx/compiler/ + wget -O clang++.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/clang++.js + wget -O clang.wasm.lzma https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/clang.wasm.lzma + wget -O wasm-ld.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/wasm-ld.js + wget -O lld.wasm.lzma https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/lld.wasm.lzma + wget -O sysroot.zip https://github.com/WhyPenguins/SplashkitOnline/raw/refs/heads/cxx_language_backend_binaries/SplashKitWasm/prebuilt/sysroot.zip + # decompress them - silly since they'll just be re-compressed again, but it is what it is for now... + xz -d clang.wasm.lzma + xz -d lld.wasm.lzma + + cd ../../../../../ + + echo "========================================" + echo "Set Up Compilation Environment" + echo "========================================" + + sudo apt-get -qq update + sudo apt-get install -y build-essential cmake libpng-dev libcurl4-openssl-dev libsdl2-dev libsdl2-mixer-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-net-dev libsdl2-ttf-dev libmikmod-dev libbz2-dev libflac-dev libvorbis-dev libwebp-dev + git clone https://github.com/emscripten-core/emsdk.git + ./emsdk/emsdk install 3.1.48 + + + echo "========================================" + echo "Build SplashKit WASM Libraries" + echo "========================================" + + cd emsdk + ./emsdk activate 3.1.48 + source ./emsdk_env.sh + cd ../ + mkdir -p ./splashkitonline/SplashKitWasm/out/cxx/compiler/ # this one is due to a mistake in old CMakeLists, can be removed soon + # build this as well... + + + cd ./splashkitonline/SplashKitWasm/cmake/ + + emcmake cmake -G "Unix Makefiles" -DENABLE_JS_BACKEND=ON -DENABLE_CPP_BACKEND=ON -DENABLE_FUNCTION_OVERLOADING=ON -DCOMPRESS_BACKENDS=ON . + emmake make -j8 + + cd ../../../ + +else + + echo "========================================" + echo "Using Precompiled Binaries from Main" + echo "========================================" + + cd ../ + + # Rather than building, we'll just grab the compiled binaries from the main release. + # To do this, we'll copy over all completely untracked files from it, which will correctly + # handle if the PR has deleted files since branching from main. + # Perhaps there's a cleaner way :) + + # first let's get a list of files _not_ to copy + cd ./splashkitonline + TRACKED_FILES=$(git log --pretty=format: --name-only --diff-filter=A -- Browser_IDE| sort - | sed '/^$/d') + EXCLUDE_FILE=$(mktemp) + echo "$TRACKED_FILES" | sed "s|^Browser_IDE||" > "$EXCLUDE_FILE" + + # add some explicit excludes + echo "/codemirror-5.65.15" >> "$EXCLUDE_FILE" + echo "/jszip" >> "$EXCLUDE_FILE" + echo "/babel" >> "$EXCLUDE_FILE" + echo "/split.js" >> "$EXCLUDE_FILE" + echo "/mime" >> "$EXCLUDE_FILE" + echo "/DemoProjects" >> "$EXCLUDE_FILE" + echo "/node_modules" >> "$EXCLUDE_FILE" + + cd ../ + + mkdir prebuilt + cd prebuilt + # Download main's latest release + wget "https://github.com/$3/releases/download/branch%2Fmain/splashkitonline-static-site-branch_main.zip" + unzip splashkitonline-static-site-branch_main.zip + rm splashkitonline-static-site-branch_main.zip + cd ../ + + # copy in all the untracked files! + rsync -av --progress --exclude-from="$EXCLUDE_FILE" "prebuilt/" "splashkitonline/Browser_IDE/" + +fi + + +echo "========================================" +echo "Install Node Dependencies" +echo "========================================" +cd ./splashkitonline/Browser_IDE + +npm install + +cd ../../ + + + +echo "========================================" +echo "Re-Structure Static Site" +echo "========================================" +cd ./splashkitonline/Browser_IDE + +# if changed, remember to update the explicit excludes above +mv node_modules/codemirror codemirror-5.65.15 +mv node_modules/jszip/dist jszip +mv node_modules/@babel/standalone babel +mv node_modules/split.js/dist split.js +mv node_modules/mime/dist mime +rm -rf external/js-lzma/data +mv ../DemoProjects DemoProjects + +cd ../ diff --git a/.github/workflows/build_static_site.yml b/.github/workflows/build_static_site.yml new file mode 100644 index 0000000..297f072 --- /dev/null +++ b/.github/workflows/build_static_site.yml @@ -0,0 +1,188 @@ +name: Build Static Site + +on: + # Runs on pushes targeting the default branch + push: + branches: ["deployed", "main"] + + pull_request_target: # use trusted workflow (as opposed to `pull_request`) + types: + - labeled # workaround for manual triggering...if we actually start using labels this might need to be removed + - unlabeled # same + - opened + - reopened + - synchronize + - closed + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: {} + +concurrency: + group: preview-${{ github.ref }} + cancel-in-progress: true + +jobs: + # Creates a build of the website and uploads it as an artifact + # May be running untrusted code, so it's been given very restricted permissions + # Hopefully it can't do anything too bad... + build: + if: ${{ github.event_name != 'pull_request_target' || github.event.action != 'closed' }} + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + env: + GITHUB_TOKEN: '' + + - name: Checkout + uses: actions/checkout@v4 + with: + path: splashkitonline + submodules: 'recursive' + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: '0' + env: + GITHUB_TOKEN: '' + + - name: Checkout scripts + uses: actions/checkout@v4 + with: + path: script + sparse-checkout: | + .github/workflows/ + sparse-checkout-cone-mode: false + + - name: Build static site + working-directory: ./ + run: | + GITHUB_SHA=${{ github.sha }} + if [ "${{ github.event_name }}" == "pull_request_target" ]; then + GITHUB_SHA="${{ github.event.pull_request.head.sha }}" + fi + + cd ./splashkitonline + # only run the `build_static_site.sh` in the PR if the user changed it - otherwise use the latest in main. + if ! git diff --quiet $(git merge-base "origin/main" "$GITHUB_SHA").."$GITHUB_SHA" -- .github/workflows/ &>/dev/null; then + script_path="./splashkitonline/.github/workflows/build_static_site.sh" # use the PR's + else + script_path="./script/.github/workflows/build_static_site.sh" # use main's + fi + cd ../ + echo "using $script_path" + + bash "$script_path" "$GITHUB_SHA" "${{ github.event_name }}" "${{ github.repository }}" + env: + GITHUB_TOKEN: '' + + - name: Upload the build as an artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: preview-${{ github.sha }} + path: ./splashkitonline/Browser_IDE + retention-days: 1 + compression-level: 8 + overwrite: true + + # This part takes that artifact and uploads it as a release + # Perhaps this can be merged into the previous job - just seperated it out for + # potential security concerns (if for instance scripts in the previous job poisoned something) + # We never run the artifact here, so should be completely safe this way. + # Todo: Investigate! + deploy: + needs: build + if: ${{ always() && !failure() && !cancelled() }} # run this job even if the previous one is skipped + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + contents: write + id-token: write + pull-requests: write + environment: + name: static-site + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout scripts # This way it's safe... + uses: actions/checkout@v4 + with: + path: script + sparse-checkout: | + .github/workflows/ + sparse-checkout-cone-mode: false + + - name: Checkout Repo for Tagging + uses: actions/checkout@v4 + with: + path: repo + submodules: 'false' + fetch-depth: '0' + + # Note, we download it _into_ the git folder (so a .git is in a parent dir) + # The edit_release.py script will upload the assets in release_assets.txt, _relative_ to where the script is + # called from. However, it also updates tags in the repo, and so a `.git` directory needs to be somewhere. + # This is all a bit messy, but it works for now. Can be someone else's job to untangle it :P + - name: Download built site + if: ${{ github.event_name != 'pull_request_target' || github.event.action != 'closed' }} + uses: actions/download-artifact@v4.1.8 + with: + name: preview-${{ github.sha }} + path: ./repo/built-site + + - name: Create/Update release + if: ${{ github.event_name != 'pull_request_target' || github.event.action != 'closed' }} + working-directory: ./repo/built-site + run: | + sudo apt-get install zip sed + + if [ "${{ github.event_name }}" == "pull_request_target" ]; then + echo " PR Release! ${{ github.event.number }}" + tag_name="pr/${{ github.event.number }}" + else + echo "Branch Release! ${{ github.ref_name }}" + tag_name="branch/${{ github.ref_name }}" + fi + file_name=$(echo $tag_name | sed "s#/#_#") + + zip -r "../splashkitonline-static-site-$file_name.zip" ./ # note: this name is expected in download_github_site_previews.py + echo "../splashkitonline-static-site-$file_name.zip" >> ../../script/.github/workflows/release_assets.txt + + python3 ../../script/.github/workflows/edit_release.py "update" "${{ secrets.GITHUB_TOKEN }}" "${{ github.repository }}" "$tag_name" "${{ github.sha }}" yes "../../script/.github/workflows/release_assets.txt" "# Static Site Build ($tag_name)\nA static build of $tag_name, used in the live deployment :smiley:" + + repoSiteURL=$(echo ${{ github.repository }} | sed 's/\//.github.io\//') + echo "repoSiteURL=$repoSiteURL" >> $GITHUB_ENV + + - name: Or delete the release... + if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'closed' }} + working-directory: ./repo + run: | + echo " PR Release Delete! ${{ github.ref_name }}" + python3 ../script/.github/workflows/edit_release.py "delete" "${{ secrets.GITHUB_TOKEN }}" "${{ github.repository }}" "pr/${{ github.event.number }}" + + # The following bits assume the GitHub Pages site is about to be updated with this new release preview + - name: Leave a link on the PR + if: ${{ success() && github.event_name == 'pull_request_target' && github.event.action != 'closed' }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-preview + message: | + | :whale2: **PR Preview!** | + | :-----: | + | Preview at https://${{ env.repoSiteURL }}/pr-previews/${{ github.event.number }} | + | for commit ${{ github.event.pull_request.head.sha }} | + + - name: Or delete the link... + if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'closed' }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-preview + message: | + | :whale2: **PR Preview!** | + | :-----: | + | The preview is no more! | + | Congrats if this was merged! :smile: | diff --git a/.github/workflows/deploy_github_site.yml b/.github/workflows/deploy_github_site.yml new file mode 100644 index 0000000..2c96434 --- /dev/null +++ b/.github/workflows/deploy_github_site.yml @@ -0,0 +1,81 @@ +name: Assemble and Deploy Live Site + +on: + workflow_run: + workflows: ['Build Static Site'] + types: + - completed + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: {} + +concurrency: + group: "site_build" + cancel-in-progress: true + +jobs: + # This job downloads and extracts every release that has a splashkitonline-static-site-....zip asset + # It then arranges them into folders, de-duplicates large files, and deploys the result as the GitHub Pages site. + deploy: + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + contents: write + pages: write + id-token: write + pull-requests: write + environment: + name: static-site + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout Scripts + uses: actions/checkout@v4 + with: + path: script + sparse-checkout: | + .github/workflows/ + sparse-checkout-cone-mode: false + + - name: Download Built Sites + working-directory: ./ + run: | + sudo apt-get install tree + python3 ./script/.github/workflows/download_github_site_previews.py "${{ github.repository }}" static-site + tree + + # the directories are named based on the Git tag - let's rename them + cd static-site + mkdir -p "./branch" # just in case + mkdir -p "./pr" # just in case + mv branch branch-previews + mv pr pr-previews + + - name: Structure Deployment # Put everything inside the `deployed` branch's folder + working-directory: ./static-site + run: | + mkdir -p "./branch-previews/deployed" # just in case + mv "./branch-previews/deployed" ../deployed + mv ./* ../deployed/ + + - name: De-duplicate # I really wish GitHub supported hardlinks at least, this would have been much less painful...and save them space! + working-directory: ./deployed + run: python3 ../script/.github/workflows/generate_pr_map.py + + - name: Delete existing page artifact # allows re-run of workflow + uses: geekyeggo/delete-artifact@v5 + with: + name: github-pages + + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload IDE site + path: './deployed' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/download_github_site_previews.py b/.github/workflows/download_github_site_previews.py new file mode 100644 index 0000000..d716248 --- /dev/null +++ b/.github/workflows/download_github_site_previews.py @@ -0,0 +1,64 @@ +# written thanks to the wonders of GenAI, with minimal modifications :D +import os +import requests +import zipfile +import shutil +import sys + +# GitHub repository details +REPO = sys.argv[1] +GITHUB_API_URL = f"https://api.github.com/repos/{REPO}/releases" +HEADERS = {"Accept": "application/vnd.github.v3+json"} # Add authentication if needed + +# Directory where the files will be extracted +STATIC_DIR = sys.argv[2] +os.makedirs(STATIC_DIR, exist_ok=True) + +def get_releases(): + response = requests.get(GITHUB_API_URL, headers=HEADERS) + response.raise_for_status() + return response.json() + +def download_asset(asset_url, filename): + response = requests.get(asset_url, headers=HEADERS, stream=True) + response.raise_for_status() + with open(filename, "wb") as file: + for chunk in response.iter_content(chunk_size=8192): + file.write(chunk) + +def extract_zip(zip_path, extract_to): + os.makedirs(extract_to, exist_ok=True) + with zipfile.ZipFile(zip_path, "r") as zip_ref: + zip_ref.extractall(extract_to) + +def process_release(release, base_dir): + tag_name = release["tag_name"] + asset_url = None + + zip_name = f"splashkitonline-static-site-{tag_name.replace("/","_")}.zip" + + for asset in release["assets"]: + if asset["name"] == zip_name: + asset_url = asset["browser_download_url"] + break + + if asset_url: + print(f"Downloading {tag_name}...") + download_asset(asset_url, zip_name) + extract_zip(zip_name, base_dir) + os.remove(zip_name) + else: + print(f"No {zip_name} found for {tag_name}, skipping...") + +if __name__ == "__main__": + releases = get_releases() + + for release in releases: + try: + release_dir = os.path.join(STATIC_DIR, release["tag_name"]) + print(f"Processing release {release['tag_name']}...") + process_release(release, release_dir) + except Exception as e: + print(f"Failed to process release", release, e) + + print("Done!") diff --git a/.github/workflows/edit_release.py b/.github/workflows/edit_release.py new file mode 100644 index 0000000..7732b82 --- /dev/null +++ b/.github/workflows/edit_release.py @@ -0,0 +1,103 @@ +# written thanks to the wonders of GenAI, with minimal modifications :D +import subprocess +import requests +import os +import sys + +#edit_release.py update +#edit_release.py delete + +assert len(sys.argv[1:]) > 1 +assert sys.argv[1] == "update" or sys.argv[1] == "delete" +if sys.argv[1] == "update": + assert len(sys.argv[1:]) == 8 + assert sys.argv[6] == "yes" or sys.argv[5] == "no" +else: + assert len(sys.argv[1:]) == 4 + +# Configuration +GITHUB_TOKEN = sys.argv[2] +REPO = sys.argv[3] +REPO_URL = f"https://github.com/{REPO}.git" +API_BASE = f"https://api.github.com/repos/{REPO}" +HEADERS = {"Authorization": f"Bearer {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"} + +def run_git_command(*args): + result = subprocess.run(["git", *args], capture_output=True, text=True) + if result.returncode != 0: + print(f"Git command failed: {' '.join(args)}\n{result.stderr}") + exit(1) + return result.stdout.strip() + +def create_or_update_tag(tag_name, sha): + run_git_command("tag", "-f", tag_name, sha) + run_git_command("push", "--force", REPO_URL, tag_name) + print(f"Tag {tag_name} created/updated at {sha}") + +def get_release(tag_name): + url = f"{API_BASE}/releases/tags/{tag_name}" + response = requests.get(url, headers=HEADERS) + return response.json() if response.status_code == 200 else None + +def create_release(tag_name): + url = f"{API_BASE}/releases" + payload = {"tag_name": tag_name, "name": tag_name, "draft": False, "body": sys.argv[8].replace("\\n","\n"), "prerelease": sys.argv[6]=="yes"} + response = requests.post(url, headers=HEADERS, json=payload) + if response.status_code == 201: + return response.json() + else: + print(f"Failed to create release: {response.text}") + exit(1) + +def upload_asset(release_id, file_path): + file_name = os.path.basename(file_path) + delete_existing_asset(release_id, file_name) + url = f"https://uploads.github.com/repos/{REPO}/releases/{release_id}/assets?name={file_name}" + with open(file_path, "rb") as file: + headers = HEADERS.copy() + headers["Content-Type"] = "application/octet-stream" + response = requests.post(url, headers=headers, data=file) + if response.status_code == 201: + print(f"Uploaded {file_name}") + else: + print(f"Failed to upload {file_name}: {response.text}") + +def delete_existing_asset(release_id, asset_name): + url = f"{API_BASE}/releases/{release_id}/assets" + response = requests.get(url, headers=HEADERS) + if response.status_code == 200: + assets = response.json() + for asset in assets: + if asset["name"] == asset_name: + delete_url = asset["url"] + requests.delete(delete_url, headers=HEADERS) + print(f"Deleted existing asset: {asset_name}") + +def delete_tag(tag_name): + run_git_command("push", "--delete", REPO_URL, tag_name) + +def delete_release(release_id): + requests.delete(f"{API_BASE}/releases/{release_id}", headers=HEADERS) + +if __name__ == "__main__": + tag_name = sys.argv[4] + if sys.argv[1] == "update": + sha = sys.argv[5] + create_or_update_tag(tag_name, sha) + + release = get_release(tag_name) or create_release(tag_name) + release_id = release["id"] + + with open(sys.argv[7], "r") as file: + for line in file: + file_path = line.strip() + if os.path.isfile(file_path): + upload_asset(release_id, file_path) + else: + print(f"File not found: {file_path}") + else: + release = get_release(tag_name) + print("Deleting release:", release) + if release: + delete_release(release) + delete_tag(tag_name) diff --git a/.github/workflows/release_assets.txt b/.github/workflows/release_assets.txt new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml deleted file mode 100644 index f5dbb5c..0000000 --- a/.github/workflows/static.yml +++ /dev/null @@ -1,235 +0,0 @@ -name: Deploy current 'deployed'/PR previews - -on: - # Runs on pushes targeting the default branch - push: - branches: ["deployed", "main"] - - pull_request_target: # use trusted workflow (as opposed to `pull_request`) - types: - - opened - - reopened - - synchronize - - closed - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -permissions: {} - -# Allow only one concurrent deployment per PR, 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: preview-${{ github.ref }} - # cancel-in-progress: false - -jobs: - # Creates a build of the website and uploads it as an artifact - # May be running untrusted code, so it's been given very restricted permissions - # Hopefully it can't do anything too bad... - build: - if: ${{ github.event_name != 'pull_request_target' || github.event.action != 'closed' }} - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - env: - GITHUB_TOKEN: '' - - - name: Checkout - uses: actions/checkout@v4 - with: - path: splashkitonline - submodules: 'true' - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - env: - GITHUB_TOKEN: '' - - - name: npm install - working-directory: ./splashkitonline/Browser_IDE - run: | - npm install - env: - GITHUB_TOKEN: '' - - - name: shuffle folders - working-directory: ./splashkitonline/Browser_IDE - run: | - mv node_modules/codemirror codemirror-5.65.15 - mv node_modules/jszip/dist jszip - mv node_modules/@babel/standalone babel - mv node_modules/split.js/dist split.js - mv node_modules/mime/dist mime - rm -rf external/js-lzma/data - mv ../DemoProjects DemoProjects - env: - GITHUB_TOKEN: '' - - - name: download binaries - working-directory: ./splashkitonline/Browser_IDE #python3 ./setup.py - run: | - wget -O splashkit/splashkit_autocomplete.json https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/splashkit/splashkit_autocomplete.json - wget -O runtimes/javascript/bin/SplashKitBackendWASM.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/runtimes/javascript/bin/SplashKitBackendWASM.js - wget -O runtimes/javascript/bin/SplashKitBackendWASM.wasm https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/runtimes/javascript/bin/SplashKitBackendWASM.wasm - wget -O compilers/cxx/bin/wasi-sysroot.zip.lzma https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/wasi-sysroot.zip.lzma - wget -O compilers/cxx/bin/clang++.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/clang++.js - wget -O compilers/cxx/bin/clang.wasm.lzma https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/clang.wasm.lzma - wget -O compilers/cxx/bin/wasm-ld.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/wasm-ld.js - wget -O compilers/cxx/bin/lld.wasm.lzma https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/compilers/cxx/bin/lld.wasm.lzma - wget -O runtimes/cxx/bin/SplashKitBackendWASMCPP.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/runtimes/cxx/bin/SplashKitBackendWASMCPP.js - wget -O runtimes/cxx/bin/SplashKitBackendWASMCPP.worker.js https://raw.githubusercontent.com/WhyPenguins/SplashkitOnline/github-live/Browser_IDE/runtimes/cxx/bin/SplashKitBackendWASMCPP.worker.js - env: - GITHUB_TOKEN: '' - - - name: Upload the build as an artifact - uses: actions/upload-artifact@v4.4.3 - with: - name: preview-${{ github.sha }} - path: ./splashkitonline/Browser_IDE - retention-days: 1 - compression-level: 8 - overwrite: true - - # This part takes that artifact, merges it in to `site-builds` in its respective folder, - # and deploys. - deploy: - needs: build - if: ${{ always() && !failure() && !cancelled() }} # run this job even if the previous one is skipped - # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages - permissions: - contents: write - pages: write - id-token: write - pull-requests: write - environment: - name: static-site - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Download built site - if: ${{ github.event_name != 'pull_request_target' || github.event.action != 'closed' }} - uses: actions/download-artifact@v4.1.8 - with: - name: preview-${{ github.sha }} - path: ./built-site - - - name: Or make an empty folder... # Note: Git will ignore empty folders when commiting - if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'closed' }} - run: mkdir -p built-site - - - name: Checkout Site Builds - uses: actions/checkout@v4 - with: - path: site-builds - submodules: 'false' - ref: site-builds - - - name: Upload Built Archive - working-directory: ./site-builds - env: - action: ${{ github.event.action }} - event: ${{ github.event_name }} - pr: ${{ github.event.number }} - ref: ${{ github.ref_name }} - run: | - git checkout --orphan new-site-builds site-builds - - # clean the directory - delete everything except for pr-previews and .git, a bit hacky really... - mkdir -p ./pr-previews - mkdir -p ./branch-previews - mv ./pr-previews ../ - mv ./branch-previews ../ - mv ./.git ../ - cd ../ && rm -rf site-builds && mkdir site-builds && cd site-builds - mv ../.git ./.git - mv ../pr-previews ./pr-previews - mv ../branch-previews ./branch-previews - - # move the new build in! - if [ "${event}" == "push" ]; then - echo "Branch! ${ref}" - mkdir -p "./branch-previews/${ref}" # also creates parent directories - rm -rf "./branch-previews/${ref}" - mv ../built-site "./branch-previews/${ref}" - elif [ "${event}" == "pull_request_target" ]; then - echo "PR! ${pr}" - rm -rf "./pr-previews/${pr}" - if [ "${action}" != "closed" ]; then - mv ../built-site "./pr-previews/${pr}" - fi - fi - - # commit! - git config --global user.email "buildbot@bot.bot" - git config --global user.name "build-bot-bob" - git add --all --force - git commit -m "Update builds" - git branch -M new-site-builds site-builds - # TODO: This is race condition, if there are two simultaneous PRs only one will survive... - git push origin site-builds --force-with-lease - - repoSiteURL=$(echo ${{ github.repository }} | sed 's/\//.github.io\//') - echo "repoSiteURL=$repoSiteURL" >> $GITHUB_ENV - - - name: Structure Deployment # Put everything inside the `deployed` branch's folder - working-directory: ./site-builds - run: | - mkdir -p "./branch-previews/deployed" # just in case - mv "./branch-previews/deployed" ../deployed - mv ./* ../deployed/ - - - name: Checkout de-duplicate script # This way it's safe... - uses: actions/checkout@v4 - with: - path: script - sparse-checkout: | - .github/workflows/generate_pr_map.py - sparse-checkout-cone-mode: false - - - name: De-duplicate # I really wish GitHub supported hardlinks at least, this would have been much less painful...and save them space! - working-directory: ./deployed - run: python3 ../script/.github/workflows/generate_pr_map.py - - - name: Delete existing page artifact # allows re-run of workflow - uses: geekyeggo/delete-artifact@v5 - with: - name: github-pages - - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload IDE site - path: './deployed' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 - - - name: Leave a link to the PR - if: ${{ success() && github.event_name == 'pull_request_target' && github.event.action != 'closed' }} - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: pr-preview - message: | - | :whale2: **PR Preview!** | - | :-----: | - | Preview at https://${{ env.repoSiteURL }}/pr-previews/${{ github.event.number }} | - | for commit ${{ github.event.pull_request.head.sha }} | - - - name: Or delete the link... - if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'closed' }} - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: pr-preview - message: | - | :whale2: **PR Preview!** | - | :-----: | - | The preview is no more! | - | Congrats if this was merged! :smile: | diff --git a/SplashKitWasm/cmake/CMakeLists.txt b/SplashKitWasm/cmake/CMakeLists.txt index cb9c0a6..d144299 100644 --- a/SplashKitWasm/cmake/CMakeLists.txt +++ b/SplashKitWasm/cmake/CMakeLists.txt @@ -415,6 +415,7 @@ if (EMSCRIPTEN) OUTPUT "${SK_OUT}/cxx/compiler/wasi-sysroot.zip" COMMENT "Bundling C++ Compilation System Root..." + COMMAND ${CMAKE_COMMAND} -E make_directory "${SK_OUT}/cxx/compiler/" COMMAND python "${SK_WASMEXT}/tools/cxx_backend_systemroot_builder.py" $ "${SK_SRC}/coresdk/"