-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from vmware-labs/11-python-automation
#11 Add GH actions for build and publish of python
- Loading branch information
Showing
12 changed files
with
201 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Python | ||
on: | ||
push: | ||
# By specifying branches explicitly, we avoid this workflow from | ||
# running on tag push. We have a dedicated workflow to be ran when | ||
# a tag is pushed. | ||
branches: | ||
- "*" | ||
pull_request: | ||
jobs: | ||
build-python: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- version: 3.11.1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Build Python | ||
run: make python/v${{ matrix.version }} | ||
- name: Rename artifacts | ||
shell: bash | ||
run: | | ||
sudo mv python/build-output/python/v${{ matrix.version }}/bin/python{,-${{ matrix.version }}}.wasm | ||
- name: Upload python-aio-${{ matrix.version }}.zip artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-aio-${{ matrix.version }}.zip | ||
path: | | ||
python/build-output/python/v${{ matrix.version }}/bin/python-${{ matrix.version }}.wasm | ||
python/build-output/python/v${{ matrix.version }}/usr | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Note that for this workflow to be triggered, the tag needs to be | ||
# created of the form `python/<version>+<buildinfo>`, where <buildinfo> | ||
# by convention is YYYYMMDD-<short-sha> (short SHA can be calculated | ||
# with `git rev-parse --short HEAD`). An example of a tag following | ||
# the convention that triggers automation would be | ||
# `python/3.11.1+20221123-8dfe8b9`. | ||
name: Release Python | ||
on: | ||
push: | ||
tags: | ||
- python/* | ||
jobs: | ||
release-python: | ||
strategy: | ||
matrix: | ||
include: | ||
- version: 3.11.1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version)) | ||
uses: actions/checkout@v3 | ||
- name: Build Python | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version)) | ||
run: make python/v${{ matrix.version }} | ||
- name: Rename release artifacts | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version)) | ||
shell: bash | ||
run: | | ||
sudo mv python/build-output/python/v${{ matrix.version }}/bin/python{,-${{ matrix.version }}}.wasm | ||
- name: Bundle Python with standard libraries | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version)) | ||
run: | | ||
pushd python/build-output/python/v${{ matrix.version }} | ||
sudo zip -qq -r python-aio-${{ matrix.version }}.zip bin/python-${{ matrix.version }}.wasm usr | ||
popd | ||
- name: Create release | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version)) | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create --generate-notes ${{ github.ref_name }} || true | ||
- name: Append Python release assets | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: ${{ startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version))}} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload ${{ github.ref_name }} \ | ||
python/build-output/python/v${{ matrix.version }}/python-aio-${{ matrix.version }}.zip | ||
- name: Generate release assets digests | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: ${{ startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version))}} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
for asset in python/build-output/python/v${{ matrix.version }}/python-aio-${{ matrix.version }}.zip; do | ||
sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null | ||
done | ||
- name: Append release assets digests | ||
# Only run for the Python version specified in the git tag. | ||
# | ||
# This if could be moved to the parent `job` section when it's | ||
# supported by GitHub (https://github.com/community/community/discussions/37883) | ||
if: ${{ startsWith(github.event.ref, format('refs/tags/python/{0}+', matrix.version))}} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload ${{ github.ref_name }} \ | ||
python/build-output/python/v${{ matrix.version }}/python-aio-${{ matrix.version }}.zip.sha256sum | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build-output | ||
build-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ARG WASI_SDK_VERSION=16 | ||
FROM ghcr.io/vmware-labs/wasi-builder:${WASI_SDK_VERSION} | ||
|
||
# If more capabilities are required from the build-erpython, consult this | ||
# github workflow configuration for a list of possible dependencies - | ||
# https://github.com/python/cpython/blob/main/.github/workflows/posix-deps-apt.sh | ||
RUN DEBIAN_FRONTEND=noninteractive apt install -y \ | ||
tcl \ | ||
uuid-dev \ | ||
zlib1g-dev | ||
|
||
ADD . /wlr/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
WASI_SDK_VERSION ?= 16 | ||
# NOTE - the default python build is failing with wasi-sdk-19 | ||
|
||
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
include ../Makefile.builders | ||
|
||
.PHONY: python-builder | ||
python-builder: wasi-builder-16 | ||
docker build -f ${ROOT_DIR}/Dockerfile --build-arg WASI_SDK_VERSION=$(WASI_SDK_VERSION) -t ghcr.io/vmware-labs/python-builder:wasi-$(WASI_SDK_VERSION) ${ROOT_DIR} | ||
|
||
.PHONY: v* | ||
v*: python-builder | ||
mkdir -p build-output build-staging | ||
docker run --rm -e WASMLABS_RUNTIME -v ${ROOT_DIR}/build-output:/wlr/build-output -v ${ROOT_DIR}/build-staging:/wlr/build-staging ghcr.io/vmware-labs/python-builder:wasi-${WASI_SDK_VERSION} ./wl-make.sh python/$@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build-output build-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters