-
Notifications
You must be signed in to change notification settings - Fork 39
186 lines (154 loc) · 5.6 KB
/
Build.yml
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
name: APK Release CI
on:
push:
tags: ['[0-9]+.[0-9]+.[0-9]+']
branches: [master]
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
outputs:
release_sha: ${{ steps.prepare_artifact.outputs.release_sha }}
short_sha: ${{ steps.prepare_artifact.outputs.short_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Android SDK
run: ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Assemble release APK
uses: gradle/gradle-command-action@v2
with:
arguments: :app:assembleRelease
- name: Sign release APK
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Prepare release artifact
id: prepare_artifact
run: |
mv app/build/outputs/apk/release/app-release-unsigned-signed.apk flixclusive-release.apk
echo "release_sha=$(sha256sum flixclusive-release.apk | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
echo "short_sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: release-apk
path: flixclusive-release.apk
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: release-apk
- name: Get previous tag
id: previousTag
if: startsWith(github.ref, 'refs/tags/')
run: |
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
echo "previousTag: $name"
echo "previousTag=$name" >> $GITHUB_ENV
- name: Generate changelogs
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fromTag: ${{ github.ref_name }}
toTag: ${{ startsWith(github.ref, 'refs/tags/') && env.previousTag || 'pre-release' }}
excludeTypes: ${{ startsWith(github.ref, 'refs/tags/') && 'build,docs,other,style' || '' }}
writeToFile: false
- name: Manage pre-release
if: "!startsWith(github.ref, 'refs/tags/')"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete pre-release --yes || true
gh release create pre-release \
--title "PR-${{ needs.build.outputs.short_sha }}" \
--notes "$(cat << EOF
##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._
---
### 🐞 Known issues
- TV focus crashes. Compose TV is bugged af; we wait til the new update.
${{ steps.changelog.outputs.changes }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| release | ${{ needs.build.outputs.release_sha }} |
EOF
)" \
--prerelease \
flixclusive-release.apk
- name: Manage stable release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--notes "$(cat << EOF
##### _NOTE: Android TV is incomplete, the providers on this port are not yet installable. Though, you could test it now._
---
### 🐞 Known issues
- TV focus crashes. Compose TV is bugged af; we wait til the new update.
${{ steps.changelog.outputs.changes }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| release | ${{ needs.build.outputs.release_sha }} |
EOF
)" \
flixclusive-release.apk
archive:
name: Archive APK
needs: [build, release]
if: "!startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout archives
uses: actions/checkout@v4
with:
ref: "archives"
path: "archives"
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: release-apk
- name: Archive pre-release APK
run: |
version=$(.github/parse_version.sh)
archive_dir="$GITHUB_WORKSPACE/archives/$version"
mkdir -p "$archive_dir"
cp flixclusive-release.apk "$archive_dir/PR-${{ needs.build.outputs.short_sha }} $(date +'%Y-%m-%d %H:%M:%S').apk"
cd $GITHUB_WORKSPACE/archives
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Archive $(date +'%Y-%m-%d') [flixclusiveorg/Flixclusive@${GITHUB_SHA}]" || true
git push