Skip to content

Commit 2bba28b

Browse files
committed
feat: android build workflow
1 parent 752bea4 commit 2bba28b

File tree

9 files changed

+95
-9
lines changed

9 files changed

+95
-9
lines changed
261 Bytes
Loading
248 Bytes
Loading
5.38 KB
Loading
5.42 KB
Loading
5.54 KB
Loading

.github/workflows/compile.yaml

+37-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
path: main
1010
submodules: true
1111
name: Checkout Repository
12+
- name: Extract Metadata
13+
id: metadata
14+
run: python3 main/.scripts/extract-metadata.py
1215
- name: Add Universe Repository
1316
run: sudo add-apt-repository universe
1417
- name: Update Packages
@@ -18,29 +21,57 @@ jobs:
1821
- name: Install makelove
1922
run: pip3 install git+https://github.com/pfirsich/makelove/
2023
- name: Build
21-
run: cd main && python3 -m makelove
24+
run: cd main && python3 -m makelove && cd ..
25+
- name: Build (Android)
26+
id: build-android
27+
uses: love-actions/love-actions-android@v1
28+
with:
29+
app-name: ${{ steps.metadata.outputs.title }}
30+
bundle-id: net.stabyourself.${{ steps.metadata.outputs.id }}
31+
product-name: ${{ steps.metadata.outputs.id }}
32+
resource-path: "main/.android-resources"
33+
love-ref: ${{ steps.metadata.outputs.love-version }}
34+
love-package: main/makelove-build/love/${{ env.ARTIFACT_NAME_LOVE }}
35+
version-string: ${{ steps.metadata.outputs.version }}
36+
version-code: ${{ steps.metadata.outputs.android-version }}
37+
output-folder: "main/makelove-build/android"
38+
keystore-alias: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
39+
keystore-base64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
40+
keystore-key-password: ${{ secrets.ANDROID_KEYSTORE_KEYPASSWORD }}
41+
keystore-store-password: ${{ secrets.ANDROID_KEYSTORE_STOREPASSWORD }}
2242
- name: Artifact (LÖVE)
2343
uses: actions/upload-artifact@v3
2444
with:
25-
name: a99e-source
45+
name: ${{ steps.metadata.outputs.id }}-source
2646
path: main/makelove-build/love/${{ env.ARTIFACT_NAME_LOVE }}
2747
- name: Artifact (AppImage)
2848
uses: actions/upload-artifact@v3
2949
with:
30-
name: a99e-linux
50+
name: ${{ steps.metadata.outputs.id }}-linux
3151
path: main/makelove-build/appimage/${{ env.ARTIFACT_NAME_APPIMAGE }}
3252
- name: Artifact (Win64)
3353
uses: actions/upload-artifact@v3
3454
with:
35-
name: a99e-win64
55+
name: ${{ steps.metadata.outputs.id }}-win64
3656
path: main/makelove-build/win64/${{ env.ARTIFACT_NAME_WIN64 }}
3757
- name: Artifact (Win32)
3858
uses: actions/upload-artifact@v3
3959
with:
40-
name: a99e-win32
60+
name: ${{ steps.metadata.outputs.id }}-win32
4161
path: main/makelove-build/win32/${{ env.ARTIFACT_NAME_WIN32 }}
4262
- name: Artifact (MacOS)
4363
uses: actions/upload-artifact@v3
4464
with:
45-
name: a99e-macos
65+
name: ${{ steps.metadata.outputs.id }}-macos
4666
path: main/makelove-build/macos/${{ env.ARTIFACT_NAME_MACOS }}
67+
- name: Artifact (Android Debug)
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: ${{ steps.metadata.outputs.id }}-android-debug
71+
path: main/makelove-build/android/${{ steps.metadata.outputs.id }}-debug.apk
72+
- name: Artifact (Android Release)
73+
if: "${{ secrets.ANDROID_KEYSTORE_ALIAS != '' && secrets.ANDROID_KEYSTORE_BASE64 != '' && secrets.ANDROID_KEYSTORE_KEYPASSWORD != '' && secrets.ANDROID_KEYSTORE_STOREPASSWORD != '' }}"
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: ${{ steps.metadata.outputs.id }}-android-release
77+
path: main/makelove-build/android/${{ steps.metadata.outputs.id }}-release.apk

