GithubAction基本使用(提交代码到github自动打包上传到google play)
1.github Actions创建workflow
- 提交代码到github,点击Actions,并创建workflow

- 创建workflow,可选择如下任一模板创建,粘贴如下代码替换,提交
粘贴代码如下:(注意:分支,包名修改,注意去掉注释内容)
name: Deploy App CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant rights
run: chmod +x build.gradle
- name: Build with Gradle
id: build
run: ./gradlew build
- name: Build Release APK
id: buildRelease
run: ./gradlew assembleRelease
//添加这个打包好的APK可以进行本地下载
- uses: actions/upload-artifact@v2
name: upload build output
with:
name: 下载的压缩包名字
path: ${{ github.workspace }}/app/build/outputs/apk/release
- name: Create service_account.json
id: createServiceAccount
run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json
- name: Deploy to Play Store (BETA)
id: deploy
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: service_account.json
packageName: com.besttextonphoto.addbesttext
releaseFiles: app/build/outputs/apk/release/app-release.apk
track: internal

2.Google服务帐号创建
- 设置->API权限->创建服务账号

-
按照提示流程创建服务账号,注意角色选择
图片.png
-
创建完后之后创建密钥,创建完成会自动下载json文件,拷贝里面全部内容(注意:json文件只能下载一次)
图片.png

-
回到github,Settings->Secrets,创建SERVICE_ACCOUNT_JSON,将复制的json文件内容全部复制进去
图片.png

- 点击Action查看上传状态

iOS通过Github Action进行打包需要配置的参数一览

APPSTORE_API_KEY_ID、APPSTORE_ISSUER_ID、APPSTORE_API_PRIVATE_KEY
通过

即可生成APPSTORE_API_KEY_ID、APPSTORE_ISSUER_ID
此界面可以进行private key p8文件的下载,文件里有对应的private key,复制出来即可。
CODE_SIGNING_IDENTITY
举例 "Apple Distribution"
TEAM_ID

MOBILEPROVISION_BASE64
将对应的provision文件进行base64处理得到的字符串
P12_BASE64
将对应的p12文件进行base64处理得到的字符串
网友评论