From 1e0799c38c35581fe03c50d539f0f46737cf4a0e Mon Sep 17 00:00:00 2001 From: Peter Baumgartner Date: Mon, 11 Dec 2023 16:23:29 -0700 Subject: [PATCH] Only build sdist once --- .github/workflows/build.yml | 58 ++++++++++++++++++++++++++++++------- Makefile | 6 +++- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fdb916e..95fa25a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,42 @@ name: Build on: [push, pull_request] jobs: + build_sdist: + name: Build sdist + runs-on: ubuntu-latest + outputs: + sdist_name: ${{ steps.build_sdist.outputs.sdist_name }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Debug patch + run: patch -d uwsgi -p1 < uwsgi-version-debug.txt + + - name: Patch packaging + run: ./patch-uwsgi-packaging.sh uwsgi + + - name: Build sdist + id: build_sdist + run: | + git submodule update --init + make sdist + echo "sdist_name=pyuwsgi-$(make print-version)" >> $GITHUB_OUTPUT + + - uses: actions/upload-artifact@v3 + with: + name: dist + path: dist + + - uses: actions/upload-artifact@v3 + with: + name: pre_build.sh + path: pre_build.sh + build_wheels: name: Build wheels for ${{ matrix.os }} + needs: [build_sdist] runs-on: ${{ matrix.os }} strategy: matrix: @@ -13,12 +47,21 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 with: - submodules: true + name: dist + path: dist - - name: Debug patch - run: patch -d uwsgi -p1 < uwsgi-version-debug.txt + - uses: actions/download-artifact@v3 + with: + name: pre_build.sh + path: pre_build.sh + + - name: Unpack sdist + run: | + tar -xvzf "dist/${{ needs.build_sdist.outputs.sdist_name }}.tar.gz" + rm -rf dist - name: Set up QEMU if: runner.os == 'Linux' @@ -30,7 +73,7 @@ jobs: uses: pypa/cibuildwheel@v2.16.2 with: output-dir: dist - package-dir: ./uwsgi + package-dir: ./${{ needs.build_sdist.outputs.sdist_name }} env: CIBW_ARCHS_LINUX: auto aarch64 CIBW_ARCHS_MACOS: x86_64 @@ -42,14 +85,9 @@ jobs: CIBW_SKIP: cp36-* pp* CIBW_ENVIRONMENT: APPEND_VERSION=".post0" UWSGI_PROFILE=pyuwsginossl CIBW_TEST_COMMAND: pyuwsgi --help - CIBW_BEFORE_ALL: ./patch-uwsgi-packaging.sh uwsgi CIBW_BEFORE_BUILD_MACOS: IS_MACOS=1 ./pre_build.sh CIBW_BEFORE_BUILD_LINUX: ./pre_build.sh && (yum install -y zlib-devel || apk add zlib-dev) - - name: Create sdist - run: | - rm -rf uwsgi && git submodule update --init - pipx run build --sdist --outdir dist uwsgi - uses: actions/upload-artifact@v3 with: name: dist diff --git a/Makefile b/Makefile index 6f244bc..b89da44 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SHELL := bash # Figure out what version we're building UPSTREAM_VERSION := $(shell cd uwsgi; python setup.pyuwsgi.py --version) # super fragile way of extracting `APPEND_VERSION` from workflow 🤮 -APPEND_VERSION := $(shell yq e '.jobs.build_wheels.steps[3].env.CIBW_ENVIRONMENT' .github/workflows/build.yml | cut -d' ' -f1 | cut -d= -f2) +APPEND_VERSION := $(shell yq e '.jobs.build_wheels.steps[4].env.CIBW_ENVIRONMENT' .github/workflows/build.yml | cut -d' ' -f1 | cut -d= -f2) VERSION := $(UPSTREAM_VERSION)$(APPEND_VERSION) HASH := $(shell cd uwsgi; git rev-parse HEAD) @@ -33,6 +33,10 @@ dist/pyuwsgi-$(VERSION).tar.gz: build/pyuwsgi-$(VERSION) .PHONY: sdist sdist: dist/pyuwsgi-$(VERSION).tar.gz +.PHONY: print-version +print-version: + @echo $(VERSION) + .PHONY: update update: cd uwsgi; git pull