Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8c3dfd59c | |||
| affc407f5e | |||
| 29f29a4524 |
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 202
|
||||
versionName = "2.0.2"
|
||||
versionCode = 204
|
||||
versionName = "2.0.4"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
@@ -39,14 +39,55 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名。
|
||||
*
|
||||
* ★ 用的是**原来那个 debug 证书**(fingerprint 83:28:15:D6…),
|
||||
* 只是把它**拷进了仓库**,并且**显式开了 v1/v2/v3**。
|
||||
*
|
||||
* 为什么这么做(踩过两次,记下来):
|
||||
*
|
||||
* 1. **不能随便换证书**。Android 不允许同包名不同签名覆盖安装 ——
|
||||
* 换了之后用户必须**先卸载**(数据全丢)。
|
||||
* 我第一次"修签名问题"时顺手换了一把新证书,结果老用户装不上,
|
||||
* 报"已安装了签名冲突的应用"。**修 A 问题不能引入 B 问题。**
|
||||
*
|
||||
* 2. **缺 v1(JAR)签名会让很多安装器拒绝**。Android 7+ 自己装没问题,
|
||||
* 但从远程传过去再装(MT 管理器 / UU远程 之类)会报
|
||||
* "解析失败:安装包没有签名文件"。所以 v1/v2/v3 全开。
|
||||
*
|
||||
* 3. **debug 证书默认在 ~/.android/ 里,换台机器就变**。
|
||||
* 拷进仓库(连密码一起)之后,**哪台机器构建出来的指纹都一样**,
|
||||
* 能互相覆盖安装。
|
||||
*
|
||||
* ★ 密码是 debug 证书的标准密码,**它不是秘密**。
|
||||
* 自签证书只保证"指纹稳定、能覆盖安装",不证明"是谁发的"。
|
||||
*/
|
||||
signingConfigs {
|
||||
create("doubao") {
|
||||
storeFile = file("../doubao-release.jks")
|
||||
storePassword = "android"
|
||||
keyAlias = "androiddebugkey"
|
||||
keyPassword = "android"
|
||||
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