Skip to content

Commit

Permalink
[add] init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingyueyixi committed Sep 28, 2024
1 parent 6ee9a20 commit bda0cb4
Show file tree
Hide file tree
Showing 86 changed files with 6,020 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Android CI

on:
push:
branches: [ "main", "v*/**"]
pull_request:
branches: [ "main" , "v*/**"]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Install python pip dependencies
run: |
python -m pip install --upgrade pip
pip install requests
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Prepare Env
id: Prepare
run: |
GIT_COMMIT=$(git rev-parse HEAD)
github_run_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
echo "GIT_COMMIT=$GIT_COMMIT$">> $GITHUB_ENV
echo "GITHUB_RUN_URL=$github_run_url">> $GITHUB_ENV
echo "GIT_BRANCH=`git branch --show-current`" >> $GITHUB_ENV
chmod +x robot.py
# debug
- name: Dump Env
run: env | sort

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Grant execute permission for gradlew
run: chmod +x gradlew
# - name: Build with Gradle
# run: ./gradlew build
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: build

- name: Prepare Artifact
if: success()
id: prepareArtifact
run: |
releaseArtifactName=`ls app/build/outputs/apk/release/*.apk | grep -Po "(?<=release/).*(?=\.apk)"` && echo "releaseArtifactName=$releaseArtifactName" >> $GITHUB_OUTPUT
debugArtifactName=`ls app/build/outputs/apk/debug/*.apk | grep -Po "(?<=debug/).*(?=\.apk)"` && echo "debugArtifactName=$debugArtifactName" >> $GITHUB_OUTPUT
- name: Upload Archive Release-Apk
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepareArtifact.outputs.releaseArtifactName }}
path: app/build/outputs/apk/release/*.apk

- name: Upload Archive Debug-Apk
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepareArtifact.outputs.debugArtifactName }}
path: ./app/build/outputs/apk/debug/*.apk

- name: Post Message
env:
CHAT_ID: ${{ secrets.TG_CI_CHAT_ID }}
BOT_TOKEN: ${{ secrets.TG_CI_BOT_TOKEN }}
run: |
echo "github_run_url=$GITHUB_RUN_URL"
echo '${{ toJson(github) }}'> github_context.txt
if [ -f "robot.py" ]; then
python robot.py -e ci
fi
# curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" -d "chat_id=$CHAT_ID&text=CI编译完成${github_run_url}"

61 changes: 61 additions & 0 deletions .github/workflows/release-post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release-Robot

on:
release:
types: [ published, edited ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# debug
- name: Dump Env
run: env | sort

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# GIT_TAG=$(git describe --exact-match --abbrev=0 --tags "${COMMIT}" 2> /dev/null || true)
# https://github.com/actions/actions-runner-controller/blob/acbce4b70ad1cf719f3bab94e127ca38a1576228/hack/make-env.sh
# GIT_TAG=${GITHUB_REF/refs\/tags\//}
# 这个方式在commit没有tag时,结果类似于: refs/heads/main
- name: Prepare Env
id: Prepare
run: |
GIT_TAG=${GITHUB_REF/refs\/tags\//}
GIT_COMMIT=$(git rev-parse HEAD)
echo "GIT_COMMIT=$GIT_COMMIT$">> $GITHUB_ENV
echo "GIT_TAG=$GIT_TAG">> $GITHUB_ENV
echo "GITHUB_RUN_URL=$github_run_url">> $GITHUB_ENV
echo "GIT_BRANCH=`git branch --show-current`" >> $GITHUB_ENV
- name: Robot Post Message
env:
tag_name: ${{ github.event.release.tag_name }}
chat_id: ${{ secrets.TG_CI_CHAT_ID }}
bot_token: ${{ secrets.TG_CI_BOT_TOKEN }}
github_user: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# github_release: ${{ toJson(github.event.release) }}
run: |
echo "${{ toJson(github) }}"> github_context.txt
python robot.py -e release
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
/.idea/**
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# PicCatcher(图片捕手)

[Source link / 项目地址](https://github.com/Mingyueyixi/PicCatcher)

反馈问题可点击以上地址,发起issues


## 介绍

Catch app's picture
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
178 changes: 178 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import org.json.JSONObject

import java.text.SimpleDateFormat

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
apply {
from rootProject.file('props.gradle')
}
def buildInfoJson = {
def p = "git branch --show-current".execute()
//当前分支
def currentBranch = p.text.trim()
p.destroy()
//最后1个提交ID
p = "git rev-parse HEAD".execute()
def lastedCommit = p.text.trim()
p.destroy()

//github等服务器打包时,因时区不同,格式化的时间与本地时间对不上
//故直接保存毫秒
def buildTime = System.currentTimeMillis()

def gitBranch = currentBranch
def gitCommit = lastedCommit;

def jsonObj = new JSONObject()
jsonObj.put("time", buildTime)
jsonObj.put("branch", gitBranch)
jsonObj.put("commit", gitCommit)
return jsonObj.toString()
}()

def writeBuildInfoJson(dirPath, jsonText) {
println "----------Commit Info------------"

def buildInfoPath = "$dirPath/build_info.json".replace("\\", "/")
def jsonFile = file(buildInfoPath)
jsonFile.parentFile.mkdirs()
jsonFile.withWriter('utf-8') {
it.write(jsonText)
}
println "commit info file: $buildInfoPath"

}

this.afterEvaluate {
project.tasks.forEach {
if (it.name.startsWith("process") && it.name.endsWith("JavaRes")) {
//将构建信息打包到apk中,这个方法似乎不太靠谱,改为写入buildConfig
it.doLast {
println(">>> ${it.name} attach build json")
writeBuildInfoJson(it.destinationDir.path, buildInfoJson)
}
}
}

}

android {
namespace 'com.pic.catcher'
compileSdk 35

defaultConfig {
applicationId "com.pic.catcher"
minSdk 24
targetSdk 35
versionCode 1001
versionName "1.0-dev"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "int", "VERSION_CODE", "${versionCode}"
buildConfigField "String", "VERSION_NAME", "\"${versionName}\""
buildConfigField "String", "buildInfoJson64", "\"${buildInfoJson.bytes.encodeBase64()}\""
}
// sourceSets {
// main{
// resources{
// srcDir("src/main/reouserces")
// }
// }
// }
signingConfigs {
alpha {
storeFile file("${rootDir}/app/key-store-test.jks")
storePassword "123456"
keyAlias "piccatch"
keyPassword "123456"
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.alpha
}
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.alpha
}

}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

viewBinding {
enabled = true
}

applicationVariants.all { variant ->
def outputs = variant.outputs
def size = outputs.size()
def commit = new JSONObject(buildInfoJson).optString("commit").substring(0, 6)
outputs.eachWithIndex { Object output, int index ->
def fontName = "piccatcher-v${variant.versionName}-${commit}-${variant.name}"
if (size == 1) {
output.outputFileName = "${fontName}.apk"
} else {
output.outputFileName = "${fontName}-${index}.apk"
}
}
// variant.properties.each {
// println("${it.key} --》 ${it.value}")
// }
// println("------------"+ variant.outputs)

// testOptions {
// //使javaTest可以使用外部库的代码,例如android.jar
// //但是,api实际没有结果。
// unitTests.returnDefaultValues = true
// }
}
buildFeatures {
buildConfig = true
}
}

configurations.all {
resolutionStrategy {

}
}



dependencies {
implementation(fileTree(dir: "libs", include: ["*.jar", "*.aar"]))
implementation(deps['com.github.Mingyueyixi.frame-base-utils:base'])
// implementation(deps['com.github.Mingyueyixi.frame-ui:ui-appcompat']){
// exclude(group:'androidx.core', module:'core')
// }
implementation(deps['com.github.Mingyueyixi.lposed:xposed-api2'])
implementation(deps['com.github.Mingyueyixi.lposed:plugin'])
// implementation(deps['androidx.appcompat:appcompat'])
compileOnly(deps['de.robv.android.xposed:api'])
// compileOnly('com.tencent.wcdb:wcdb-android:1.1-19')
// https://mvnrepository.com/artifact/com.tencent.wcdb/wcdb-android

// https://mvnrepository.com/artifact/org.json/json
// testImplementation 'org.json:json:20220924'

testImplementation(deps['junit:junit'])
androidTestImplementation(deps['androidx.test.ext:junit'])
androidTestImplementation(deps['androidx.test.espresso:espresso-core'])
}
Binary file added app/key-store-test.jks
Binary file not shown.
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading

0 comments on commit bda0cb4

Please sign in to comment.