This repository was archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
132 lines (109 loc) · 4.39 KB
/
create_release.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
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
name: "Create release"
on:
pull_request:
types:
- closed
env:
FLUTTER_VERSION: "3.3.1"
jobs:
build:
runs-on: macos-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
outputs:
ANDROID_APK_NAME: ${{ steps.build.outputs.ANDROID_APK_NAME }}
steps:
- uses: actions/checkout@v2
# #499, https://github.com/actions/virtual-environments/issues/5595
- name: Configure ndk
run: |
ANDROID_HOME=$HOME/Library/Android/sdk
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
echo y | $SDKMANAGER "ndk;21.4.7075529"
ln -sfn $ANDROID_HOME/ndk/21.4.7075529 $ANDROID_HOME/ndk-bundle
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "8.x" # "betterprogramming.pub" says must be java "8"
cache: "gradle"
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }}
architecture: x64
- uses: actions/cache@v3
id: cache-deps
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./rust/target
key: ${{ runner.os }}-cargo-integrate-android-${{ hashFiles('**/Cargo.lock') }}-${{ steps.checkout.outputs.rustc_hash }}
- name: Install FFI bindings
if: steps.cache-deps.outputs.cache-hit != 'true'
run: cargo install flutter_rust_bridge_codegen
- name: Generate FFI bindings
run: make gen
- name: Add Rust targets
run: rustup target add armv7-linux-androideabi aarch64-linux-android
- name: Install `cargo-ndk`
if: steps.cache-deps.outputs.cache-hit != 'true'
run: cargo install cargo-ndk --force
- name: Build Rust lib
working-directory: ./rust
run: cargo ndk -o ../android/app/src/main/jniLibs build
- name: Parse version from pubspec.yaml
id: version
uses: jbutcher5/[email protected]
with:
file: "pubspec.yaml"
key-path: '["version"]'
- name: Build Android APK release
id: build
run: |
mkdir keystore
echo $ENCODED_KEYSTORE | base64 -d > keystore/upload-keystore.jks
BUILD_NAME=${{ steps.version.outputs.data }}
BUILD_NUMBER=$(git rev-list HEAD --count)
flutter build apk --build-name=$BUILD_NAME --build-number=$BUILD_NUMBER --release
mv build/app/outputs/flutter-apk/app.apk build/app/outputs/flutter-apk/tentenone-$BUILD_NAME.apk
echo "ANDROID_APK_NAME=$(echo tentenone-$BUILD_NAME.apk)" >> $GITHUB_OUTPUT
env:
SIGNING_KEY_ALIAS: ${{ secrets.ANDROID_UPLOAD_SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_UPLOAD_SIGNING_STORE_PASSWORD }}
ENCODED_KEYSTORE: ${{ secrets.ANDROID_UPLOAD_KEYSTORE }}
- name: Upload APK to job
uses: actions/upload-artifact@v3
with:
name: ${{steps.build.outputs.ANDROID_APK_NAME}}
path: build/app/outputs/flutter-apk/${{steps.build.outputs.ANDROID_APK_NAME}}
release:
needs: build
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract version from branch name
id: extract-version
shell: python
run: |
branch_name = "${{ github.event.pull_request.head.ref }}"
version = branch_name.split("/")[1]
print(f"::set-output name=version::{version}")
- name: Extract changelog section for release
id: changelog
uses: coditory/changelog-parser@v1
with:
version: ${{ steps.extract-version.outputs.version }}
- uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.ANDROID_APK_NAME }}
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: ${{ needs.build.outputs.ANDROID_APK_NAME }}
body: ${{ steps.changelog.outputs.description }}
token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
tag: ${{ steps.extract-version.outputs.version }}