GitHub Actions 是 GitHub 的持续集成服务

趁着现在免费写一篇文章

1.项目信息

yhkl-dev/test-github-actions

  • 一个简单的安卓项目 hello world

  • 目标:发生push动作时自动触发workflow进行编译打包成Apk,并发布release

2.编写workflow

.github/workflows/android.yml

具体参考:https://github.com/ShaunLWM/action-release-debugapk

1
name: Build & Publish Debug APK
2
3
on:
4
 push:
5
  branches:
6
   - master
7
   
8
jobs:
9
  build:
10
    runs-on: ubuntu-latest
11
    steps:
12
    - uses: actions/checkout@v1
13
    - name: set up JDK 1.8
14
      uses: actions/setup-java@v1
15
      with:
16
        java-version: 1.8
17
    - name: Make Gradle executable
18
      run: chmod +x ./gradlew
19
    - name: Build with Gradle
20
      run: ./gradlew build
21
    - name: Build Debug APK
22
      run: ./gradlew assembleDebug
23
    - name: Releasing using Hub
24
      uses: ShaunLWM/action-release-debugapk@master
25
      env:
26
       GITHUB_TOKEN: ${{ secrets.SecRet }} # github 项目secert key 名字必须和设置的一致, 并且token具有相关权限
27
       APP_FOLDER: app
28
       RELEASE_TITLE: New Build # 版本名称

secret key 举例

1572567695244

3.本地push提交
  • 启动本地github 回调

    1572567997508

  • 提交代码

    1572567783029

    1572568049800

  • 查看github actions

    1572568103035

    1572568125370

    1572568235994

    成功

    1572568246363

  • 查看release

    1572568735977

4. webhooks下载apk

1572568349748

1572568379572