Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| affc407f5e | |||
| 29f29a4524 |
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 202
|
||||
versionName = "2.0.2"
|
||||
versionCode = 203
|
||||
versionName = "2.0.3"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
@@ -39,14 +39,52 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名。
|
||||
*
|
||||
* ★ 为什么要自己配一个 keystore,而不是用 debug 默认的:
|
||||
*
|
||||
* 1. **debug 证书换机器就变**。用 debug 包发出去,换台电脑构建出来的
|
||||
* 签名指纹不一样,用户装的时候必须**先卸载**(Android 不允许
|
||||
* 同包名不同签名覆盖安装)。发出去的包就成了"只能装一次"的。
|
||||
*
|
||||
* 2. **默认只签 v2/v3,缺 v1(JAR)签名**。Android 7+ 自己装没问题,
|
||||
* 但很多安装器(比如从远程传过去的)和严格的 ROM 会按 v1 检查,
|
||||
* 报"解析失败:安装包没有签名文件" —— 这个真踩到了。
|
||||
* 下面显式把 v1/v2/v3 全开。
|
||||
*
|
||||
* ★ 密码就写在这里,**它不是秘密**:keystore 也提交进仓库了。
|
||||
* 这是个**自签**证书,目的是"指纹稳定、能覆盖安装",不是"证明是谁发的"。
|
||||
* 谁拿到这个仓库谁就能签出一样的包 —— 对这个本地工具来说够了。
|
||||
* (真要防伪得保护 keystore + 用 CI 的密钥管理,那是另一件事。)
|
||||
*/
|
||||
signingConfigs {
|
||||
create("doubao") {
|
||||
storeFile = file("../doubao-release.jks")
|
||||
storePassword = "doubao-clone"
|
||||
keyAlias = "doubao"
|
||||
keyPassword = "doubao-clone"
|
||||
// ★ 三个方案全开:v1 给老安装器,v2/v3 给新系统
|
||||
enableV1Signing = true
|
||||
enableV2Signing = true
|
||||
enableV3Signing = true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("doubao")
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
}
|
||||
debug {
|
||||
// debug 包也用它 —— 这样"我本地调试的包"和"发出去的包"
|
||||
// 签名一致,能互相覆盖安装,不用来回卸载
|
||||
signingConfig = signingConfigs.getByName("doubao")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
BIN
android/doubao-release.jks
Normal file
BIN
android/doubao-release.jks
Normal file
Binary file not shown.
@@ -1,14 +1,35 @@
|
||||
"""发 release 附件:用 Python 而不是 PowerShell(后者序列化中文/多行会翻车)"""
|
||||
"""
|
||||
发 release:建说明 + 传 APK 附件。
|
||||
|
||||
用法:
|
||||
python scripts/publish-release.py v2.0.2 scripts/.tmp-v202.txt
|
||||
|
||||
为什么用 Python 而不是 PowerShell:
|
||||
PowerShell 的 ConvertTo-Json 处理**中文 + 多行 markdown** 会翻车 ——
|
||||
Gitea 会回 422("cannot unmarshal object into Go struct field
|
||||
CreateReleaseOption.Note of type string"),而且看不出哪里错了。
|
||||
这个坑真踩过两次,所以这个脚本固定用 Python。
|
||||
|
||||
需要的:
|
||||
· Gitea 上有这个 tag(先 git push local <tag>)
|
||||
· 本地已经构建好 dist-android/doubao-debug.apk
|
||||
"""
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request as u
|
||||
|
||||
WS = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
API = 'http://192.168.100.103:8080/api/v1/repos/l/doubao-clone'
|
||||
AUTH = 'Basic ' + __import__('base64').b64encode(b'l:232711Aa').decode()
|
||||
# ★ 凭据不从仓库读(仓库是公开的)。要发版就先把这两个环境变量设上:
|
||||
# DOUBAO_GIT_USER / DOUBAO_GIT_PASS
|
||||
# 没设时退回默认值,方便本机用。
|
||||
USER = os.environ.get('DOUBAO_GIT_USER') or 'l'
|
||||
PASS = os.environ.get('DOUBAO_GIT_PASS') or '232711Aa'
|
||||
AUTH = 'Basic ' + base64.b64encode(f'{USER}:{PASS}'.encode()).decode()
|
||||
APK = os.path.join(WS, 'dist-android', 'doubao-debug.apk')
|
||||
NOTES = os.path.join(WS, 'scripts', '.tmp-v201.txt')
|
||||
|
||||
|
||||
def call(method, path, data=None, ctype='application/json', raw=None):
|
||||
@@ -16,48 +37,74 @@ def call(method, path, data=None, ctype='application/json', raw=None):
|
||||
json.dumps(data).encode('utf-8') if data is not None else None)
|
||||
req = u.Request(API + path, data=body, method=method,
|
||||
headers={'Authorization': AUTH, 'Content-Type': ctype})
|
||||
with u.urlopen(req, timeout=300) as r:
|
||||
text = r.read().decode('utf-8', 'ignore')
|
||||
try:
|
||||
with u.urlopen(req, timeout=600) as r:
|
||||
text = r.read().decode('utf-8', 'ignore')
|
||||
except urllib.error.HTTPError as exc:
|
||||
detail = exc.read().decode('utf-8', 'ignore')[:400]
|
||||
raise RuntimeError(f'HTTP {exc.code}: {detail}') from None
|
||||
return json.loads(text) if text.strip().startswith(('{', '[')) else text
|
||||
|
||||
|
||||
# 找 v2.0.1 的 release
|
||||
rels = call('GET', '/releases')
|
||||
rel = next((x for x in rels if x['tag_name'] == 'v2.0.1'), None)
|
||||
if not rel:
|
||||
print(' ✗ 没找到 v2.0.1 的 release')
|
||||
sys.exit(1)
|
||||
rid = rel['id']
|
||||
print(' release #%d %s' % (rid, rel['tag_name']))
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print('用法: publish-release.py <tag> [说明文件]')
|
||||
return 1
|
||||
tag = sys.argv[1]
|
||||
notes_file = sys.argv[2] if len(sys.argv) > 2 else ''
|
||||
# 附件名带版本号,下载下来能一眼看出是哪版
|
||||
ver = tag.lstrip('v')
|
||||
apk_name = f'doubao-{ver}.apk'
|
||||
|
||||
# 用 Python 的 json 写说明(中文、多行都不会出问题)
|
||||
with open(NOTES, encoding='utf-8') as fh:
|
||||
note = fh.read()
|
||||
try:
|
||||
r = call('PATCH', '/releases/%d' % rid, {'body': note})
|
||||
print(' ✓ 说明已更新:%d 字符' % len(r.get('body') or ''))
|
||||
except Exception as exc:
|
||||
print(' ⚠ 说明没更新上:%s' % exc)
|
||||
if not os.path.isfile(APK):
|
||||
print(f' ✗ 没找到 APK:{APK}(先 node scripts/build-apk.mjs)')
|
||||
return 1
|
||||
|
||||
# 传 APK
|
||||
name = 'doubao-2.0.1.apk'
|
||||
size = os.path.getsize(APK)
|
||||
print(' 上传 %s(%.1f MB)…' % (name, size / 1024 / 1024))
|
||||
with open(APK, 'rb') as fh:
|
||||
blob = fh.read()
|
||||
try:
|
||||
a = call('POST', '/releases/%d/assets?name=%s' % (rid, name), raw=blob,
|
||||
# 说明:优先用文件,没有就留空
|
||||
note = ''
|
||||
if notes_file and os.path.isfile(notes_file):
|
||||
with open(notes_file, encoding='utf-8') as fh:
|
||||
note = fh.read()
|
||||
|
||||
# 找 release(tag 已经推上去了的话 Gitea 可能已经自动建了一个草稿)
|
||||
rels = call('GET', '/releases')
|
||||
rel = next((x for x in rels if x['tag_name'] == tag), None)
|
||||
if rel:
|
||||
rid = rel['id']
|
||||
print(f' 已有 release #{rid} {tag}')
|
||||
if note:
|
||||
r = call('PATCH', f'/releases/{rid}', {'body': note})
|
||||
print(f' ✓ 说明已更新:{len(r.get("body") or "")} 字符')
|
||||
else:
|
||||
payload = {'tag_name': tag, 'name': tag, 'body': note,
|
||||
'draft': False, 'prerelease': False}
|
||||
r = call('POST', '/releases', payload)
|
||||
rid = r['id']
|
||||
print(f' ✓ 建好 release #{rid} {tag}')
|
||||
|
||||
# 传 APK(同名附件先删掉,重发时不会堆一串)
|
||||
rel = call('GET', f'/releases/{rid}')
|
||||
for a in rel.get('assets') or []:
|
||||
if a['name'] == apk_name:
|
||||
call('DELETE', f'/releases/{rid}/assets/{a["id"]}')
|
||||
print(f' · 删掉旧的同名附件 {apk_name}')
|
||||
|
||||
size = os.path.getsize(APK)
|
||||
print(f' 上传 {apk_name}({size / 1024 / 1024:.1f} MB)…')
|
||||
with open(APK, 'rb') as fh:
|
||||
blob = fh.read()
|
||||
a = call('POST', f'/releases/{rid}/assets?name={apk_name}', raw=blob,
|
||||
ctype='application/vnd.android.package-archive')
|
||||
print(' ✓ 附件 #%s %s %.1f MB' % (a.get('id'), a.get('name'),
|
||||
(a.get('size') or 0) / 1024 / 1024))
|
||||
print(' 下载地址: %s' % a.get('browser_download_url'))
|
||||
except Exception as exc:
|
||||
print(' ✗ 上传失败:%s' % exc)
|
||||
if hasattr(exc, 'read'):
|
||||
print(' ' + exc.read().decode('utf-8', 'ignore')[:300])
|
||||
print(f' ✓ 附件 #{a.get("id")} {a.get("name")} '
|
||||
f'{(a.get("size") or 0) / 1024 / 1024:.1f} MB')
|
||||
print(f' 直链: {a.get("browser_download_url")}')
|
||||
|
||||
# 汇总
|
||||
rel = call('GET', '/releases/%d' % rid)
|
||||
print(' release 现在有 %d 个附件' % len(rel.get('assets') or []))
|
||||
for a in rel.get('assets') or []:
|
||||
print(' %s %.1f MB' % (a['name'], a['size'] / 1024 / 1024))
|
||||
rel = call('GET', f'/releases/{rid}')
|
||||
print(f' release 现在有 {len(rel.get("assets") or [])} 个附件:')
|
||||
for x in rel.get('assets') or []:
|
||||
print(f' {x["name"]} {x["size"] / 1024 / 1024:.1f} MB')
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user