Publish scripts

This commit is contained in:
世界 2020-07-08 14:06:59 +00:00
parent d86c857e11
commit 93f3f957df
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
15 changed files with 210 additions and 272 deletions

View File

@ -21,42 +21,11 @@ jobs:
- name: assembleRelease
run: |
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
./gradlew TMessagesProj:assembleRelease \
TMessagesProj:assembleReleaseNoGcm \
TMessagesProj:bundleFullRelease
echo ::set-env name=AAB_FILE::$(find TMessagesProj/build/outputs/bundle -name "*.aab")
- name: Setup ghr
run: |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
tar xvzf ghr.tar.gz; rm ghr.tar.gz
sudo mv ghr*linux_amd64/ghr /usr/local/bin; rm -rf ghr*linux_amd64
- name: Upload apks
run: |
export GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}"
mkdir apks; find . -name "*.apk" -exec mv {} apks \;
ref="${{ github.ref }}"
ref=${ref/"refs/tags/"/}
msg="${{ github.event.head_commit.message }}"
ghr -delete -n "$ref" -b "$msg" "$ref" apks/
rm -rf $HOME/.ssh
mkdir -p $HOME/.ssh
echo "${{ secrets.SSH_KEY }}" > $HOME/.ssh/id_rsa
chmod 600 $HOME/.ssh/id_rsa
mv build/update.json apks
cd apks
rm *universal*
xz *.apk
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
git init
git config --global user.name "世界"
git config --global user.email "i@nekox.me"
git remote add origin "git@github.com:NekoX-Dev/Resources.git"
git add . --all
git commit -m 喵
git push origin master -f
- uses: r0adkll/upload-google-play@master
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_ACCOUNT_SERVICE }}
packageName: nekox.messenger
releaseFile: ${{ env.AAB_FILE }}
track: production
ref="${{ github.ref }}"
ref=${ref/"refs/tags/"/}
./bin/release.sh "$ref"

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ local.properties
/TMessagesProj/jni/boringssl/build/
CMakeLists.txt
CMakeLists.txt.orig
service_account_credentials.json

View File

