Repository navigation
228 lines (209 loc) · 8.89 KB
/
Copy pathandroid-release-artifacts.yml
File metadata and controls
228 lines (209 loc) · 8.89 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Android Release Artifacts
on:
workflow_call:
inputs:
version:
description: Version name to be uploaded for AAR release
required: false
type: string
default: ''
upload_to_maven:
description: Upload the AAR to Maven Central for manual review
required: false
type: boolean
default: false
source_ref:
description: Git ref or SHA to build; defaults to the workflow commit
required: false
type: string
default: ''
flavor:
description: Build flavor
required: false
type: string
default: 'xnnpack'
workflow_dispatch:
inputs:
version:
description: Version name to be uploaded for AAR release
required: false
type: string
upload_to_maven:
description: Upload the AAR to Maven Central for manual review
required: false
type: boolean
source_ref:
description: Git ref or SHA to build; defaults to the workflow commit
required: false
type: string
flavor:
type: choice
options:
- "xnnpack"
- "xnnpack-no-sme2"
- "vulkan"
- "qnn"
- "all"
schedule:
- cron: 0 10 * * *
jobs:
docker-image:
name: Resolve CI docker image
uses: ./.github/workflows/_docker-image.yml
check-if-aar-exists:
name: check-if-aar-exists
runs-on: ubuntu-22.04
timeout-minutes: 10
outputs:
aar-exists: ${{ steps.check.outputs.aar-exists }}
should-skip: ${{ steps.check.outputs.should-skip }}
steps:
- name: Check if this RC version is already in S3
id: check
shell: bash
run: |
VERSION="${{ inputs.version }}"
FLAVOR="${{ inputs.flavor }}"
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
if [ -z "$FLAVOR" ]; then
FLAVOR="xnnpack"
fi
if [[ "$UPLOAD_TO_MAVEN" == "true" && -z "$VERSION" ]]; then
echo "A version is required when publishing to Maven Central"
exit 1
fi
if [ -z "$VERSION" ]; then
echo "No version name specified. Will create a snapshot AAR"
echo "aar-exists=false" >> $GITHUB_OUTPUT
echo "should-skip=false" >> $GITHUB_OUTPUT
exit 0
fi
if curl -I "https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar" | grep "200 OK"; then
echo "AAR already exists at https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar"
echo "aar-exists=true" >> $GITHUB_OUTPUT
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
echo "Maven publishing requested. Will rebuild without replacing the S3 artifact"
echo "should-skip=false" >> $GITHUB_OUTPUT
else
echo "Will skip build/upload"
echo "should-skip=true" >> $GITHUB_OUTPUT
fi
else
echo "aar-exists=false" >> $GITHUB_OUTPUT
echo "should-skip=false" >> $GITHUB_OUTPUT
fi
build-aar:
name: build-aar
needs: [docker-image, check-if-aar-exists]
if: ${{ !github.event.pull_request.head.repo.fork && needs.check-if-aar-exists.outputs.should-skip != 'true' }}
uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
secrets: inherit
permissions:
id-token: write
contents: read
with:
secrets-env: EXECUTORCH_MAVEN_SIGNING_KEYID EXECUTORCH_MAVEN_SIGNING_PASSWORD EXECUTORCH_MAVEN_CENTRAL_PASSWORD EXECUTORCH_MAVEN_CENTRAL_USERNAME EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS
docker-image: ${{ needs.docker-image.outputs.docker-registry }}/ci-image:executorch-ubuntu-22.04-clang12-android-${{ needs.docker-image.outputs.ci-docker-hash }}
submodules: 'recursive'
ref: ${{ inputs.source_ref || github.sha }}
timeout: 90
upload-artifact: android-apps
upload-artifact-to-s3: true
script: |
set -eux
# Use sccache for NDK compiler as well
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
export CMAKE_C_COMPILER_LAUNCHER=sccache
# The Android image already contains the build dependencies and pinned PyTorch.
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
mkdir -p ~/.gradle
touch ~/.gradle/gradle.properties
echo "signing.keyId=${SECRET_EXECUTORCH_MAVEN_SIGNING_KEYID}" >> ~/.gradle/gradle.properties
echo "signing.password=${SECRET_EXECUTORCH_MAVEN_SIGNING_PASSWORD}" >> ~/.gradle/gradle.properties
echo "mavenCentralUsername=${SECRET_EXECUTORCH_MAVEN_CENTRAL_USERNAME}" >> ~/.gradle/gradle.properties
echo "mavenCentralPassword=${SECRET_EXECUTORCH_MAVEN_CENTRAL_PASSWORD}" >> ~/.gradle/gradle.properties
echo "signing.secretKeyRingFile=/tmp/secring.gpg" >> ~/.gradle/gradle.properties
echo -n "$SECRET_EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS" | base64 -d > /tmp/secring.gpg
GRADLE_ARGS=""
# Update the version name in build.gradle in case of maven publish
VERSION="${{ inputs.version }}"
if [ ! -z "$VERSION" ]; then
GRADLE_ARGS+=" -DexecuTorchVersion=${VERSION}"
fi
FLAVOR="${{ inputs.flavor }}"
if [ -z "$FLAVOR" ]; then
FLAVOR="xnnpack"
fi
GRADLE_ARGS+=" -Dflavor=${FLAVOR}"
if [[ "$FLAVOR" == "vulkan" || "$FLAVOR" == "all" || -z "$FLAVOR" ]]; then
curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz
tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz -C /tmp
export PATH="/tmp/1.4.321.1/x86_64/bin:$PATH"
export EXECUTORCH_BUILD_VULKAN=ON
fi
if [[ "$FLAVOR" == "xnnpack-no-sme2" ]]; then
export XNNPACK_ENABLE_ARM_SME2=OFF
fi
if [[ "$FLAVOR" == "qnn" || "$FLAVOR" == "all" ]]; then
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
# build_android_library.sh builds the QNN runtime included in the AAR;
# the host-only PyQnnManagerAdaptor is not part of this artifact.
export EXECUTORCH_BUILD_QNN=ON
source backends/qualcomm/scripts/qnn_config.sh
export QNN_SDK_ROOT="/tmp/qnn/${QNN_VERSION}"
export ANDROID_ABIS=arm64-v8a
GRADLE_ARGS+=" -DqnnVersion=2.50.0"
fi
# Build AAR Package
mkdir aar-out
export BUILD_AAR_DIR=aar-out
bash scripts/build_android_library.sh
mkdir -p "${ARTIFACTS_DIR_NAME}"
cp aar-out/executorch.aar "${ARTIFACTS_DIR_NAME}/executorch-${FLAVOR}.aar"
shasum -a 256 "${ARTIFACTS_DIR_NAME}/executorch-${FLAVOR}.aar"
# Upload a deployment to Maven Central. A release owner reviews and
# publishes it manually in the Central Portal.
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
(cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew --no-daemon --console=plain ${GRADLE_ARGS} :executorch_android:publishToMavenCentral)
{
echo "### Maven Central deployment uploaded"
echo
echo "Review and publish the deployment in the [Central Portal](https://central.sonatype.com/publishing/deployments)."
} >> "$GITHUB_STEP_SUMMARY"
fi
upload-release-aar:
name: upload-release-aar
needs: [check-if-aar-exists, build-aar]
if: ${{ needs.check-if-aar-exists.outputs.aar-exists != 'true' }}
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
id-token: write
contents: read
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-android
aws-region: us-east-1
- name: Upload AAR RC to AWS S3
shell: bash
run: |
VERSION="${{ inputs.version }}"
FLAVOR="${{ inputs.flavor }}"
if [ -z "$VERSION" ]; then
VERSION="snapshot-$(date +"%Y%m%d")"
fi
if [ -z "$FLAVOR" ]; then
FLAVOR="xnnpack"
fi
wget https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/executorch-${FLAVOR}.aar
mv executorch-${FLAVOR}.aar executorch.aar
shasum -a 256 executorch.aar > executorch.aar.sha256sums
pip install awscli==1.32.18
AWS_CMD="aws s3 cp"
${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar --acl public-read
${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar.sha256sums --acl public-read