-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (171 loc) · 6.97 KB
/
build.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
on:
pull_request:
workflow_dispatch:
# Declare default permissions as read only.
permissions:
contents: read
jobs:
test_image:
permissions:
# Allow to write packages for the docker/scout-action to write a comment
packages: write
# Allow to write pull requests for the docker/scout-action to write a comment
pull-requests: write
# Allow to write security events for github/codeql-action/upload-sarif to upload SARIF results
security-events: write
runs-on: ubuntu-24.04
env:
IMAGE_REPOSITORY_NAME: flutter-android
VERSION_MANIFEST: config/version.json
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Read environment variables from version.json
env:
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: ./script/set_environment_variables.sh
- name: Load image metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
id: metadata
with:
images: |
${{ env.IMAGE_REPOSITORY_PATH }}
ghcr.io/${{ env.IMAGE_REPOSITORY_PATH }}
quay.io/${{ env.IMAGE_REPOSITORY_PATH }}
tags: |
type=raw,value=${{ env.FLUTTER_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: Build image and push to local Docker daemon
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with:
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}
target: android
build-args: |
flutter_version=${{ env.FLUTTER_VERSION }}
fastlane_version=${{ env.FASTLANE_VERSION }}
android_build_tools_version=${{ env.ANDROID_BUILD_TOOLS_VERSION }}
android_platform_versions=${{ env.ANDROID_PLATFORM_VERSIONS }}
- name: Test image
uses: plexsystems/container-structure-test-action@c0a028aa96e8e82ae35be556040340cbb3e280ca # v0.3.0
with:
image: ${{ fromJSON(steps.metadata.outputs.json).tags[0] }}
config: test/android.yml
# TODO: Parallelize testing and vulnerability scanning
- name: Scan with Docker Scout
id: docker-scout
uses: docker/scout-action@6ac950eb733f8b2811f25c05d97bfb3d181b8026 # v1
with:
command: compare, recommendations
# Use the Docker Hub image that is the first tag in the metadata
image: local://${{ fromJson(steps.metadata.outputs.json).tags[0] }}
# github-token is needed to be able to write the PR comment
github-token: ${{ github.token }}
only-fixed: true
organization: ${{ secrets.DOCKER_HUB_USERNAME }}
# sarif-file: output.sarif.json
to-env: prod
# Enable debug logging when needed
# debug: true
# verbose-debug: true
validate_version:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Cue for JSON validation
uses: cue-lang/setup-cue@a93fa358375740cd8b0078f76355512b9208acb1 # v1.0.1
- name: Validate version.json and flutter_version.json
run: |
cue vet config/version.cue config/version.json
cue vet config/flutter_version.cue config/flutter_version.json
validate_generated_config:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Generate test files
uses: mikefarah/yq@bbdd97482f2d439126582a59689eb1c855944955 # v4
with:
cmd: ./script/update_test.sh
- name: Check if there are any changes in the git working tree
run: |
git add -A
git diff --exit-code HEAD
build_docs:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup NodeJS
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
cache: 'npm'
cache-dependency-path: docs/src/package-lock.json
node-version-file: docs/src/package.json
- name: Update documentation
working-directory: docs/src
run: |
npm ci --prefer-offline
npm run build
- name: Check if there are any changes in the git working tree
run: |
git add -A
git diff --exit-code HEAD
test_gradle:
permissions:
# Allow to read packages to pull the container image from GitHub Container Registry
packages: read
runs-on: ubuntu-24.04
container:
image: ghcr.io/${{ github.repository_owner }}/flutter-android:${{ vars.FLUTTER_VERSION }}
credentials:
username: ${{ github.actor }}
password: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Read version.json
id: version-json
run: |
{
echo "content<<EOF"
cat ./config/version.json
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Set environment variables from version.json
run: |
echo "FLUTTER_VERSION=${{ fromJson( steps.version-json.outputs.content ).flutter.version }}" >> $GITHUB_ENV
echo "FLUTTER_CHANNEL=${{ fromJson( steps.version-json.outputs.content ).flutter.channel }}" >> $GITHUB_ENV
- name: Setup Flutter
run: |
cd $FLUTTER_ROOT
git fetch origin ${{ env.FLUTTER_VERSION }}:${{ env.FLUTTER_VERSION }}
git switch ${{ env.FLUTTER_VERSION }}
- name: Create test application
run: |
flutter create test_app
- name: Update default Android platform versions in Flutter
working-directory: test_app/android
run: |
cat ../../script/updateAndroidVersions.gradle >> app/build.gradle
./gradlew --warning-mode all updateAndroidVersions
- name: Setup Cue for JSON validation
uses: cue-lang/setup-cue@a93fa358375740cd8b0078f76355512b9208acb1 # v1.0.1
- name: Validate version.json
run: cue vet config/version.cue config/version.json