Skip to content

Commit 6c12e0b

Browse files
committed
Refactor CI workflows for modular release process
Split release logic into modular workflow files for building, GitHub release, and Telegram release. Updated release-ci.yml to use matrix builds for official and spoofed flavors, and to call reusable workflows for GitHub and Telegram releases. Improved artifact handling and environment variable management for better maintainability and extensibility.
1 parent 50a3a18 commit 6c12e0b

File tree

4 files changed

+393
-176
lines changed

4 files changed

+393
-176
lines changed

.github/workflows/build.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build APK
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
flavor:
7+
description: "Flavor"
8+
type: string
9+
required: true
10+
buildType:
11+
description: "Build Type"
12+
type: string
13+
required: true
14+
15+
jobs:
16+
build:
17+
name: Build ${{ inputs.flavor }}-${{ inputs.buildType }}
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Set environment variables
22+
run: |
23+
FLAVOR="${{ inputs.flavor }}"
24+
BUILD_TYPE="${{ inputs.buildType }}"
25+
26+
echo "FLAVOR_CAPITALIZED=${FLAVOR^}" >> $GITHUB_ENV
27+
echo "FLAVOR_CAPITALIZED_ALL=${FLAVOR^^}" >> $GITHUB_ENV
28+
echo "FLAVOR_LOWERCASE=${FLAVOR,,}" >> $GITHUB_ENV
29+
echo "BUILD_TYPE_CAPITALIZED=${BUILD_TYPE^}" >> $GITHUB_ENV
30+
echo "BUILD_TYPE_LOWERCASE=${BUILD_TYPE,,}" >> $GITHUB_ENV
31+
echo "BUILD_COMMAND=${FLAVOR^}${BUILD_TYPE^}" >> $GITHUB_ENV
32+
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Set up signing key
39+
run: |
40+
if [ -n "${{ secrets.KEY_STORE }}" ]; then
41+
echo keyStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> signing.properties
42+
echo keyAlias='${{ secrets.KEY_ALIAS }}' >> signing.properties
43+
echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> signing.properties
44+
echo keyStore='${{ github.workspace }}/key.jks' >> signing.properties
45+
echo ${{ secrets.KEY_STORE }} | base64 --decode > ${{ github.workspace }}/key.jks
46+
fi
47+
48+
- name: Set up JDK
49+
uses: actions/setup-java@v4
50+
with:
51+
distribution: "zulu"
52+
java-version: 21
53+
54+
- name: Set up Gradle
55+
uses: gradle/actions/setup-gradle@v4
56+
with:
57+
validate-wrappers: true
58+
59+
- name: Build APK
60+
run: chmod +x ./gradlew && ./gradlew assemble${{ env.BUILD_COMMAND }}
61+
62+
- name: Get APK output
63+
id: apk
64+
run: |
65+
apk_path=$(find app/build/outputs/apk/${{ env.FLAVOR_LOWERCASE }}/${{ env.BUILD_TYPE_LOWERCASE }} -name "*.apk" -print -quit)
66+
mapping_path=$(find app/build/outputs/mapping/${{ env.FLAVOR_LOWERCASE }}${{ env.BUILD_TYPE_CAPITALIZED }} -name "mapping.txt" -print -quit)
67+
name=$(basename "$apk_path" .apk)
68+
69+
echo "name=$name" >> $GITHUB_OUTPUT
70+
echo "path=$apk_path" >> $GITHUB_OUTPUT
71+
echo "mapping=$mapping_path" >> $GITHUB_OUTPUT
72+
73+
echo "${{ env.FLAVOR_CAPITALIZED_ALL }}_NAME=\"$name\"" >> ${{ inputs.flavor }}.${{ inputs.buildType }}.txt
74+
75+
- name: Upload mapping as artifact
76+
if: steps.apk.outputs.mapping != ''
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ inputs.flavor }}-${{ inputs.buildType }}-mapping
80+
path: ${{ steps.apk.outputs.mapping }}
81+
82+
- name: Upload APK as artifact
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: ${{ steps.apk.outputs.name }}
86+
path: ${{ steps.apk.outputs.path }}
87+
88+
- name: Upload env info
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ inputs.flavor }}.${{ inputs.buildType }}
92+
path: ${{ inputs.flavor }}.${{ inputs.buildType }}.txt

