Repository navigation
79 lines (66 loc) · 2.1 KB
/
Copy pathci.yml
File metadata and controls
79 lines (66 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Android CI
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
# 并发策略
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
# 如果有新的运行实例,取消正在进行的实例
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HAS_RELEASE_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检出项目
uses: actions/checkout@v4
- name: 使用JDK 17 环境
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: gradlew 添加可执行权限
run: chmod +x ./gradlew
- name: 静态代码检查 (Detekt)
if: env.HAS_RELEASE_TAG != 'true'
run: ./gradlew detektAll
- name: 上传 Detekt 报告
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: detekt-report
path: ./**/build/reports/detekt/**
- name: 构建和测试 (Debug)
if: env.HAS_RELEASE_TAG != 'true'
run: ./gradlew testDebugUnitTest publishMainPublicationToGitHubPackagesRepository assembleDebug
- name: 构建、测试和发布 (Release)
if: env.HAS_RELEASE_TAG == 'true'
run: ./gradlew testDebugUnitTest publishMainPublicationToGitHubPackagesRepository assembleRelease
- name: 上传单元测试报告
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-artifact
path: ./**/build/reports/**
- name: 上传产出物
uses: actions/upload-artifact@v4
with:
name: outputs-artifact
path: ./**/build/outputs/**
- name: GitHub Release
if: ${{ env.HAS_RELEASE_TAG == 'true' }}
uses: ncipollo/release-action@v1
with:
draft: false
artifacts: "app/build/outputs/apk/*/*.apk,apps/*/build/outputs/apk/*/*.apk"
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}