chore: GitHub Actions

This commit is contained in:
HuanCheng65 2023-01-28 22:17:29 +08:00
parent 48b848dfc1
commit ce69d9e2c1
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
2 changed files with 42 additions and 9 deletions

View File

@ -1,4 +1,4 @@
name: Android CI name: Build, Deploy
on: on:
push: push:
@ -23,17 +23,49 @@ jobs:
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew
- name: Decrypt keystore
env:
RELEASE_ENCRYPT_SECRET_KEY: ${{ secrets.RELEASE_ENCRYPT_SECRET_KEY }}
run: openssl aes-256-cbc -d -in "${{ github.workspace }}/${{ vars.RELEASE_KEYSTORE }}.encrypted" -k $RELEASE_ENCRYPT_SECRET_KEY -md md5 >> ${{ github.workspace }}/${{ vars.RELEASE_KEYSTORE }}
- name: Generate keystore.properties
env:
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASEKEYPASSWORD }}
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASESTOREPASSWORD }}
run: printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' ${{ vars.RELEASE_KEY_ALIAS }} $RELEASE_KEY_PASSWORD ${{ vars.RELEASE_KEYSTORE }} $RELEASE_STORE_PASSWORD > ${{ github.workspace }}/keystore.properties
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew packageRelease run: ./gradlew clean packageRelease
- name: Upload Package - name: Upload Package
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
name: package name: package
path: ${{ github.workspace }}/build/outputs/apk/release/*.apk path: ${{ github.workspace }}/app/build/outputs/apk/release/*.apk
- name: Upload Mapping - name: Upload Mapping
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
name: mapping name: mapping
path: ${{ github.workspace }}/build/outputs/apk/mapping path: ${{ github.workspace }}/app/build/outputs/mapping/release
- name: Upload Mapping to App Center
uses: vhsantos26/app-center-cli-action@v1
with:
user_token: ${{ secrets.APP_CENTER_TOKEN }}
command: appcenter crashes upload-mappings
- name: Get Output Metadata
run: |
echo 'OUTPUT_METADATA<<OUTPUT_METADATA_DELIMITER' >> $GITHUB_ENV
cat ${{ github.workspace }}/app/build/outputs/apk/release/output-metadata.json >> $GITHUB_ENV
echo 'OUTPUT_METADATA_DELIMITER' >> $GITHUB_ENV
- name: Upload Mapping to App Center
env:
version_code: ${{ fromJSON(env.OUTPUT_METADATA).elements[0].versionCode }}
version_name: ${{ fromJSON(env.OUTPUT_METADATA).elements[0].versionName }}
uses: vhsantos26/app-center-cli-action@v1
with:
user_token: ${{ secrets.APP_CENTER_TOKEN }}
command: appcenter crashes upload-mappings -c $version_code -n $version_name -m ${{ github.workspace }}/app/build/outputs/apk/mapping/mapping.txt -a huanchengfly/TiebaLite

View File

@ -13,13 +13,14 @@ def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(rootProject.file("keystore.properties"))) keystoreProperties.load(new FileInputStream(rootProject.file("keystore.properties")))
def applicationProperties = new Properties() def applicationProperties = new Properties()
applicationProperties.load(new FileInputStream(rootProject.file("application.properties"))) applicationProperties.load(new FileInputStream(rootProject.file("application.properties")))
def buildId = System.getenv("APPCENTER_BUILD_ID") def sha = System.getenv("GITHUB_SHA")
def isSelfBuild = buildId == null def isCI = System.getenv("CI")
def isSelfBuild = isCI != "true"
def applicationVersionCode = applicationProperties["versionCode"].toInteger() def applicationVersionCode = applicationProperties["versionCode"].toInteger()
def applicationVersionName = applicationProperties["versionName"] def applicationVersionName = applicationProperties["versionName"]
def isPerVersion = applicationProperties["isPerRelease"] == "true" def isPerVersion = applicationProperties["isPerRelease"] == "true"
if (!isSelfBuild) { if (!isSelfBuild) {
applicationVersionName = applicationVersionName + ".${buildId}" applicationVersionName = applicationVersionName + ".${sha.substring(0, 7)}"
} }
if (isPerVersion) { if (isPerVersion) {
applicationVersionName = applicationVersionName + ".${applicationProperties["preReleaseName"]}-${applicationProperties["preReleaseVer"]}" applicationVersionName = applicationVersionName + ".${applicationProperties["preReleaseName"]}-${applicationProperties["preReleaseVer"]}"
@ -146,7 +147,7 @@ dependencies {
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version" implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
implementation "com.google.accompanist:accompanist-webview:$accompanist_version" implementation "com.google.accompanist:accompanist-webview:$accompanist_version"
def sketch_version = "3.2.0-beta01" def sketch_version = "3.2.0-beta02"
implementation "io.github.panpf.sketch3:sketch:$sketch_version" implementation "io.github.panpf.sketch3:sketch:$sketch_version"
implementation "io.github.panpf.sketch3:sketch-compose:$sketch_version" implementation "io.github.panpf.sketch3:sketch-compose:$sketch_version"
implementation "io.github.panpf.sketch3:sketch-extensions:$sketch_version" implementation "io.github.panpf.sketch3:sketch-extensions:$sketch_version"
@ -193,7 +194,7 @@ dependencies {
implementation fileTree(include: ["*.jar"], dir: "libs") implementation fileTree(include: ["*.jar"], dir: "libs")
//AndroidX //AndroidX
implementation "androidx.appcompat:appcompat:1.5.1" implementation "androidx.appcompat:appcompat:1.6.0"
implementation "androidx.annotation:annotation:1.5.0" implementation "androidx.annotation:annotation:1.5.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4" implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.core:core-ktx:1.9.0" implementation "androidx.core:core-ktx:1.9.0"