Skip to content

Commit ae24b75

Browse files
author
OpenCode Bot
committed
ci: fix GitHub Actions workflow for building and releasing APK
- Add debug keystore generation - Add keystore.properties creation - Add artifact upload/download for manual release
1 parent dd1ebb2 commit ae24b75

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version tag (e.g., v1.3.2)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: 'temurin'
26+
java-version: '17'
27+
28+
- name: Setup Android SDK
29+
uses: android-actions/setup-android@v2
30+
31+
- name: Create debug keystore
32+
run: |
33+
if [ ! -f "debug.jks" ]; then
34+
keytool -genkey -v -keystore debug.jks -alias android -keyalg RSA -keysize 2048 -validity 10000 \
35+
-storepass android -keypass android -dname "CN=Android Debug,O=Android,C=US"
36+
fi
37+
38+
- name: Create keystore.properties
39+
run: |
40+
echo "storeFile=debug.jks" > keystore.properties
41+
echo "storePassword=android" >> keystore.properties
42+
echo "keyAlias=android" >> keystore.properties
43+
echo "keyPassword=android" >> keystore.properties
44+
45+
- name: Grant execute permission
46+
run: chmod +x gradlew
47+
48+
- name: Build Release APK
49+
run: ./gradlew assembleRelease --no-daemon 2>&1
50+
51+
- name: Upload APK
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: apk
55+
path: releases/*.apk
56+
57+
- name: Download APK
58+
if: github.event_name == 'workflow_dispatch'
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: apk
62+
63+
- name: Create Release
64+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
65+
uses: softprops/action-gh-release@v2
66+
with:
67+
files: releases/*.apk
68+
generate_release_notes: true
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Upload to Release
73+
if: github.event_name == 'workflow_dispatch'
74+
run: |
75+
curl -s -X POST \
76+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
77+
-H "Content-Type: application/octet-stream" \
78+
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.inputs.release_id }}/assets?name=$(ls releases/*.apk | xargs basename)" \
79+
--data-binary "@releases/*.apk"

0 commit comments

Comments
 (0)