ci: fix YAML (sort le patch Android dans un script, plus de heredoc)
Build APK / build (push) Failing after 52s
Build APK / build (push) Failing after 52s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
8a71eb60d8
commit
f103134762
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Patche le scaffold Android généré par `flutter create` :
|
||||
- permissions (internet + auto-install APK)
|
||||
- signature release depuis key.properties
|
||||
- schéma de redirection OIDC (flutter_appauth)
|
||||
Lancé dans la CI après `flutter create`. Idempotent."""
|
||||
import os
|
||||
import re
|
||||
|
||||
KSPW = os.environ["KSPW"]
|
||||
ALIAS = os.environ["ALIAS"]
|
||||
|
||||
# 1) key.properties
|
||||
with open("android/key.properties", "w") as f:
|
||||
f.write(
|
||||
f"storePassword={KSPW}\n"
|
||||
f"keyPassword={KSPW}\n"
|
||||
f"keyAlias={ALIAS}\n"
|
||||
"storeFile=/app/gamemanager.keystore\n"
|
||||
)
|
||||
|
||||
# 2) AndroidManifest : permissions
|
||||
man = "android/app/src/main/AndroidManifest.xml"
|
||||
s = open(man).read()
|
||||
perms = (
|
||||
'<uses-permission android:name="android.permission.INTERNET"/>\n'
|
||||
' <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>\n'
|
||||
)
|
||||
if "REQUEST_INSTALL_PACKAGES" not in s:
|
||||
s = s.replace("<application", perms + " <application", 1)
|
||||
open(man, "w").write(s)
|
||||
|
||||
# 3) build.gradle : signature + schéma OIDC
|
||||
gr = "android/app/build.gradle"
|
||||
s = open(gr).read()
|
||||
if "keystoreProperties" not in s:
|
||||
s = (
|
||||
'def keystoreProperties = new Properties()\n'
|
||||
'def keystorePropertiesFile = rootProject.file("key.properties")\n'
|
||||
'if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) }\n\n'
|
||||
) + s
|
||||
if "appAuthRedirectScheme" not in s:
|
||||
s = s.replace(
|
||||
"defaultConfig {",
|
||||
'defaultConfig {\n manifestPlaceholders += [appAuthRedirectScheme: "nfteam.gamemanager"]',
|
||||
1,
|
||||
)
|
||||
if "signingConfigs {" not in s:
|
||||
s = re.sub(
|
||||
r"(\n\s*buildTypes\s*\{)",
|
||||
'\n signingConfigs {\n'
|
||||
' release {\n'
|
||||
' keyAlias keystoreProperties["keyAlias"]\n'
|
||||
' keyPassword keystoreProperties["keyPassword"]\n'
|
||||
' storeFile file(keystoreProperties["storeFile"])\n'
|
||||
' storePassword keystoreProperties["storePassword"]\n'
|
||||
' }\n }\n\\1',
|
||||
s,
|
||||
count=1,
|
||||
)
|
||||
s = s.replace("signingConfig signingConfigs.debug", "signingConfig signingConfigs.release")
|
||||
open(gr, "w").write(s)
|
||||
print("patch_android: OK")
|
||||
Reference in New Issue
Block a user