Skip to content

Commit c5b9435

Browse files
committed
workflow improvement
1 parent 75edbd0 commit c5b9435

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ on:
66
tags: ['v*']
77
pull_request:
88
branches: [main, master]
9+
workflow_dispatch:
10+
inputs:
11+
build_type:
12+
description: 'Build type'
13+
required: true
14+
default: 'debug'
15+
type: choice
16+
options:
17+
- debug
18+
- release
19+
- both
920

1021
jobs:
1122
build:
@@ -23,27 +34,29 @@ jobs:
2334
- name: Setup Gradle
2435
uses: gradle/actions/setup-gradle@v4
2536

26-
# ── Debug build (every push / PR) ──────────────────────────────
37+
# ── Debug build ──────────────────────────────────────────────────
2738

2839
- name: Build debug APK
40+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both'
2941
run: ./gradlew assembleDebug --no-daemon
3042

3143
- name: Upload debug APK
44+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both'
3245
uses: actions/upload-artifact@v4
3346
with:
3447
name: app-debug
3548
path: app/build/outputs/apk/debug/app-debug.apk
3649

37-
# ── Release build (tags only, signed if secrets configured) ────
50+
# ── Release build (tags or manual trigger, signed if secrets configured) ────
3851

3952
- name: Decode keystore
40-
if: startsWith(github.ref, 'refs/tags/v') && env.KEYSTORE_BASE64 != ''
53+
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
4154
env:
4255
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
4356
run: echo "$KEYSTORE_BASE64" | base64 -d > release.keystore
4457

4558
- name: Create keystore.properties
46-
if: startsWith(github.ref, 'refs/tags/v') && env.KEYSTORE_BASE64 != ''
59+
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
4760
env:
4861
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
4962
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
@@ -58,18 +71,18 @@ jobs:
5871
EOF
5972
6073
- name: Build release APK
61-
if: startsWith(github.ref, 'refs/tags/v')
74+
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both'
6275
run: ./gradlew assembleRelease --no-daemon
6376

6477
- name: Upload release APK
65-
if: startsWith(github.ref, 'refs/tags/v')
78+
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both'
6679
uses: actions/upload-artifact@v4
6780
with:
6881
name: app-release-unsigned
6982
path: app/build/outputs/apk/release/app-release-unsigned.apk
7083

7184
- name: Upload signed release APK
72-
if: startsWith(github.ref, 'refs/tags/v') && env.KEYSTORE_BASE64 != ''
85+
if: (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == 'both') && env.KEYSTORE_BASE64 != ''
7386
env:
7487
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
7588
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)