-
Notifications
You must be signed in to change notification settings - Fork 18
180 lines (158 loc) · 6.65 KB
/
deploy.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
on:
push:
branches: [master, develop]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
name: Deploy Action
jobs:
build:
permissions:
actions: "write"
name: "Bump version and Build App Bundle"
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
env:
PROPERTIES_PATH: android/key.properties
JAVA_VERSION: 21.x
APP_VERSION_PATH: app_version.txt
PUBSPEC_PATH: pubspec.yaml
defaults:
run:
working-directory: ./packages/uni_app
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.NIAEFEUPBOT_PAT }}
fetch-depth: 0
- name: Get develop hash
if: github.ref == 'refs/heads/master'
# We get the master hash by assuming that the last commit is always a
# merge commit. This is assured by requiring pull requests. You should NOT
# use rebase or squash merges onto the master branch.
run: |
git fetch origin develop
git pull origin master
echo "DEVELOP_HASH=$(git rev-parse origin/develop)" >> $GITHUB_ENV
echo "MASTER_HASH=$(git rev-parse origin/master^2)" >> $GITHUB_ENV
- name: Get latest version (develop)
if: github.ref != 'refs/heads/master'
uses: LuisDuarte1/[email protected]
id: latest-beta-version
with:
google_service_account_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
package_name: ${{ secrets.ANDROID_PACKAGE_NAME }}
track: "beta"
- name: Get latest production version
uses: LuisDuarte1/[email protected]
id: latest-production-version
with:
google_service_account_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
package_name: ${{ secrets.ANDROID_PACKAGE_NAME }}
track: "production"
- name: Bump beta version
uses: LuisDuarte1/[email protected]
if: github.ref != 'refs/heads/master'
id: bump-beta-version
with:
current_environment: staging
production_version: ${{ steps.latest-production-version.outputs.latest_version_name }}
staging_version: ${{ steps.latest-beta-version.outputs.latest_version_name }}
bump_type: prerelease
- name: Bump prod version (from develop)
uses: LuisDuarte1/[email protected]
if: github.ref == 'refs/heads/master' && env.MASTER_HASH == env.DEVELOP_HASH
id: bump-prod-minor-version
with:
current_environment: production
production_version: ${{ steps.latest-production-version.outputs.latest_version_name }}
bump_type: minor
- name: Bump prod version (patch)
uses: LuisDuarte1/[email protected]
if: github.ref == 'refs/heads/master' && env.MASTER_HASH != env.DEVELOP_HASH
id: bump-prod-patch-version
with:
current_environment: production
production_version: ${{ steps.latest-production-version.outputs.latest_version_name }}
bump_type: patch
- name: Combine output and write new version into file
run: |
export NEW_VERSION_NAME=${{
(steps.bump-beta-version.outcome == 'success' && steps.bump-beta-version.outputs.new_version) ||
(steps.bump-prod-minor-version.outcome == 'success' && steps.bump-prod-minor-version.outputs.new_version) ||
(steps.bump-prod-patch-version.outcome == 'success' && steps.bump-prod-patch-version.outputs.new_version)
}}
echo "$NEW_VERSION_NAME+$((${{steps.latest-production-version.outputs.latest_version_code}} + 1))" > ${{env.APP_VERSION_PATH}}
- name: Copy app version to pubspec
run: cat ${{ env.APP_VERSION_PATH }} | tr -d '\n' | perl -i -pe 's/^(version:\s+)(.+)$/$1.(<STDIN>)/e' ${{ env.PUBSPEC_PATH }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Bump app version [no ci]"
- uses: actions/setup-java@v4
with:
java-version: ${{env.JAVA_VERSION}}
distribution: "zulu"
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: packages/uni_app/pubspec.yaml
cache: true
- name: Download Android keystore
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > /tmp/key.jks
- name: Create key.properties
run: |
rm -f -- ${{env.PROPERTIES_PATH}}
touch ${{env.PROPERTIES_PATH}}
echo "storeFile=/tmp/key.jks" >> ${{env.PROPERTIES_PATH}}
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> ${{env.PROPERTIES_PATH}}
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> ${{env.PROPERTIES_PATH}}
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> ${{env.PROPERTIES_PATH}}
- name: Create .env file
run: echo "${{vars.UNI_ENV_FILE}}" > ./assets/env/.env
- name: Build Android App Bundle
run: |
flutter pub get
flutter build appbundle
- name: Upload App Bundle
uses: actions/upload-artifact@v4
with:
name: appbundle
if-no-files-found: error
path: packages/uni_app/build/app/outputs/bundle/release/app-release.aab
deploy_play_store:
name: "Deploy to Google Play Store"
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Get App Bundle
uses: actions/download-artifact@v4
with:
name: appbundle
- name: Release app to beta track
if: github.ref == 'refs/heads/develop'
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }}
releaseFiles: app-release.aab
whatsNewDirectory: whatsnew
track: beta
status: completed
- name: Release app to production track
if: github.ref == 'refs/heads/master'
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }}
releaseFiles: app-release.aab
whatsNewDirectory: whatsnew
track: production
status: completed
- name: Propagate version to develop
if: github.ref == 'refs/heads/master'
run: |
echo '${{ secrets.NIAEFEUPBOT_PAT }}' | gh auth login --with-token
gh workflow run 'Deploy Action' --ref develop