Skip to content

Commit a4facff

Browse files
committed
Rewrite CI to use a Python script , setup step, and build matrix to build platforms in parallel
Close #1203
1 parent 45799c0 commit a4facff

4 files changed

Lines changed: 590 additions & 762 deletions

File tree

.github/workflows/ExportGodot.yaml

Lines changed: 86 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# this actions workflow builds large dscript for desktop plus web. It also has
2+
# some steps to deploy to itch.io through their upload program butler. We have a
3+
# copy of the app on itch.
14
name: "Export Godot"
25

36
on:
@@ -12,125 +15,120 @@ env:
1215
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
1316
ITCHIO_USERNAME: ${{ secrets.ITCHIO_USERNAME }}
1417
ITCHIO_GAME: ${{ secrets.ITCHIO_GAME }}
15-
git_branch: ${{ github.ref_name }}
18+
BUILD_GIT_COMMIT: ${{ github.sha }}
19+
BUILD_GIT_BRANCH: ${{ github.ref_name }}
1620

1721
jobs:
18-
export-linux:
19-
name: Linux Export
22+
# This setup job runs only once and first to prepare the environment to avoid
23+
# downloading Godot and the export templates multiple times.
24+
setup:
25+
name: Setup environment
2026
runs-on: ubuntu-latest
2127
container: registry.gitlab.com/greenfox/godot-build-automation:latest
2228
steps:
2329
- name: Checkout
2430
uses: actions/checkout@v4
2531
with:
2632
lfs: false
33+
2734
- name: Load .env file
28-
run: cat .env >> "$GITHUB_ENV"
29-
- name: Make run executable
30-
run: chmod +x run
31-
- run: ./run prepare:ci
32-
- run: ./run export:linux
33-
- name: Push to itch.io
34-
if: github.ref_name == 'release'
35-
run: ./run push:linux
36-
- name: Upload Linux Artifact
35+
run: |
36+
if [ -f .env ]; then
37+
cat .env >> "$GITHUB_ENV"
38+
else
39+
echo "Warning: .env file not found, skipping"
40+
fi
41+
42+
- name: Install Python 3
43+
run: apt-get update && apt-get install -y --no-install-recommends python3
44+
45+
- name: Prepare CI environment
46+
run: python3 build.py prepare ci
47+
48+
- name: Upload prepared source
3749
uses: actions/upload-artifact@v4
3850
with:
39-
name: linux
40-
path: build/linux
41-
- name: Releases
42-
uses: svenstaro/upload-release-action@v2
43-
with:
44-
repo_token: ${{ secrets.GITHUB_TOKEN }}
45-
file: build/linux/*
46-
tag: linux
47-
file_glob: true
48-
overwrite: true
51+
name: prepared-source
52+
path: |
53+
.
54+
!.git
55+
retention-days: 1
56+
include-hidden-files: true
4957

50-
export-win:
51-
name: Windows Export
58+
export:
59+
name: Export ${{ matrix.platform }}
60+
needs: setup
5261
runs-on: ubuntu-latest
53-
container: registry.gitlab.com/greenfox/godot-build-automation:latest
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
platform: [linux, windows, osx, web]
66+
include:
67+
- platform: linux
68+
artifact_name: linux
69+
release_tag: linux
70+
- platform: windows
71+
artifact_name: windows
72+
release_tag: windows
73+
- platform: osx
74+
artifact_name: macos-build
75+
release_tag: osx
76+
- platform: web
77+
artifact_name: web
78+
release_tag: ""
79+
5480
steps:
55-
- name: Checkout
81+
- name: Checkout for GitHub Pages deploy
82+
if: matrix.platform == 'web'
5683
uses: actions/checkout@v4
5784
with:
5885
lfs: false
59-
- name: Load .env file
60-
run: cat .env >> "$GITHUB_ENV"
61-
- name: Make run executable
62-
run: chmod +x run
63-
- run: ./run prepare:ci
64-
- run: ./run export:windows
65-
- name: Push to itch.io
66-
if: github.ref_name == 'release'
67-
run: ./run push:windows
68-
- name: Artifact
69-
uses: actions/upload-artifact@v4
70-
with:
71-
name: windows
72-
path: build/windows
73-
- name: Releases
74-
uses: svenstaro/upload-release-action@v2
75-
with:
76-
repo_token: ${{ secrets.GITHUB_TOKEN }}
77-
file: build/windows/*
78-
tag: windows
79-
file_glob: true
80-
overwrite: true
8186

82-
export-osx:
83-
name: OSX Export
84-
runs-on: ubuntu-latest
85-
container: registry.gitlab.com/greenfox/godot-build-automation:latest
86-
steps:
87-
- name: Checkout
88-
uses: actions/checkout@v4
87+
- name: Download prepared source
88+
uses: actions/download-artifact@v4
8989
with:
90-
lfs: false
90+
name: prepared-source
91+
92+
- name: Make Godot executable and set up environment
93+
run: |
94+
chmod +x ./godot
95+
echo "$PWD" >> $GITHUB_PATH
96+
echo "GODOT_TEMPLATES_DIR=$PWD/templates" >> $GITHUB_ENV
97+
9198
- name: Load .env file
92-
run: cat .env >> "$GITHUB_ENV"
93-
- name: Make run executable
94-
run: chmod +x run
95-
- run: ./run prepare:ci
96-
- run: ./run export:osx
99+
run: |
100+
if [ -f .env ]; then
101+
cat .env >> "$GITHUB_ENV"
102+
else
103+
echo "Warning: .env file not found, skipping"
104+
fi
105+
106+
- name: Export for ${{ matrix.platform }}
107+
run: python3 build.py export ${{ matrix.platform }}
108+
97109
- name: Push to itch.io
98110
if: github.ref_name == 'release'
99-
run: ./run push:osx
100-
- name: Artifact
111+
run: python3 build.py push ${{ matrix.platform }}
112+
113+
- name: Upload artifact
101114
uses: actions/upload-artifact@v4
102115
with:
103-
name: macos-build
104-
path: build/osx
105-
retention-days: 30
106-
- name: Upload macOS Release
116+
name: ${{ matrix.artifact_name }}
117+
path: build/${{ matrix.platform }}
118+
retention-days: ${{ matrix.platform == 'osx' && 30 || 90 }}
119+
120+
- name: Upload desktop builds to GitHub Releases
121+
if: matrix.release_tag != ''
107122
uses: svenstaro/upload-release-action@v2
108123
with:
109124
repo_token: ${{ secrets.GITHUB_TOKEN }}
110-
file: build/osx/*
111-
tag: osx
125+
file: build/${{ matrix.platform }}/*
126+
tag: ${{ matrix.release_tag }}
112127
file_glob: true
113128
overwrite: true
114129

115-
export-web:
116-
name: Web Export
117-
runs-on: ubuntu-latest
118-
container: registry.gitlab.com/greenfox/godot-build-automation:latest
119-
steps:
120-
- name: Checkout
121-
uses: actions/checkout@v4
122-
with:
123-
lfs: false
124-
- name: Load .env file
125-
run: cat .env >> "$GITHUB_ENV"
126-
- name: Make run executable
127-
run: chmod +x run
128-
- run: ./run prepare:ci
129-
- run: ./run export:web
130-
- name: Push to itch.io
131-
if: github.ref_name == 'release'
132-
run: ./run push:web
133-
- name: Deploy to GitHub Pages 🚀
130+
- name: Deploy web build to GitHub Pages
131+
if: matrix.platform == 'web'
134132
uses: JamesIves/github-pages-deploy-action@v4
135133
with:
136134
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)