-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (148 loc) · 5.8 KB
/
Copy pathupload-build-android.yml
File metadata and controls
167 lines (148 loc) · 5.8 KB
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
name: upload build
# See docs/flutter.md for required `release` environment variables and secrets.
on:
workflow_call:
inputs:
release_tag:
required: true
type: string
track:
description: >
The Google Play release track to which the uploaded app bundle will be
assigned (such as 'internal', 'alpha', 'beta', or 'production').
required: false
type: string
default: internal
release_status:
description: >
The release status to apply after uploading the app bundle.
Use 'draft' to create a draft release in the Play Console for
manual review and publishing, or 'completed' to publish
immediately to the selected track.
required: false
type: string
default: draft
jobs:
upload_build:
name: google play console
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Checkout source code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
persist-credentials: false
- name: Add Toolbox Envy to PATH
uses: EarthmanMuons/toolbox-envy/.github/actions/add-to-path@main
with:
include_bins: |
common
flutter
- name: Validate upload options
env:
INPUTS_TRACK: ${{ inputs.track }}
INPUTS_RELEASE_STATUS: ${{ inputs.release_status }}
run: |
set -euo pipefail
case "${INPUTS_TRACK}" in
internal|alpha|beta|production) ;;
*)
echo "::error::Invalid track '${INPUTS_TRACK}' (expected internal, alpha, beta, or production)."
exit 1
;;
esac
case "${INPUTS_RELEASE_STATUS}" in
draft|completed|inProgress|halted) ;;
*)
echo "::error::Invalid release_status '${INPUTS_RELEASE_STATUS}' (expected draft, completed, inProgress, or halted)."
exit 1
;;
esac
- id: release_notes
name: Resolve Google Play release notes directory
env:
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
set -euo pipefail
RELEASE_VERSION="${RELEASE_TAG#v}"
WHATS_NEW_DIRECTORY="docs/whatsnew/${RELEASE_VERSION}"
if [[ -z "${RELEASE_VERSION}" ]]; then
echo "::error::Could not derive a release version from release_tag '${RELEASE_TAG}'."
exit 1
fi
if [[ ! -d "${WHATS_NEW_DIRECTORY}" ]]; then
echo "::notice::Skipping Google Play release notes because '${WHATS_NEW_DIRECTORY}' does not exist."
exit 0
fi
echo "whats_new_directory=${WHATS_NEW_DIRECTORY}" >>"$GITHUB_OUTPUT"
- name: Download release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
set -euo pipefail
mkdir -p dist
if ! gh release download "$RELEASE_TAG" \
--pattern "*.aab" \
--pattern "sha256sums.txt" \
--dir dist; then
echo "::error::Failed to download release assets for tag '${RELEASE_TAG}'. Expected at least one .aab and sha256sums.txt."
exit 1
fi
- name: Verify release assets
run: verify-checksums --dir dist --pattern '*.aab'
- name: Validate Google Play authentication configuration
env:
GCP_WIF_PROVIDER: ${{ vars.GCP_WIF_PROVIDER }}
GCP_SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }}
GOOGLE_PLAY_PACKAGE_NAME: ${{ vars.GOOGLE_PLAY_PACKAGE_NAME }}
run: |
set -euo pipefail
if [[ -z "${GCP_WIF_PROVIDER}" ]]; then
echo "::error::Missing GCP_WIF_PROVIDER in the release environment."
exit 1
fi
if [[ -z "${GCP_SERVICE_ACCOUNT}" ]]; then
echo "::error::Missing GCP_SERVICE_ACCOUNT in the release environment."
exit 1
fi
if [[ -z "${GOOGLE_PLAY_PACKAGE_NAME}" ]]; then
echo "::error::Missing GOOGLE_PLAY_PACKAGE_NAME in the release environment."
exit 1
fi
- id: gcp_auth
name: Configure Google Cloud authentication
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093
with:
workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: upload aab with release notes
if: ${{ steps.release_notes.outputs.whats_new_directory != '' }}
uses: r0adkll/upload-google-play@e738b9dd8f2476ea806d921b64aacd24f34515a5
with:
serviceAccountJson: ${{ steps.gcp_auth.outputs.credentials_file_path }}
packageName: ${{ vars.GOOGLE_PLAY_PACKAGE_NAME }}
releaseFiles: dist/*.aab
tracks: ${{ inputs.track }}
status: ${{ inputs.release_status }}
whatsNewDirectory: ${{ steps.release_notes.outputs.whats_new_directory }}
- name: upload aab
if: ${{ steps.release_notes.outputs.whats_new_directory == '' }}
uses: r0adkll/upload-google-play@e738b9dd8f2476ea806d921b64aacd24f34515a5
with:
serviceAccountJson: ${{ steps.gcp_auth.outputs.credentials_file_path }}
packageName: ${{ vars.GOOGLE_PLAY_PACKAGE_NAME }}
releaseFiles: dist/*.aab
tracks: ${{ inputs.track }}
status: ${{ inputs.release_status }}
- name: Annotate workflow run with uploaded aab
run: |
ASSET_NAME="$(basename dist/*.aab)"
{
printf '### :shipit: Uploaded Android build:\n'
printf '\n'
printf -- '- [%s]\n' "${ASSET_NAME}"
} >>"$GITHUB_STEP_SUMMARY"