Skip to content

Commit

Permalink
Only build sdist once
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Dec 11, 2023
1 parent 7910d7f commit ce94624
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
59 changes: 49 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,65 @@ 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
path: pre_build.sh

build_wheels:
name: Build wheels for ${{ matrix.os }}
needs: [build_sdist]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
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
path: .

- name: Unpack sdist
run: |
tar -xvzf "dist/${{ needs.build_sdist.outputs.sdist_name }}.tar.gz"
rm -rf dist
chmod +x pre_build.sh
- name: Set up QEMU
if: runner.os == 'Linux'
Expand All @@ -30,7 +74,7 @@ jobs:
uses: pypa/[email protected]
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
Expand All @@ -42,14 +86,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
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit ce94624

Please sign in to comment.