.github/workflows/github.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Release to GitHub
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
officialAssetName:
7+
type: string
8+
required: true
9+
spoofedAssetName:
10+
type: string
11+
required: true
12+
13+
jobs:
14+
release-gh:
15+
name: Release GH
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Download Official Release APK
24+
uses: actions/download-artifact@v4
25+
with:
26+
name: ${{ inputs.officialAssetName }}
27+
path: official-apk
28+
29+
- name: Download Spoofed Release APK
30+
uses: actions/download-artifact@v4
31+
with:
32+
name: ${{ inputs.spoofedAssetName }}
33+
path: spoofed-apk
34+
35+
- name: Find APKs by name
36+
id: find_apks
37+
run: |
38+
OFFICIAL_APK_PATH=$(find official-apk -maxdepth 1 -type f -name "${{ inputs.officialAssetName }}*.apk" -print -quit)
39+
SPOOFED_APK_PATH=$(find spoofed-apk -maxdepth 1 -type f -name "${{ inputs.spoofedAssetName }}*.apk" -print -quit)
40+
41+
if [ -z "$OFFICIAL_APK_PATH" ]; then
42+
echo "❌ No official APK found matching ${{ inputs.officialAssetName }}"
43+
exit 1
44+
fi
45+
46+
if [ -z "$SPOOFED_APK_PATH" ]; then
47+
echo "❌ No spoofed APK found matching ${{ inputs.spoofedAssetName }}"
48+
exit 1
49+
fi
50+
51+
echo "OFFICIAL_APK_PATH=$OFFICIAL_APK_PATH" >> $GITHUB_OUTPUT
52+
echo "SPOOFED_APK_PATH=$SPOOFED_APK_PATH" >> $GITHUB_OUTPUT
53+
54+
- name: Get commit info and build timestamp
55+
id: meta
56+
run: |
57+
BUILD_DATE=$(date +"%Y-%m-%d %H:%M:%S")
58+
VERSION=$(git rev-list --count HEAD || echo 0)
59+
60+
if [ -f commits.sh ]; then
61+
MESSAGE=$(bash commits.sh 10000)
62+
else
63+
MESSAGE="Latest commits not available."
64+
fi
65+
66+
echo "VERSION=$VERSION" >> $GITHUB_ENV
67+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
68+
echo "MESSAGE<<EOF" >> $GITHUB_ENV
69+
echo "$MESSAGE" >> $GITHUB_ENV
70+
echo "EOF" >> $GITHUB_ENV
71+
72+
- name: Check if release exists
73+
id: check_release
74+
run: |
75+
if gh release view v${{ env.VERSION }} --repo ${{ github.repository }} > /dev/null 2>&1; then
76+
echo "exists=true" >> $GITHUB_OUTPUT
77+
else
78+
echo "exists=false" >> $GITHUB_OUTPUT
79+
fi
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Create GitHub Release
84+
if: steps.check_release.outputs.exists == 'false'
85+
id: create_release
86+
uses: actions/create-release@v1
87+
with:
88+
tag_name: v${{ env.VERSION }}
89+
release_name: v${{ env.VERSION }}
90+
body: |
91+
## What's new?
92+
93+
${{ env.MESSAGE }}
94+
95+
[Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
99+
- name: Upload Official Release APK to GitHub
100+
if: steps.check_release.outputs.exists == 'false'
101+
uses: actions/upload-release-asset@v1
102+
with:
103+
upload_url: ${{ steps.create_release.outputs.upload_url }}
104+
asset_path: ${{ steps.find_apks.outputs.OFFICIAL_APK_PATH }}
105+
asset_name: ${{ inputs.officialAssetName }}.apk
106+
asset_content_type: application/vnd.android.package-archive
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
110+
- name: Upload Spoofed Release APK to GitHub
111+
if: steps.check_release.outputs.exists == 'false'
112+
uses: actions/upload-release-asset@v1
113+
with:
114+
upload_url: ${{ steps.create_release.outputs.upload_url }}
115+
asset_path: ${{ steps.find_apks.outputs.SPOOFED_APK_PATH }}
116+
asset_name: ${{ inputs.spoofedAssetName }}.apk
117+
asset_content_type: application/vnd.android.package-archive
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)