-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (137 loc) · 5.44 KB
/
master-build-apk.yaml
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
133
134
135
136
137
138
139
name: Release (master)
on:
push:
branches:
- master
schedule:
- cron: '0 15 * * 4'
jobs:
bumpVersion:
runs-on: ubuntu-latest
environment: master
concurrency: master
outputs:
new_tag: ${{ steps.get_version.outputs.new_tag }}
commit_sha: ${{ steps.get_commit_sha.outputs.commit_sha }}
has_changes: ${{ steps.merge.outputs.has_changes }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
ref: 'master'
- name: Config git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Merge develop -> master
id: merge
run: |
git fetch
git checkout master
git pull
CHANGES=$(git log master..origin/develop --oneline)
if [[ -z "$CHANGES" ]]; then
echo "No changes to merge."
echo "has_changes=no" >> $GITHUB_OUTPUT
else
git merge origin/develop
echo "has_changes=yes" >> $GITHUB_OUTPUT
fi
- name: Calculate new version
id: get_version
if: steps.merge.outputs.has_changes == 'yes'
uses: mathieudutour/github-tag-action@v6.1
with:
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
release_branches: .*
- name: Update version in pubspec.yaml
if: steps.merge.outputs.has_changes == 'yes'
run: |
sed -i 's/version: .*/version: ${{ steps.get_version.outputs.new_tag }}/g' pubspec.yaml
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add pubspec.yaml
git diff --quiet && git diff --staged --quiet || git commit -m "Updated version in pubspec.yaml"
- name: Push version changes to develop
if: steps.merge.outputs.has_changes == 'yes'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: develop
- name: Push version changes to master
if: steps.merge.outputs.has_changes == 'yes'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
- name: Resolve commit SHA
if: steps.merge.outputs.has_changes == 'yes'
id: get_commit_sha
run: echo "::set-output name=commit_sha::$(git rev-parse HEAD)"
- name: Tag version
if: steps.merge.outputs.has_changes == 'yes'
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
custom_tag: ${{ steps.get_version.outputs.new_tag }}
commit_sha: ${{ steps.get_commit_sha.outputs.commit_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
- name: Create a GitHub release
if: steps.merge.outputs.has_changes == 'yes'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.get_version.outputs.new_tag }}
name: Release ${{ steps.get_version.outputs.new_tag }}
body: ${{ steps.get_version.outputs.changelog }}
buildAndroid:
runs-on: ubuntu-latest
environment: master
concurrency: master
needs: bumpVersion
if: needs.bumpVersion.outputs.has_changes == 'yes'
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
ref: ${{ needs.bumpVersion.outputs.commit_sha }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Build APK
uses: subosito/flutter-action@v2
with:
flutter-version: "3.19.6"
channel: "stable"
- run: |
export API_BASE_URL=${{ secrets.API_BASE_URL }}
export KEYCLOAK_URL=${{ secrets.KEYCLOAK_URL }}
export KEYCLOAK_REALM=${{ secrets.KEYCLOAK_REALM }}
export KEYCLOAK_CLIENT_ID=${{ secrets.KEYCLOAK_CLIENT_ID }}
export KEYCLOAK_CLIENT_SECRET=${{ secrets.KEYCLOAK_CLIENT_SECRET }}
export UPDATES_URL=${{ secrets.UPDATES_URL }}
echo ${{ secrets.SIGN_KEYSTORE }} > /tmp/app.keystore.b64 && base64 -d -i /tmp/app.keystore.b64 > /tmp/app.keystore
echo storePassword=${{ secrets.SIGN_STORE_PASSWORD }} >> android/key.properties
echo keyPassword=${{ secrets.SIGN_STORE_PASSWORD }} >> android/key.properties
echo keyAlias=app >> android/key.properties
echo storeFile=/tmp/app.keystore >> android/key.properties
flutter pub run dart_define generate
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build apk --dart-define-from-file=env.json
mkdir -p update/android/${{ needs.bumpVersion.outputs.new_tag }}
mv build/app/outputs/apk/release/output-metadata.json update/android/output-metadata.json
mv build/app/outputs/apk/release/*.apk update/android/${{ needs.bumpVersion.outputs.new_tag }}/
- name: Upload APK
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: ${{ secrets.UPDATES_BUCKET }}
source_dir: update
destination_dir: "production/"