Skip to content

Commit

Permalink
github action: add release.
Browse files Browse the repository at this point in the history
  • Loading branch information
longluo committed Jul 8, 2022
1 parent a18d281 commit d6e9915
Showing 1 changed file with 62 additions and 22 deletions.
84 changes: 62 additions & 22 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,100 @@ on:
- 'v*'

pull_request:
branches: [ master ]
branches:
- master
- dev

jobs:
build:

name: Build Apk
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v2
- name: Checkout Code
uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v2
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '14'
distribution: 'adopt'
cache: gradle

- name: Build with Gradle
- name: Build Apk with Gradle
id: build
run: |
pwd
echo -e "\n gradlew assembleRelease \n"
echo -e "\n\n gradlew assembleRelease start... \n\n"
chmod a+x gradlew
./gradlew assembleRelease
echo -e "\n\n Rename the Apk \n"
cd ./build/app/outputs/apk/release/
mv Android_Dev_Quick_*.apk QuickDev.apk
ls -l
- name: Get Time
id: time
uses: JantHsueh/get-time-action@master
with:
timeZone: 8

- name: Get Git Log
id: git_log
uses: JantHsueh/get-git-log-action@master
with:
tag: last_release

- name: Upload Apk
uses: actions/upload-artifact@v3
if: always()
with:
name: QuickDev.apk
path: ${{ github.workspace }}/build/app/outputs/apk/release/*.apk

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5

- name: Print branch
run: |
echo -e "\n Running on default: ${{ steps.branch-name.outputs.current_branch }}"
- name: Get Apk Info
id: apkInfo
uses: JantHsueh/get-apk-info-action@master
with:
apkPath: ./build/app/outputs/apk/release/*.apk
apkPath: ${{ github.workspace }}/build/app/outputs/apk/release/QuickDev.apk

- name: Get git log
id: gitLog
uses: JantHsueh/get-git-log-action@master
- name: Print Apk Info
run: |
echo -e "\n Apk Info: "
echo -e "${{ steps.apkInfo.outputs.versionNum }} ${{ steps.apkInfo.outputs.versionCode }}"
- name: Print Log
run: |
echo -e "\n Log: \n"
echo -e "${{ steps.git_log.outputs.log }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: release
tag_name: ${{ github.run_number }}
release_name: ${{ github.event.repository.name }} ${{ steps.branch-name.outputs.current_branch }} v${{ steps.apkInfo.outputs.versionNum }} ${{ steps.apkInfo.outputs.versionCode }} at ${{ steps.time.outputs.time}}

- name: upload apk
uses: actions/upload-artifact@v2
if: always()
- name: Upload Release APK
id: upload_release_asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: QuickDev.apk
path: |
echo -e "\n show path \n"
pwd
ls -l
${{github.workspace}}/build/app/outputs/apk/release/*.apk
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/app/outputs/apk/release/QuickDev.apk
asset_name: ${{ github.event.repository.name }}_${{ steps.branch-name.outputs.current_branch }}_v${{ steps.apkInfo.outputs.versionNum }}.apk
asset_content_type: application/zip

- name: Upload File to Pgyer
id: upload
Expand Down

0 comments on commit d6e9915

Please sign in to comment.