Skip to content

Commit 7b7610a

Browse files
authored
Add a new workflow for building the mobile/library/python whl and uploading to pypi (#44193)
Create a new workflow that runs on manual dispatch that builds and repairs the mobile/library/python whl and uploads to pypi Some things that still need work: The workflow currently only runs on manual dispatch. We could change it to run when changes are made to the //library/python:envoy_mobile_wheel target, but the upload to pypi will fail unless the version is bumped in the BUILD configuration ~~The workflow is currently still configured for test PyPi. We need to set up an account and credentials for an official PyPi repo and add them to the repository as a secret~~ --------- Signed-off-by: Jonathan Wu <jtwu@google.com> Signed-off-by: Jonathan Wu <jonathanwu12@gmail.com>
1 parent 3fd93ea commit 7b7610a

2 files changed

Lines changed: 105 additions & 9 deletions

File tree

.github/workflows/_load_env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ jobs:
110110
needs: request
111111
if: ${{ inputs.cache-docker }}
112112
with:
113-
request: ${{ toJSON(needs.request.outputs) }}
113+
caches: ${{ needs.request.outputs.caches }}
114114
image-tag: ${{ fromJSON(needs.request.outputs.build-image).default }}

.github/workflows/mobile-release.yml

Lines changed: 104 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ permissions:
55

66
on:
77
workflow_dispatch:
8+
inputs:
9+
job_to_run:
10+
description: 'Select the job to run'
11+
required: true
12+
default: 'all'
13+
type: choice
14+
options:
15+
- all
16+
- android
17+
- python
818
schedule:
919
# Mondays at 1pm UTC (8am EST)
1020
- cron: "0 13 * * 1"
@@ -18,16 +28,18 @@ jobs:
1828
contents: read
1929
uses: ./.github/workflows/_load_env.yml
2030

21-
release:
31+
android-release:
2232
permissions:
33+
actions: read
2334
contents: read
2435
packages: read
2536
if: >-
26-
${{
27-
github.repository == 'envoyproxy/envoy'
28-
&& (github.event.schedule
29-
|| !contains(github.actor, '[bot]'))
30-
}}
37+
github.repository == 'envoyproxy/envoy'
38+
&& (github.event.schedule
39+
|| !contains(github.actor, '[bot]'))
40+
&& (github.event.inputs.job_to_run == 'all'
41+
|| github.event.inputs.job_to_run == 'android'
42+
|| github.event_name == 'schedule')
3143
needs: env
3244
uses: ./.github/workflows/_mobile_container_ci.yml
3345
with:
@@ -76,8 +88,14 @@ jobs:
7688
//:android_dist
7789
output: envoy
7890

79-
deploy:
80-
needs: release
91+
android-deploy:
92+
needs: android-release
93+
if: >-
94+
always()
95+
&& (github.event.inputs.job_to_run == 'all'
96+
|| github.event.inputs.job_to_run == 'android'
97+
|| github.event_name == 'schedule')
98+
&& (needs.android-release.result == 'success')
8199
permissions:
82100
contents: read
83101
packages: read
@@ -141,3 +159,81 @@ jobs:
141159
${{ matrix.output }}-pom.xml.asc \
142160
${{ matrix.output }}-sources.jar.asc \
143161
${{ matrix.output }}-javadoc.jar.asc
162+
163+
python-release:
164+
permissions:
165+
actions: read
166+
contents: read
167+
packages: read
168+
if: >-
169+
github.repository == 'envoyproxy/envoy'
170+
&& (github.event_name == 'workflow_dispatch')
171+
&& (github.event.inputs.job_to_run == 'all'
172+
|| github.event.inputs.job_to_run == 'python')
173+
needs: env
174+
name: Build and Publish Python Wheel
175+
uses: ./.github/workflows/_mobile_container_ci.yml
176+
with:
177+
args: ${{ matrix.args }}
178+
container: ${{ fromJSON(needs.env.outputs.build-image).default }}
179+
container-output: |
180+
"bazel-bin/library/python/": build/
181+
request: ${{ needs.env.outputs.request }}
182+
steps-post: |
183+
- name: Repair wheel
184+
run: |
185+
mkdir -p /tmp/dist
186+
WHEEL_PATH=$(find /tmp/container-output/build -name "*.whl" | head -n 1)
187+
188+
if [[ -z "$WHEEL_PATH" ]]; then
189+
echo "Error: No wheel file found in /tmp/container-output/build"
190+
ls -R /tmp/container-output/
191+
exit 1
192+
fi
193+
python3 -m venv envoy_wheel
194+
source envoy_wheel/bin/activate
195+
pip install patchelf auditwheel
196+
197+
auditwheel repair "$WHEEL_PATH" --wheel-dir /tmp/dist
198+
shell: bash
199+
target: ${{ matrix.target }}
200+
upload-name: python-wheel
201+
upload-path: /tmp/dist/*.whl
202+
strategy:
203+
fail-fast: false
204+
matrix:
205+
include:
206+
- target: envoy_mobile_wheel
207+
args: >-
208+
build
209+
--config=ci
210+
--config=mobile-rbe
211+
--config=mobile-release
212+
-c opt --strip=always
213+
//library/python:envoy_mobile_wheel
214+
--//library/python:python_platform="manylinux2014_x86_64"
215+
216+
python-publish:
217+
needs: python-release
218+
if: >-
219+
always()
220+
&& (github.event.inputs.job_to_run == 'all'
221+
|| github.event.inputs.job_to_run == 'python')
222+
&& (needs.python-release.result == 'success')
223+
permissions:
224+
contents: read
225+
id-token: write
226+
runs-on: ubuntu-latest
227+
timeout-minutes: 20
228+
strategy:
229+
fail-fast: false
230+
environment:
231+
name: pypi
232+
url: https://pypi.org/p/envoy-mobile
233+
steps:
234+
- uses: actions/download-artifact@v4
235+
with:
236+
name: python-wheel
237+
path: dist/
238+
- name: Publish to PyPi
239+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)