.scripts/extract-metadata.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
Extracts game metadata from main.lua and makelove.toml
5+
and writes it out for use by GitHub Actions.
6+
7+
Authored by @qixils
8+
'''
9+
10+
import os
11+
from pathlib import Path
12+
import re
13+
14+
game_path: Path = Path(__file__).parent.resolve()
15+
main_path: Path = game_path / 'main.lua'
16+
conf_path: Path = game_path / 'conf.lua'
17+
toml_path: Path = game_path / 'makelove.toml'
18+
metadata: dict[str, str] = {} # TODO: dataclass
19+
20+
with open(main_path, 'r') as main_file:
21+
main = main_file.read()
22+
metadata['title'] = re.search(r'love\.window\.setTitle\(\s*"(.+)"\s*\)', main).group(1)
23+
metadata['version'] = re.search(r'^VERSION\s*=\s*(.+)$', main, re.MULTILINE).group(1)
24+
metadata['android-version'] = re.search(r'^ANDROIDVERSION\s*=\s*(.+)$', main, re.MULTILINE).group(1)
25+
26+
with open(conf_path, 'r') as conf_file:
27+
conf = conf_file.read()
28+
metadata['love-version'] = re.search(r'^\s*t\.version\s*=\s*"(.+)"$', conf, re.MULTILINE).group(1)
29+
30+
with open(toml_path, 'r') as toml_file:
31+
toml = toml_file.read()
32+
metadata['id'] = re.search(r'^name\s*=\s*"(.+)"', toml).group(1)
33+
# ensure title is the same as the one in main.lua
34+
# TODO: don't assert, just print a GH Actions warning (idk how)
35+
if metadata['title'] != re.search(r'^ProductName\s*=\s*"(.+)"$', toml, re.MULTILINE).group(1):
36+
print('::error file=makelove.toml::Windows product name does not match game title in main.lua')
37+
if metadata['title'] != re.search(r'^[linux.desktop_file_metadata]\r?\nName\s*=\s*"(.+)"$', toml, re.MULTILINE).group(1):
38+
print('::error file=makelove.toml::Linux desktop file name does not match game title in main.lua')
39+
if metadata['title'] != re.search(r'^CFBundleDisplayName\s*=\s*"(.+)"$', toml, re.MULTILINE).group(1):
40+
print('::error file=makelove.toml::macOS bundle display name does not match game title in main.lua')
41+
42+
with open(os.environ['GITHUB_OUTPUT'], 'a') as env_file:
43+
for key, value in metadata.items():
44+
env_file.write(f'{key}={value}\n')

main.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--[[
22
STEAL MY SHIT AND I'LL FUCK YOU UP
3-
PRETTY MUCH EVERYTHING BY MAURICE GU�GAN AND IF SOMETHING ISN'T BY ME THEN IT SHOULD BE OBVIOUS OR NOBODY CARES
3+
PRETTY MUCH EVERYTHING BY MAURICE GUÉGAN AND IF SOMETHING ISN'T BY ME THEN IT SHOULD BE OBVIOUS OR NOBODY CARES
44
55
Please keep in mind that for obvious reasons, I do not hold the rights to artwork, audio or trademarked elements of the game.
66
This license only applies to the code and original other assets. Obviously. Duh.
@@ -58,6 +58,7 @@ local debugGraphs = false
5858

5959
VERSION = 13.0124
6060
VERSIONSTRING = "13e (3/7/22)"
61+
ANDROIDVERSION = 16
6162

6263
android = (love.system.getOS() == "Android" or love.system.getOS() == "iOS") --[DROID]
6364
androidtest = false--testing android on pc

makelove.toml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
name = "a99e"
1+
name = "mari0_ae"
22
default_targets = ["win32", "win64", "appimage", "macos"]
33
build_directory = "makelove-build"
44
icon_file = "graphics/icon.png"
5-
love_version = "11.4"
65

76
love_files = [
87
"::git-ls-tree::",
98
"-*/.*",
109
]
10+
11+
# TODO: more metadata
12+
13+
[windows.exe_metadata]
14+
ProductName = "Mari0: AE"
15+
16+
[linux.desktop_file_metadata]
17+
Name = "Mari0: AE"
18+
19+
[macos.app_metadata]
20+
CFBundleDisplayName = "Mari0: AE"

0 commit comments

Comments
 (0)