add android build

This commit is contained in:
olebeck 2023-03-06 16:47:02 +01:00
parent 06cf948913
commit 818aa73a3e
3 changed files with 35 additions and 36 deletions

View File

@ -13,12 +13,6 @@ jobs:
fetch-depth: 0
- run: |
git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: '1.20'
check-latest: true
cache: true
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3

View File

@ -23,6 +23,7 @@ PLATFORMS = [
("windows", ["386", "amd64"], ".exe"),
("linux", ["386", "amd64", "arm", "arm64"], ""),
#("darwin", ["amd64", "arm64"], ""),
("android", ["arm64"], ".apk")
]
platform_filter = ""
@ -52,9 +53,13 @@ for (platform_name, archs, ext) in PLATFORMS:
if len(archs) == 0:
continue
for GUI in [False, True]:
if platform_name in ["android"] and not GUI:
continue
print(f"Building {platform_name} gui: {GUI}")
SUB1 = '-gui' if GUI else ''
exe_name = f"{NAME}{SUB1}{ext}"
name = f"{NAME}{SUB1}"
exe_name = f"{name}{ext}"
env = ["GOVCS=*:off"]
GOFLAGS = []
@ -69,7 +74,7 @@ for (platform_name, archs, ext) in PLATFORMS:
"-app-version", VER,
"-arch", ",".join(archs),
"-ldflags", LDFLAGS + f" -X github.com/bedrock-tool/bedrocktool/utils.CmdName=bedrocktool-gui",
"-name", exe_name,
"-name", name,
"-tags", "gui",
"-debug"
]
@ -77,7 +82,7 @@ for (platform_name, archs, ext) in PLATFORMS:
args.extend(["-env", e])
if platform_name == "windows":
args.append("-console")
if platform_name == "darwin":
if platform_name in ["android"]:
args.extend(["-app-id", APP_ID])
args.append("./cmd/bedrocktool")
out = subprocess.run(args)
@ -102,33 +107,33 @@ for (platform_name, archs, ext) in PLATFORMS:
out.check_returncode()
for arch in archs:
if GUI:
exe_path = f"./fyne-cross/bin/{platform_name}-{arch}/{exe_name}"
else:
exe_path = f"./tmp/{platform_name}-{arch}/{exe_name}"
with open(exe_path, "rb") as f:
exe_data = f.read()
sha = binascii.b2a_base64(hashlib.sha256(exe_data).digest()).decode("utf8").split("\n")[0]
exe_out_path = f"./builds/{NAME}-{platform_name}-{arch}-{TAG}{SUB1}{ext}"
with open(exe_out_path, "wb") as f:
f.write(exe_data)
os.chmod(exe_out_path, os.stat(exe_out_path).st_mode | stat.S_IEXEC)
updates_dir = f"./updates/{NAME}{SUB1}"
os.makedirs(updates_dir, exist_ok=True)
with open(f"{updates_dir}/{platform_name}-{arch}.json", "w") as f:
f.write(json.dumps({
"Version": TAG,
"Sha256": sha,
}, indent=2))
os.makedirs(f"{updates_dir}/{TAG}", exist_ok=True)
with gzip.open(f"{updates_dir}/{TAG}/{platform_name}-{arch}.gz", "wb") as f:
f.write(exe_data)
if platform_name == "android":
apk_path = f"./fyne-cross/dist/android-{arch}/{exe_name}"
#shutil.copy(apk_path, exe_out_path) # dont upload builds yet, its not usable lol
else:
if GUI:
exe_path = f"./fyne-cross/bin/{platform_name}-{arch}/{exe_name}"
else:
exe_path = f"./tmp/{platform_name}-{arch}/{exe_name}"
with open(exe_path, "rb") as f:
exe_data = f.read()
sha = binascii.b2a_base64(hashlib.sha256(exe_data).digest()).decode("utf8").split("\n")[0]
shutil.copy(exe_path, exe_out_path)
if not GUI:
os.remove(exe_path)
updates_dir = f"./updates/{NAME}{SUB1}"
os.makedirs(updates_dir, exist_ok=True)
with open(f"{updates_dir}/{platform_name}-{arch}.json", "w") as f:
f.write(json.dumps({
"Version": TAG,
"Sha256": sha,
}, indent=2))
os.makedirs(f"{updates_dir}/{TAG}", exist_ok=True)
with gzip.open(f"{updates_dir}/{TAG}/{platform_name}-{arch}.gz", "wb") as f:
f.write(exe_data)
if not GUI:
os.remove(exe_path)

View File

@ -1,4 +1,4 @@
//go:build gui
//go:build gui || android
package gui