@ -7,6 +7,35 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
if (serviceAccountCredentialsFile.isFile()) {
setupPlay()
play.serviceAccountCredentials = serviceAccountCredentialsFile
} else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) {
setupPlay()
}
void setupPlay() {
apply plugin: 'com.github.triplet.play'
play {
track = "production"
defaultToAppBundles = true
}
}
configurations {
compile.exclude module: 'support-v4'
}
@ -36,62 +65,8 @@ repositories {
}
dependencies {
implementation 'androidx.core:core:1.5.0-alpha01'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.2.0'
implementation "androidx.interpolator:interpolator:1.0.0"
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
// replace zxing with latest
// TODO: fix problem with android L
implementation 'com.google.zxing:core:3.4.0'
compileOnly 'org.checkerframework:checker-qual:3.5.0'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.5'
// don't change this :)
//noinspection GradleDependency
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.osmdroid:osmdroid-android:6.1.6'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion"
implementation 'dnsjava:dnsjava:3.2.1'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.3.8'
implementation 'cn.hutool:hutool-crypto:5.3.8'
implementation 'org.tukaani:xz:1.8'
compileOnly files('libs/libv2ray.aar')
compileOnly "com.google.firebase:firebase-messaging:$fcmVersion"
compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
compileOnly "com.google.android.play:core:$playCoreVersion"
compileOnly 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion"
releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
releaseImplementation "com.google.android.play:core:$playCoreVersion"
}
def verName = "6.2.0.2-preview-1"
def verCode = 51
def verName = "6.2.0.3-rc02"
def verCode = 55
task writeUpdateInfo {
@ -100,7 +75,7 @@ task writeUpdateInfo {
info.set("version", verName)
info.set("versionCode", verCode)
info.set("defaultFlavor", "full")
info.set("defaultApkName", "NekoX-full-arm64-v8a-release.apk.xz")
info.set("defaultApkName", "NekoX-full-blobEmoji-arm64-v8a-release.apk.xz")
FileUtil.writeUtf8String(info.toStringPretty(), new File("build/update.json"))
@ -251,42 +226,36 @@ android {
}
}
sourceSets.main {
jni.srcDirs = ['./jni/']
}
sourceSets.debug {
jniLibs.srcDir 'src/main/libs'
}
sourceSets.releaseNoGcm {
jniLibs.srcDir 'src/main/libs'
}
sourceSets.release {
jniLibs.srcDir 'src/main/libs'
manifest.srcFile 'src/gservcies/AndroidManifest.xml'
}
sourceSets.foss {
jni.srcDirs = ['./jni/']
}
flavorDimensions "version"
splits {
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk true
sourceSets {
main {
jni.srcDirs = ['./jni/']
}
debug {
jniLibs.srcDir 'src/main/libs'
}
releaseNoGcm {
jniLibs.srcDir 'src/main/libs'
}
release {
jniLibs.srcDir 'src/main/libs'
manifest.srcFile 'src/gservcies/AndroidManifest.xml'
}
foss {
jni.srcDirs = ['./jni/']
}
}
splits.abi {
enable true
universalApk true
}
def tgVoipDexFileName = "libtgvoip.dex"
@ -298,75 +267,45 @@ android {
dxUtilPath += ".bat"
}
flavorDimensions "version"
flavorDimensions "version", "emoji"
productFlavors {
mini {
versionNameSuffix '-mini'
dimension "version"
}
miniNoEmoji {
versionNameSuffix '-mini-no-emoji'
full {
dimension "version"
}
miniAppleEmoji {
versionNameSuffix '-mini-apple-emoji'
noEmoji {
dimension "emoji"
}
miniNotoEmoji {
versionNameSuffix '-mini-noto-emoji'
blobEmoji {
dimension "emoji"
}
miniTwitterEmoji {
versionNameSuffix '-mini-twitter-emoji'
appleEmoji {
dimension "emoji"
}
miniFacebookEmoji {
versionNameSuffix '-mini-facebook-emoji'
notoEmoji {
dimension "emoji"
}
full {}
fullNoEmoji {
versionNameSuffix '-full-no-emoji'
twitterEmoji {
dimension "emoji"
}
fullAppleEmoji {
versionNameSuffix '-full-apple-emoji'
}
fullNotoEmoji {
versionNameSuffix '-full-noto-emoji'
}
fullTwitterEmoji {
versionNameSuffix '-full-twitter-emoji'
}
fullFacebookEmoji {
versionNameSuffix '-full-facebook-emoji'
facebookEmoji {
dimension "emoji"
}
}
sourceSets.all { set ->
if (set.name.startsWith("full")) {
set.dependencies {
implementation files('libs/libv2ray.aar')
implementation files('libs/ss-rust-release.aar')
implementation files('libs/ssr-libev-release.aar')
}
}
if (set.name.matches("(mini|full).*")) {
if (set.name.contains("Apple")) {
set.dependencies {
implementation 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Noto")) {
set.dependencies {
implementation 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Twitter")) {
set.dependencies {
implementation 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Facebook")) {
set.dependencies {
implementation 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
}
} else {
set.assets.srcDirs = ["src/main/assets", "src/emojis/blob"]
}
}
}
sourceSets.blobEmoji.assets.srcDirs = ["src/main/assets", "src/emojis/blob"]
tasks.all { task ->
if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !task.name.contains("Foss")) {
@ -440,6 +379,70 @@ android {
}
dependencies {
implementation 'androidx.core:core:1.5.0-alpha01'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.2.0'
implementation "androidx.interpolator:interpolator:1.0.0"
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
// replace zxing with latest
// TODO: fix problem with android L
implementation 'com.google.zxing:core:3.4.0'
compileOnly 'org.checkerframework:checker-qual:3.5.0'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.5'
// don't change this :)
//noinspection GradleDependency
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.osmdroid:osmdroid-android:6.1.6'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion"
implementation 'dnsjava:dnsjava:3.2.1'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.3.8'
implementation 'cn.hutool:hutool-crypto:5.3.8'
implementation 'org.tukaani:xz:1.8'
compileOnly files('libs/libv2ray.aar')
fullImplementation files('libs/libv2ray.aar')
fullImplementation files('libs/ss-rust-release.aar')
fullImplementation files('libs/ssr-libev-release.aar')
compileOnly "com.google.firebase:firebase-messaging:$fcmVersion"
compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
compileOnly "com.google.android.play:core:$playCoreVersion"
compileOnly 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
appleEmojiImplementation 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
notoEmojiImplementation 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
twitterEmojiImplementation 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
facebookEmojiImplementation 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion"
releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
releaseImplementation "com.google.android.play:core:$playCoreVersion"
}
private static File findJavaHome() {
String javaPath = System.getProperty("java.home")
if (javaPath != null) {

View File

@ -552,7 +552,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (BuildConfig.BUILD_TYPE.startsWith("release")) {
builder.addItem(LocaleController.getString("SwitchVersion", R.string.SwitchVersion), R.drawable.baseline_replay_24, (it) -> {
builder.dismiss();
UpdateChecksKt.switchVersion(getParentActivity());
Browser.openUrl(getParentActivity(), "https://github.com/NekoX-Dev/NekoX/releases");
return Unit.INSTANCE;
});
}

View File

@ -21,13 +21,13 @@ object EmojiProvider {
// default use blob
@JvmField
val isFont = !type.contains("Emoji")
val isFont = type.contains("Blob")
@JvmStatic
val font by lazy {
if (!isFont) throw IllegalStateException()
val resName = when {
!type.contains("emoji") -> "blob_compat.ttf"
type.contains("Blob") -> "blob_compat.ttf"
else -> throw IllegalStateException()
}
Typeface.createFromAsset(ApplicationLoader.applicationContext.assets, "fonts/$resName");

View File

@ -18,90 +18,6 @@ import tw.nekomimi.nekogram.NekoXConfig
import tw.nekomimi.nekogram.utils.*
import java.util.*
fun Activity.switchVersion() {
val builder = BottomBuilder(this)
fun addVersion(fPrefix: String, fSuffix: String, noGcm: Boolean) {
var buildType = "Release"
if (noGcm) buildType += "NoGcm"
builder.addItem("$fPrefix $buildType $fSuffix".trim()) {
val flavor = (fPrefix.toLowerCase() + fSuffix).trim()
buildType = StrUtil.lowerFirst(buildType)
val progress = AlertUtil.showProgress(this)
progress.show()
UIUtil.runOnIoDispatcher {
val ex = mutableListOf<Throwable>()
UpdateUtil.updateUrls.forEach { url ->
runCatching {
val updateInfo = JSONObject(HttpUtil.get("$url/update.json"))
val code = updateInfo.getInt("versionCode")
UIUtil.runOnUIThread {
progress.dismiss()
UpdateUtil.doUpdate(this, code, updateInfo.getString("defaultFlavor"), buildType, flavor)
}
return@runOnIoDispatcher
}.onFailure {
ex.add(it)
}
}
progress.dismiss()
AlertUtil.showToast(ex.joinToString("\n") { it.message ?: it.javaClass.simpleName })
}
}
}
fun addVersion(fPrefix: String, fSuffix: String) {
addVersion(fPrefix, fSuffix, false)
addVersion(fPrefix, fSuffix, true)
}
fun addVersion(fPrefix: String) {
arrayOf("", "NoEmoji", "Apple", "Noto", "Twitter", "Facebook").forEach {
addVersion(fPrefix, "${it}Emoji")
}
}
addVersion("Full")
addVersion("Mini")
builder.show()
}
@JvmOverloads
fun Activity.checkUpdate(force: Boolean = false) {

View File

@ -55,7 +55,7 @@ export NINJA_PATH="$(command -v ninja)"
export PATH=$(echo "$ANDROID_HOME"/cmake/*/bin):$PATH
cd TMessagesProj/jni
cd TMessagesProj/jni || exit 1
git submodule update --init --recursive

3
bin/publish_play.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
./gradlew TMessagesProj:publishFullBlobEmojiRelease

16
bin/publish_release_apks.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
if [ ! -x "$(command -v ghr)" ]; then
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz &&
tar xvzf ghr.tar.gz &&
rm ghr.tar.gz &&
sudo mv ghr*linux_amd64/ghr /usr/local/bin &&
rm -rf ghr*linux_amd64 || exit 1
fi
rm -rf build/apks &&
mkdir -p build/apks &&
find TMessagesProj -name "*.apk" -exec cp {} build/apks \; &&
ghr -delete -n "$1" "$1" build/apks/

18
bin/publish_repo_apks.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
rm -rf build/apks &&
mkdir -p build/apks &&
find TMessagesProj -name "*.apk" -exec cp {} build/apks \; &&
cp build/update.json build/apks &&
cd build/apks &&
rm *universal* &&
xz *.apk &&
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&
git init &&
git config --global user.name "世界" &&
git config --global user.email "i@nekox.me" &&
git remote add origin "git@github.com:NekoX-Dev/Resources.git" &&
git add . --all &&
git commit -m "Update" &&
git push origin master -f &&
rm -rf build/apks

11
bin/release.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
./gradlew TMessagesProj:clean \
TMessagesProj:assembleFullBlobEmojiRelease \
TMessagesProj:assembleFullBlobEmojiReleaseNoGcm \
TMessagesProj:assembleMiniBlobEmojiRelease \
TMessagesProj:assembleMiniBlobEmojiReleaseNoGcm \
TMessagesProj:assembleMiniNoEmojiRelease \
TMessagesProj:assembleMiniNoEmojiReleaseNoGcm &&
./bin/publish_repo_apks.sh &&
./bin/publish_release_apks.sh "$1"

4
bin/tag.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
git tag "$1" -f &&
git push origin "$1" -f

View File

@ -12,6 +12,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3'
classpath 'com.github.triplet.gradle:play-publisher:2.8.0'
}
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
git tag "$1" -f
git push origin "$1" -f