-
Notifications
You must be signed in to change notification settings - Fork 3
201 lines (178 loc) · 6.12 KB
/
Copy pathmain.yml
File metadata and controls
201 lines (178 loc) · 6.12 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Release
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
draft:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.check_release.outputs.tag_title }}
steps:
- uses: actions/checkout@v6
- name: Check if release exists
id: check_release
env:
TZ: 'Asia/Tokyo'
GH_TOKEN: ${{ github.token }}
run: |
VERSION_FILE=buildSrc/src/main/java/property/Version.kt
MAJOR=$(cat $VERSION_FILE | grep MAJOR | head -1 | awk '{print $6}')
MIDDLE=$(cat $VERSION_FILE | grep MIDDLE | head -1 | awk '{print $6}')
MINOR=$(cat $VERSION_FILE | grep MINOR | head -1 | awk '{print $6}')
CURRENT_VERSION=$MAJOR.$MIDDLE.$MINOR
echo $CURRENT_VERSION
tag_title="${CURRENT_VERSION}_draft"
echo "tag_title=${tag_title}" >> $GITHUB_OUTPUT
releases=$(curl -s -H "Authorization: token ${GH_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=50")
RELEASE_EXISTS=$(echo $releases | jq --arg search_name $tag_title '[.[] | select(.draft == true and .name == $search_name)] | length > 0')
echo $RELEASE_EXISTS
if [[ $RELEASE_EXISTS == true ]]; then
echo "release_exists=true" >> $GITHUB_OUTPUT
echo "Release ${tag_title} already exists, skipping creation."
else
echo "release_exists=false" >> $GITHUB_OUTPUT
echo "Release ${tag_title} does not exist. I will create it on next step."
fi
shell: bash
- name: Create Release
id: create_release
if: steps.check_release.outputs.release_exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ steps.check_release.outputs.tag_title }} --title ${{ steps.check_release.outputs.tag_title }} --draft
shell: bash
build:
needs: draft
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install
timeout-minutes: 3
uses: actions/setup-java@v5
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '21'
- name: Download Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 35
build-tools: 35.0.0
- name: Prepare credentials
id: prepare-credentials
timeout-minutes: 1
run: |
echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 -d > release_keystore.jks
echo "store_file=$(realpath release_keystore.jks)" >> "${GITHUB_OUTPUT}"
- name: Grant permission of Gradle wrapper
timeout-minutes: 1
run: chmod +x gradlew
- name: Build Release APK
timeout-minutes: 16
run: |
./gradlew assembleRelease
env:
_JAVA_OPTIONS: '-Duser.language=ja -Duser.country=JP'
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
STORE_FILE_PATH: ${{ steps.prepare-credentials.outputs.store_file }}
- name: Clean up credentials
timeout-minutes: 1
if: ${{ always() }}
run: |
rm release_keystore.jks
- name: Upload artifacts
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release artifacts
path: |
app/build/outputs/
- name: Upload APK to artifact
timeout-minutes: 2
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Release APK
path: |
app/build/outputs/apk/release/*.apk
- name: Upload artifact to release
timeout-minutes: 5
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.draft.outputs.release_tag }}
run: |
tag_title=$RELEASE_TAG
gh release upload ${tag_title} app/build/outputs/apk/release/*.apk --clobber
shell: bash
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: install
timeout-minutes: 3
uses: actions/setup-java@v5
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '21'
cache: gradle
- name: Grant permission of Gradle wrapper
timeout-minutes: 1
run: chmod +x gradlew
- name: Coverage
timeout-minutes: 18
env:
TZ: 'Asia/Tokyo'
_JAVA_OPTIONS: '-Duser.language=ja -Duser.country=JP -Duser.timezone=Asia/Tokyo'
run: "./gradlew koverHtmlReport"
- name: Upload configuration cache
timeout-minutes: 3
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: Configuration cache
path: |
build/reports/configuration-cache/
build/reports/problems/problems-report.html
- name: Upload Unit Test Results
timeout-minutes: 3
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: Unit Test Results
path: |
*/build/reports/tests
- name: Upload Coverage Results
timeout-minutes: 3
if: ${{ success() }}
uses: actions/upload-artifact@v7
with:
name: Kover Results
path: |
build/reports/kover
- name: Print summary
timeout-minutes: 1
if: ${{ success() }}
run: ./gradlew printCoverageSummary
- name: Store summary
timeout-minutes: 1
if: ${{ success() }}
run: |
echo "## Test coverage" >> $GITHUB_STEP_SUMMARY
./gradlew printCoverageSummary >> $GITHUB_STEP_SUMMARY
cat $GITHUB_STEP_SUMMARY
shell: bash