Skip to content

Commit

Permalink
Merge pull request #57 from SummonHIM/main
Browse files Browse the repository at this point in the history
optimize workflow
  • Loading branch information
cofbro committed Nov 20, 2023
2 parents 7c9de12 + a94030d commit d888df8
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 30 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/gradle-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Develop CI

on:
push:
branches-ignore: [ main ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build debug apk with Gradle
uses: gradle/gradle-command-action@v2
with:
arguments: assembleDebug

- name: Upload debug apk to artifacts
uses: actions/upload-artifact@v3
with:
name: app-debug
path: ${{github.workspace}}/app/build/outputs/apk/debug/*.apk
30 changes: 0 additions & 30 deletions .github/workflows/gradle-publish.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/gradle-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: [ main ]
tags: '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Prepare signing key
run: echo '${{ secrets.SIGNING_KEY }}' | base64 -d > signingkey.jks

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build release binary with Gradle
uses: gradle/gradle-command-action@v2
env:
ALIAS: ${{ secrets.ALIAS }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
with:
arguments: assembleRelease

- name: Clean up
run: |
rm signingkey.jks
rm -f ${{github.workspace}}/app/build/outputs/apk/release/app-release-unsigned.apk
- name: Upload release binary to artifacts
uses: actions/upload-artifact@v3
with:
name: app-release
path: ${{github.workspace}}/app/build/outputs/apk/release/*.apk

- name: Setup release info
run: |
cd ${{github.workspace}}/app/build/outputs/apk/release
echo "OPT_APK_SHA=$(sha256sum *.apk | awk '{ print $1 }')" >> $GITHUB_ENV
echo "OPT_APK_NAME=$(ls *.apk)" >> $GITHUB_ENV
- name: Create & upload new release draft
uses: softprops/action-gh-release@v1
with:
name: Doraemon
tag_name: ${{ github.ref_name }}
draft: true
files: ${{github.workspace}}/app/build/outputs/apk/release/*.apk
body: |
### 文件校验
| 文件 | SHA-256 |
| --- | --- |
| ${{ env.OPT_APK_NAME }} | ${{ env.OPT_APK_SHA }} |
10 changes: 10 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
storeFile rootProject.file("signingkey.jks")
storePassword System.getenv("KEY_STORE_PASSWORD")
keyAlias System.getenv("ALIAS")
keyPassword System.getenv("KEY_PASSWORD")
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
Expand Down

0 comments on commit d888df8

Please sign in to comment.