Create main.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 构建 Android 应用 | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 设置 Java 环境 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: 安装依赖 | |
run: | | |
sudo apt update | |
sudo apt install -y apktool signapk | |
- name: 赋予脚本执行权限 | |
run: chmod +x build.sh | |
- name: 构建应用 | |
run: ./build.sh | |
# 将构建产物保存为工件,方便下载 | |
- name: 保存构建产物 | |
uses: actions/upload-artifact@v2 | |
with: | |
name: app-build | |
# 修改路径,指向生成的 mybv.apk 文件 | |
path: mybv.apk | |
# 添加一个新的 job 来下载构建产物 | |
download: | |
needs: build # 确保 build job 完成后再运行 | |
runs-on: ubuntu-latest | |
steps: | |
- name: 下载构建产物 | |
uses: actions/download-artifact@v2 | |
with: | |
name: app-build | |
# 下载后,您可以在 Actions 页面找到该工件并下载 |