-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (86 loc) · 3.22 KB
/
main.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
name: Release Android APK
# MINIO_ENDPOINT
# MINIO_ACCESS_KEY
# MINIO_SECRET_KEY
# ANDROID_KEY_BASE64
# ANDROID_KS_PASS
# ANDROID_KEY_ALIAS
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build_android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract Version from pubspec.yaml
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | sed 's/version: //' | cut -d '+' -f 1)
echo "PUBSPEC_VERSION=$version" >> $GITHUB_ENV
# - name: Compare Version with Git Tag
# run: |
# pubspec_version="${{ env.PUBSPEC_VERSION }}"
# git_tag="${{ github.ref_name }}"
# echo "Version from pubspec.yaml: $pubspec_version"
# echo "Git tag from push: $git_tag"
# if [ "$pubspec_version" != "$git_tag" ]; then
# echo "Version ($pubspec_version) does not match Git tag ($git_tag)."
# exit 1
# else
# echo "Version matches the Git tag."
# fi
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '17'
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path
architecture: x64 # optional, x64 or arm64
flutter-version: 3.22.2
- run: flutter --version
- name: Build for Android
run: flutter build apk --release
- name: Key base64 to file
uses: timheuer/base64-to-file@v1.2
with:
fileName: 'android_key.jks'
fileDir: '/tmp/.android_key/'
encodedString: ${{ secrets.KEYSTORE_BASE64 }}
- name: Install apksigner
run: sudo apt install apksigner
- name: Sign apk
env:
ANDROID_KS_PASS: ${{ secrets.KEYSTORE_PASSWORD }}
run: |
for file in build/app/outputs/flutter-apk/*.apk; do
filename="${file##*/}"
echo "Signing ${filename}"
apksigner sign --v4-signing-enabled false --ks /tmp/.android_key/android_key.jks --ks-pass env:ANDROID_KS_PASS --ks-key-alias ${{ secrets.KEY_ALIAS }} ${file}
done
- name: Get apk info
id: apk-info
uses: hkusu/apk-info-action@v1
with:
apk-path: build/app/outputs/flutter-apk/app-release.apk
- name: Rename Apk And Move Apk
run: |
mkdir -p build/app/outputs/my-release
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/my-release/fuckketangpai-android-v${{ steps.apk-info.outputs.version-name }}.apk
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag: ${{ github.ref_name }}
files: build/app/outputs/my-release/fuckketangpai-android-v${{ steps.apk-info.outputs.version-name }}.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}