forked from ravindu644/Droidspaces-OSS
-
Notifications
You must be signed in to change notification settings - Fork 1
230 lines (199 loc) · 6.78 KB
/
Copy pathci.yml
File metadata and controls
230 lines (199 loc) · 6.78 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Droidspaces CI
run-name: ${{ github.event.head_commit.message || format('Release {0}', github.event.inputs.tag_name) || github.workflow }}
on:
push:
branches: [ "**" ]
tags:
- "v*"
pull_request:
branches: [ "**" ]
workflow_dispatch:
inputs:
create_release:
description: 'Create an Official GitHub Release?'
required: true
type: boolean
default: false
tag_name:
description: 'Tag name (Only used if Release is checked)'
required: false
default: 'test'
jobs:
build:
name: Build Backend & Android App
runs-on: ubuntu-latest
env:
HAS_RELEASE_KEYSTORE: ${{ secrets.KEYSTORE_BASE64 != '' }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
cache-dependency-path: |
Android/*.gradle*
Android/gradle.properties
Android/gradle/wrapper/gradle-wrapper.properties
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install Android SDK packages
run: |
yes | sdkmanager --licenses >/dev/null
sdkmanager "platforms;android-34" "build-tools;34.0.0"
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y build-essential dpkg-dev file wget tree zstd
- name: Download Toolchains
run: |
mkdir -p $HOME/toolchains
cd $HOME/toolchains
BASE_URL="https://github.com/ravindu644/Droidspaces-OSS/releases/download/compilers-25843896720"
echo "[*] Downloading aarch64 toolchain..."
wget -q $BASE_URL/aarch64-linux-musl-cross.tar.zst
echo "[*] Downloading armhf toolchain..."
wget -q $BASE_URL/arm-linux-musleabihf-cross.tar.zst
echo "[*] Downloading x86 toolchain..."
wget -q $BASE_URL/i686-linux-musl-cross.tar.zst
echo "[*] Downloading x86_64 toolchain..."
wget -q $BASE_URL/x86_64-linux-musl-cross.tar.zst
echo "[*] Downloading riscv64 toolchain..."
wget -q $BASE_URL/riscv64-linux-musl-cross.tar.zst
echo "[*] Extracting toolchains..."
for f in *.tar.zst; do
echo "Extracting $f..."
tar -xf "$f"
done
echo "[+] Toolchains ready."
tree -L 3 $HOME/toolchains
- name: Build All Tarball, Debian Packages & Sync to Android
run: |
make all-tarball
scripts/mkdeb.sh
- name: Decode Keystore
if: env.HAS_RELEASE_KEYSTORE == 'true'
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: printf '%s' "$KEYSTORE_BASE64" | base64 -d > droidspaces.keystore
- name: Grant execute permission for gradlew
run: chmod +x Android/gradlew
- name: Generate Contributors
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install -q requests
python3 scripts/generate_contributors.py
- name: Build Android App with Gradle
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cd Android
./gradlew assembleRelease \
-PKEYSTORE_PASSWORD="${KEYSTORE_PASSWORD:-}" \
-PKEY_ALIAS="${KEY_ALIAS:-}" \
-PKEY_PASSWORD="${KEY_PASSWORD:-}"
- name: Stage & Rename Artifacts
run: |
TAG="${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.tag_name || 'test' }}"
DATE=$(date +%Y-%m-%d)
APK_NAME="Droidspaces-universal-${TAG}-${DATE}.apk"
TAR_NAME=$(find . -maxdepth 1 -name 'droidspaces-v*-*.tar.gz' -printf '%f\n' | head -n 1)
if [ -z "$TAR_NAME" ]; then
echo "No Droidspaces tarball found"
exit 1
fi
mkdir -p dist
mv Android/app/build/outputs/apk/release/app-release.apk dist/${APK_NAME}
mv "$TAR_NAME" dist/
mv droidspaces_*.deb dist/
echo "APK_FILE=dist/${APK_NAME}" >> $GITHUB_ENV
echo "TAR_FILE=dist/${TAR_NAME}" >> $GITHUB_ENV
- name: Build Summary
run: |
{
echo "## Droidspaces build artifacts"
echo ""
echo "- APK: \`${APK_FILE}\`"
echo "- Tarball: \`${TAR_FILE}\`"
echo "- Debian packages: \`dist/*.deb\`"
echo ""
echo "Download them from the workflow run artifacts below."
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: droidspaces-apk
path: dist/*.apk
if-no-files-found: error
- name: Upload Tarball
uses: actions/upload-artifact@v4
with:
name: droidspaces-tarball
path: dist/*.tar.gz
if-no-files-found: error
- name: Upload Debian Packages
uses: actions/upload-artifact@v4
with:
name: droidspaces-debian-packages
path: dist/*.deb
if-no-files-found: error
release:
name: Create GitHub Release
needs: [build]
if: |
startsWith(github.ref, 'refs/tags/v') ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.create_release == 'true' &&
github.event.inputs.tag_name != '' &&
github.event.inputs.tag_name != 'test'
)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Generate Changelog
id: changelog
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "Previous tag: $PREV_TAG"
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --oneline --pretty=format:"* %s (%h)")
else
CHANGELOG=$(git log ${PREV_TAG}..HEAD --oneline --pretty=format:"* %s (%h)")
fi
{
echo "notes<<EOF"
echo "$CHANGELOG"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.tag_name }}
name: Droidspaces ${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.tag_name || 'Development Build' }}
target_commitish: ${{ github.sha }}
body: |
## What's Changed
${{ steps.changelog.outputs.notes }}
---
**Automated Release by Droidspaces CI**
files: |
release-assets/*.apk
release-assets/*.tar.gz
release-assets/*.deb