update build.yml

pull/28/head
fengyuecanzhu 3 years ago
parent 8d69b115a5
commit ebd11f6f83
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 56
      .github/workflows/build.yml
  2. 15
      app/build.gradle

@ -1,4 +1,4 @@
name: Auto build and delay name: build
on: on:
push: push:
@ -60,15 +60,15 @@ jobs:
path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug" path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug"
fi fi
echo ::set-output name=file_path::"$path" echo ::set-output name=file_path::"$path"
- name: Upload App To Artifact - name: Upload Lanzou
uses: actions/upload-artifact@v3
with:
name: FYReader-apk
path: ${{ steps.get_path.outputs.file_path }}
- name: Upload App To Lanzou
run: | run: |
echo "上传APP至蓝奏云" echo "上传APP至蓝奏云"
python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}" "${{ steps.config.outputs.lanzou_folder_id }}" "${{ steps.config.outputs.version_name }}" tag_name=${{ steps.config.outputs.version_name }}
if [[ ${{ steps.config.outputs.need_create_release }} != 'true' ]];then
gitHead=$(git rev-parse --short HEAD)
tag_name=${{ steps.config.outputs.version_name }}-$gitHead
fi
python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}" "${{ steps.config.outputs.lanzou_folder_id }}" "$tag_name"
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}" echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}"
- name: Release - name: Release
if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }} if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }}
@ -80,10 +80,40 @@ jobs:
tag_name: ${{ steps.config.outputs.version_name }} tag_name: ${{ steps.config.outputs.version_name }}
name: FYReader_${{ steps.config.outputs.version_name }} name: FYReader_${{ steps.config.outputs.version_name }}
files: | files: |
app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-arm64-v8a.apk ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-arm64-v8a.apk
app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-armeabi-v7a.apk ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-armeabi-v7a.apk
app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-x86_64.apk ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-x86_64.apk
app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-x86.apk ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-x86.apk
app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-universal.apk ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-universal.apk
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Artifact arm64-v8a
uses: actions/upload-artifact@v3
with:
name: app-arm64-v8a
path: ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-arm64-v8a.apk
- name: Upload Artifact armeabi-v7a
uses: actions/upload-artifact@v3
with:
name: app-armeabi-v7a
path: ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-armeabi-v7a.apk
- name: Upload Artifact universal
uses: actions/upload-artifact@v3
with:
name: app-universal
path: ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-universal.apk
- name: Upload Artifact x86_64
uses: actions/upload-artifact@v3
with:
name: app-x86_64
path: ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-x86_64.apk
- name: Upload Artifact x86
uses: actions/upload-artifact@v3
with:
name: app-x86
path: ${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}-x86.apk

@ -32,16 +32,9 @@ def getVersionC() {
if (versionCodeFile.canRead()) { if (versionCodeFile.canRead()) {
Properties properties = new Properties() Properties properties = new Properties()
properties.load(new FileInputStream(versionCodeFile)) properties.load(new FileInputStream(versionCodeFile))
def versionCode = properties['VERSION_CODE'].toInteger()//version_code.properties文件存放的版本号 return properties['VERSION_CODE'].toInteger()
def runTasks = gradle.startParameter.taskNames
def task = ':app:assembleRelease'
if (task in runTasks) {
properties['VERSION_CODE'] = (++versionCode).toString()
properties.store(versionCodeFile.newWriter(), null)
}
return versionCode
} else { } else {
throw new FileNotFoundException("无法读取version_code.properties文件!") return 200
} }
} }
@ -112,16 +105,12 @@ android {
versionNameSuffix "-" + commitId versionNameSuffix "-" + commitId
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
def buildType = variant.buildType.name
variant.outputs.each { output -> variant.outputs.each { output ->
def abi = output.getFilter(OutputFile.ABI) def abi = output.getFilter(OutputFile.ABI)
if (abi == null) { if (abi == null) {
abi = "universal" abi = "universal"
} }
def fileName = "${name}v${defaultConfig.versionName}-${abi}.apk" def fileName = "${name}v${defaultConfig.versionName}-${abi}.apk"
if (buildType == "debug"){
fileName = "${name}v${defaultConfig.versionName}-${abi}-${commitId}.apk"
}
output.outputFileName = fileName output.outputFileName = fileName
} }
} }

Loading…
Cancel
Save