Skip to content

Commit

Permalink
Github Action: auto releases
Browse files Browse the repository at this point in the history
  • Loading branch information
longluo committed Jul 8, 2022
1 parent e3c66e3 commit 215b4a5
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:

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

- name: Setup JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '14'
distribution: 'adopt'
Expand All @@ -34,53 +34,56 @@ jobs:
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 EbookReader_*.apk EbookReader.apk
ls -l
- name: Get Time
id: time
uses: JantHsueh/get-time-action@master
with:
timeZone: 8

- name: Get Apk Info
id: apkInfo
uses: JantHsueh/get-apk-info-action@master
with:
apkPath: ./build/app/outputs/apk/release/*.apk

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

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

release:
name: Release APK
needs: build
runs-on: ubuntu-latest
steps:
name: EbookReader
path: ${{ github.workspace }}/build/app/outputs/apk/release/*.apk

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

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

- 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
Expand All @@ -89,7 +92,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: ${{ github.event.repository.name }} ${{ steps.branch-name.outputs.current_branch }} v${{ github.run_number }}.${{ github.run_attempt }}
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 Release APK
id: upload_release_asset
Expand All @@ -98,7 +101,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: apk/*.apk
asset_name: ${{ github.event.repository.name }} ${{ steps.branch-name.outputs.current_branch }} v${{ github.run_number }}.${{ github.run_attempt }}.apk
asset_path: ./build/app/outputs/apk/release/EbookReader.apk
asset_name: ${{ github.event.repository.name }}_${{ steps.branch-name.outputs.current_branch }}_v${{ steps.apkInfo.outputs.versionNum }}.apk
asset_content_type: application/zip

0 comments on commit 215b4a5

Please sign in to comment.