Skip to content

Commit 80440de

Browse files
committed
ci: Use Amalgamate Pages for web builds
Previously, only the `main` branch was published to GitHub Pages. Copy the separate build + publish workflows from Threadbare, excluding the logic to save the .pck file and build a Flatpak bundle, but including the logic to attach the web bundle to releases.
1 parent 008840b commit 80440de

2 files changed

Lines changed: 102 additions & 97 deletions

File tree

.github/workflows/export.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: "Build and Export Game"
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
release:
6+
types:
7+
- published
8+
push:
9+
branches:
10+
- '*'
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
15+
env:
16+
GODOT_VERSION: 4.4.1
17+
18+
jobs:
19+
build:
20+
name: Build for web
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
lfs: true
27+
28+
- name: Cache Godot Engine downloads
29+
id: cache-godot
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
build/godot
34+
build/._sc_
35+
build/editor_data/export_templates/${{ env.GODOT_VERSION }}.stable
36+
key: godot-${{ env.GODOT_VERSION }}
37+
38+
- name: Download Godot Engine from GitHub release
39+
id: download
40+
if: steps.cache-godot.outputs.cache-hit != 'true'
41+
run: |
42+
mkdir -p build && cd build
43+
44+
# Download Godot Engine itself
45+
wget --progress=dot:giga https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \
46+
unzip Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \
47+
mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 godot
48+
49+
# Download export templates
50+
mkdir -p editor_data/export_templates
51+
wget --progress=dot:giga https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \
52+
unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \
53+
mv templates editor_data/export_templates/${GODOT_VERSION}.stable
54+
55+
# Tell Godot Engine to run in "self-contained" mode so it looks for
56+
# templates here instead of in ~/.local/share/godot/
57+
touch ._sc_
58+
59+
- name: Export web release
60+
run: |
61+
mkdir -v -p build/web && cd build
62+
63+
# Note that the export path can be confusing; it's relative to the
64+
# Godot project path, NOT necessarily the current directory or Godot
65+
# binary location
66+
./godot --headless --verbose --path ../ --export-release "Web" ./build/web/index.html
67+
68+
- name: Upload web artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: web
72+
path: build/web
73+
74+
release:
75+
name: Attach to release
76+
needs: [build]
77+
if: ${{ github.event_name == 'release' }}
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Download web bundle
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: web
84+
path: web
85+
86+
- name: Attach web bundle to release
87+
env:
88+
GITHUB_TOKEN: ${{ github.token }}
89+
run: |
90+
pushd web
91+
zip -r "../moddable-platformer-${{ github.ref_name }}-web.zip" .
92+
popd
93+
94+
gh release upload '${{ github.ref_name }}' 'moddable-platformer-${{ github.ref_name }}-web.zip' --repo '${{ github.repository }}'

.github/workflows/github-pages.yml

Lines changed: 8 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,27 @@
11
name: "Publish to GitHub Pages"
22
on:
3+
delete:
34
workflow_dispatch:
4-
release:
5+
workflow_run:
6+
workflows:
7+
- "Build and Export Game"
58
types:
6-
- published
9+
- completed
710

8-
# Cancel any ongoing previous run if the job is re-triggered
911
concurrency:
1012
group: ${{ github.workflow }}
11-
cancel-in-progress: true
1213

1314
permissions:
1415
contents: read
1516
pages: write
1617
id-token: write
1718

18-
env:
19-
GODOT_VERSION: 4.4
20-
2119
jobs:
22-
check:
23-
name: Check if GitHub Pages is enabled
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Check
27-
id: check
28-
env:
29-
GH_TOKEN: ${{ github.token }}
30-
run: |
31-
if gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"'
32-
then
33-
echo "enabled=true" >> "$GITHUB_OUTPUT"
34-
else
35-
echo "# Not published to GitHub Pages" >> "$GITHUB_STEP_SUMMARY"
36-
echo "" >> "$GITHUB_STEP_SUMMARY"
37-
echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY"
38-
echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY"
39-
fi
40-
outputs:
41-
enabled: ${{ steps.check.outputs.enabled }}
42-
43-
build:
44-
name: Build for web
45-
needs:
46-
- check
47-
if: ${{ needs.check.outputs.enabled }}
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v4
52-
with:
53-
lfs: true
54-
55-
- name: Cache Godot Engine downloads
56-
id: cache-godot
57-
uses: actions/cache@v4
58-
with:
59-
path: |
60-
build/godot
61-
build/._sc_
62-
build/editor_data/export_templates/${{ env.GODOT_VERSION }}.stable
63-
key: godot-${{ env.GODOT_VERSION }}
64-
65-
- name: Download Godot Engine from GitHub release
66-
id: download
67-
if: steps.cache-godot.outputs.cache-hit != 'true'
68-
run: |
69-
mkdir -p build && cd build
70-
71-
# Download Godot Engine itself
72-
wget https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \
73-
unzip Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip && \
74-
mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 godot
75-
76-
# Download export templates
77-
mkdir -p editor_data/export_templates
78-
wget https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \
79-
unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz && \
80-
mv templates editor_data/export_templates/${GODOT_VERSION}.stable
81-
82-
# Tell Godot Engine to run in "self-contained" mode so it looks for
83-
# templates here instead of in ~/.local/share/godot/
84-
touch ._sc_
85-
86-
- name: Web Build
87-
run: |
88-
mkdir -v -p build/web && cd build
89-
90-
# Note that the export path can be confusing; it's relative to the
91-
# Godot project path, NOT necessarily the current directory or Godot
92-
# binary location
93-
./godot --headless --verbose --path ../ --export-release "Web" ./build/web/index.html
94-
95-
- name: Upload Artifact
96-
uses: actions/upload-pages-artifact@v3
97-
with:
98-
name: web
99-
path: build/web
100-
10120
publish:
102-
name: Publish to GitHub Pages
103-
needs:
104-
- build
21+
name: Publish all branches to GitHub Pages
10522
runs-on: ubuntu-latest
10623
steps:
107-
- id: deploy
108-
name: Deploy to GitHub Pages
109-
uses: actions/deploy-pages@v4
24+
- uses: endlessm/amalgamate-pages@v1
11025
with:
26+
workflow_name: "Build and Export Game"
11127
artifact_name: web
112-
113-
- name: Show URL in summary
114-
if: ${{ steps.deploy.outcome == 'success' }}
115-
run: |
116-
echo "Game published to: <${{ steps.deploy.outputs.page_url }}>" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)