mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
04a3bf76e8
This also upgrades liblzma to 5.4.6, and uses the new ports.contrib system Emscripten 3.1.56 introduced.
103 lines
2.8 KiB
YAML
103 lines
2.8 KiB
YAML
name: Preview build
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
PREVIEW_CLOUDFLARE_API_TOKEN:
|
|
description: API token to upload a preview to Cloudflare Pages
|
|
required: true
|
|
PREVIEW_CLOUDFLARE_ACCOUNT_ID:
|
|
description: Account ID to upload a preview to Cloudflare Pages
|
|
required: true
|
|
|
|
jobs:
|
|
preview:
|
|
name: Build preview
|
|
|
|
environment:
|
|
name: preview
|
|
url: https://preview.openttd.org/pr${{ github.event.pull_request.number }}/
|
|
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
# If you change this version, change the number in the cache step too.
|
|
image: emscripten/emsdk:3.1.57
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Name branch
|
|
run: |
|
|
git config --global --add safe.directory ${GITHUB_WORKSPACE}
|
|
git checkout -b pr${{ github.event.pull_request.number }}
|
|
|
|
- name: Setup cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: /emsdk/upstream/emscripten/cache
|
|
key: 3.1.57-${{ runner.os }}
|
|
|
|
- name: Add liblzma support
|
|
run: |
|
|
cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
|
|
|
|
- name: Build (host tools)
|
|
run: |
|
|
mkdir build-host
|
|
cd build-host
|
|
|
|
echo "::group::CMake"
|
|
cmake .. -DOPTION_TOOLS_ONLY=ON
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::Build"
|
|
echo "Running on $(nproc) cores"
|
|
make -j$(nproc) tools
|
|
echo "::endgroup::"
|
|
|
|
- name: Install GCC problem matcher
|
|
uses: ammaraskar/gcc-problem-matcher@master
|
|
|
|
- name: Build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
|
|
echo "::group::CMake"
|
|
emcmake cmake .. \
|
|
-DHOST_BINARY_DIR=../build-host \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
# EOF
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::Build"
|
|
echo "Running on $(nproc) cores"
|
|
cmake --build . -j $(nproc) --target openttd
|
|
echo "::endgroup::"
|
|
|
|
- name: Prepare preview
|
|
run: |
|
|
mkdir public
|
|
|
|
cp build/openttd.data public/
|
|
cp build/openttd.html public/
|
|
cp build/openttd.js public/
|
|
cp build/openttd.wasm public/
|
|
|
|
# Ensure we use the latest version of npm; the one we get with current
|
|
# emscripten doesn't allow running "npx wrangler" as root.
|
|
# Current emscripten can't install npm>=10.0.0 because node is too old.
|
|
npm install -g npm@9
|
|
|
|
- name: Publish preview
|
|
uses: cloudflare/pages-action@v1
|
|
with:
|
|
apiToken: ${{ secrets.PREVIEW_CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.PREVIEW_CLOUDFLARE_ACCOUNT_ID }}
|
|
projectName: ${{ vars.PREVIEW_CLOUDFLARE_PROJECT_NAME }}
|
|
directory: public
|
|
branch: pr${{ github.event.pull_request.number }}
|