2021-07-13 02:20:11 +03:00
|
|
|
# GitHub actions workflow which builds the release artifacts.
|
2021-07-12 21:03:14 +03:00
|
|
|
|
2021-07-13 02:20:11 +03:00
|
|
|
name: Build release artifacts
|
2021-07-12 21:03:14 +03:00
|
|
|
|
|
|
|
on:
|
2021-07-14 16:41:23 +03:00
|
|
|
# we build on PRs and develop to (hopefully) get early warning
|
2023-03-15 15:07:20 +03:00
|
|
|
# of things breaking (but only build one set of debs). PRs skip
|
2024-12-04 15:58:26 +03:00
|
|
|
# building wheels on macOS & ARM.
|
2021-07-14 16:41:23 +03:00
|
|
|
pull_request:
|
2021-07-12 21:03:14 +03:00
|
|
|
push:
|
2022-02-22 14:33:37 +03:00
|
|
|
branches: ["develop", "release-*"]
|
2021-07-12 21:03:14 +03:00
|
|
|
|
2021-07-14 16:41:23 +03:00
|
|
|
# we do the full build on tags.
|
2021-07-13 02:20:11 +03:00
|
|
|
tags: ["v*"]
|
2023-03-15 15:07:20 +03:00
|
|
|
merge_group:
|
2022-10-03 19:16:45 +03:00
|
|
|
workflow_dispatch:
|
2021-07-13 02:20:11 +03:00
|
|
|
|
2021-07-22 13:35:06 +03:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2022-09-06 21:01:37 +03:00
|
|
|
|
2021-07-12 21:03:14 +03:00
|
|
|
permissions:
|
2021-07-13 13:50:14 +03:00
|
|
|
contents: write
|
2021-07-12 21:03:14 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
get-distros:
|
2021-07-14 16:41:23 +03:00
|
|
|
name: "Calculate list of debian distros"
|
2021-07-12 21:03:14 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-25 18:39:54 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-12 12:59:10 +03:00
|
|
|
- uses: actions/setup-python@v5
|
2022-10-18 18:40:05 +03:00
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
2021-07-12 21:03:14 +03:00
|
|
|
- id: set-distros
|
|
|
|
run: |
|
2021-07-14 16:41:23 +03:00
|
|
|
# if we're running from a tag, get the full list of distros; otherwise just use debian:sid
|
2023-05-31 18:13:31 +03:00
|
|
|
# NOTE: inside the actual Dockerfile-dhvirtualenv, the image name is expanded into its full image path
|
2021-07-14 16:41:23 +03:00
|
|
|
dists='["debian:sid"]'
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2022-03-02 21:00:26 +03:00
|
|
|
dists=$(scripts-dev/build_debian_packages.py --show-dists-json)
|
2021-07-14 16:41:23 +03:00
|
|
|
fi
|
2022-10-18 15:45:34 +03:00
|
|
|
echo "distros=$dists" >> "$GITHUB_OUTPUT"
|
2021-07-12 21:03:14 +03:00
|
|
|
# map the step outputs to job outputs
|
|
|
|
outputs:
|
|
|
|
distros: ${{ steps.set-distros.outputs.distros }}
|
|
|
|
|
|
|
|
# now build the packages with a matrix build.
|
|
|
|
build-debs:
|
|
|
|
needs: get-distros
|
|
|
|
name: "Build .deb packages"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
distro: ${{ fromJson(needs.get-distros.outputs.distros) }}
|
|
|
|
|
|
|
|
steps:
|
2021-07-26 13:36:01 +03:00
|
|
|
- name: Checkout
|
2023-09-25 18:39:54 +03:00
|
|
|
uses: actions/checkout@v4
|
2021-07-12 21:03:14 +03:00
|
|
|
with:
|
|
|
|
path: src
|
2021-07-26 13:36:01 +03:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2023-09-25 13:34:16 +03:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-07-26 13:36:01 +03:00
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
|
|
|
- name: Set up docker layer caching
|
2024-01-22 13:35:05 +03:00
|
|
|
uses: actions/cache@v4
|
2021-07-26 13:36:01 +03:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
|
|
|
- name: Set up python
|
2023-12-12 12:59:10 +03:00
|
|
|
uses: actions/setup-python@v5
|
2022-10-18 18:40:05 +03:00
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
2021-07-26 13:36:01 +03:00
|
|
|
|
|
|
|
- name: Build the packages
|
|
|
|
# see https://github.com/docker/build-push-action/issues/252
|
|
|
|
# for the cache magic here
|
|
|
|
run: |
|
2022-03-02 21:00:26 +03:00
|
|
|
./src/scripts-dev/build_debian_packages.py \
|
2021-07-26 13:36:01 +03:00
|
|
|
--docker-build-arg=--cache-from=type=local,src=/tmp/.buildx-cache \
|
|
|
|
--docker-build-arg=--cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new \
|
|
|
|
--docker-build-arg=--progress=plain \
|
|
|
|
--docker-build-arg=--load \
|
|
|
|
"${{ matrix.distro }}"
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
2024-11-11 17:32:45 +03:00
|
|
|
- name: Artifact name
|
|
|
|
id: artifact-name
|
|
|
|
# We can't have colons in the upload name of the artifact, so we convert
|
|
|
|
# e.g. `debian:sid` to `sid`.
|
|
|
|
env:
|
|
|
|
DISTRO: ${{ matrix.distro }}
|
|
|
|
run: |
|
|
|
|
echo "ARTIFACT_NAME=${DISTRO#*:}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
2021-07-26 13:36:01 +03:00
|
|
|
- name: Upload debs as artifacts
|
2024-11-06 03:24:40 +03:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-07-12 21:03:14 +03:00
|
|
|
with:
|
2024-11-11 17:32:45 +03:00
|
|
|
name: debs-${{ steps.artifact-name.outputs.ARTIFACT_NAME }}
|
2021-07-12 21:03:14 +03:00
|
|
|
path: debs/*
|
2021-07-13 02:20:11 +03:00
|
|
|
|
2022-09-06 21:01:37 +03:00
|
|
|
build-wheels:
|
2022-10-18 20:12:21 +03:00
|
|
|
name: Build wheels on ${{ matrix.os }} for ${{ matrix.arch }}
|
2022-09-06 21:01:37 +03:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-12-04 15:58:26 +03:00
|
|
|
os: [ubuntu-22.04, macos-13]
|
2022-10-18 20:12:21 +03:00
|
|
|
arch: [x86_64, aarch64]
|
|
|
|
# is_pr is a flag used to exclude certain jobs from the matrix on PRs.
|
|
|
|
# It is not read by the rest of the workflow.
|
2022-09-06 21:01:37 +03:00
|
|
|
is_pr:
|
|
|
|
- ${{ startsWith(github.ref, 'refs/pull/') }}
|
|
|
|
|
|
|
|
exclude:
|
2024-12-04 15:58:26 +03:00
|
|
|
# Don't build macos wheels on PR CI.
|
|
|
|
- is_pr: true
|
|
|
|
os: "macos-13"
|
|
|
|
# Don't build aarch64 wheels on mac.
|
|
|
|
- os: "macos-13"
|
|
|
|
arch: aarch64
|
2022-10-18 20:12:21 +03:00
|
|
|
# Don't build aarch64 wheels on PR CI.
|
|
|
|
- is_pr: true
|
|
|
|
arch: aarch64
|
2022-09-06 21:01:37 +03:00
|
|
|
|
|
|
|
steps:
|
2023-09-25 18:39:54 +03:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-06 21:01:37 +03:00
|
|
|
|
2023-12-12 12:59:10 +03:00
|
|
|
- uses: actions/setup-python@v5
|
2022-10-04 16:59:30 +03:00
|
|
|
with:
|
|
|
|
# setup-python@v4 doesn't impose a default python version. Need to use 3.x
|
|
|
|
# here, because `python` on osx points to Python 2.7.
|
|
|
|
python-version: "3.x"
|
2022-09-06 21:01:37 +03:00
|
|
|
|
|
|
|
- name: Install cibuildwheel
|
2024-06-18 12:26:36 +03:00
|
|
|
run: python -m pip install cibuildwheel==2.19.1
|
2022-09-06 21:01:37 +03:00
|
|
|
|
2022-10-18 20:12:21 +03:00
|
|
|
- name: Set up QEMU to emulate aarch64
|
|
|
|
if: matrix.arch == 'aarch64'
|
2023-09-18 12:19:05 +03:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2022-10-18 20:12:21 +03:00
|
|
|
with:
|
|
|
|
platforms: arm64
|
|
|
|
|
|
|
|
- name: Build aarch64 wheels
|
|
|
|
if: matrix.arch == 'aarch64'
|
|
|
|
run: echo 'CIBW_ARCHS_LINUX=aarch64' >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Only build a single wheel on PR
|
2022-09-06 21:01:37 +03:00
|
|
|
if: startsWith(github.ref, 'refs/pull/')
|
2024-11-06 22:36:01 +03:00
|
|
|
run: echo "CIBW_BUILD="cp39-manylinux_${{ matrix.arch }}"" >> $GITHUB_ENV
|
2022-09-06 21:01:37 +03:00
|
|
|
|
|
|
|
- name: Build wheels
|
|
|
|
run: python -m cibuildwheel --output-dir wheelhouse
|
|
|
|
env:
|
|
|
|
# Skip testing for platforms which various libraries don't have wheels
|
|
|
|
# for, and so need extra build deps.
|
2023-02-08 02:55:22 +03:00
|
|
|
CIBW_TEST_SKIP: pp3*-* *i686* *musl*
|
2022-10-18 20:12:21 +03:00
|
|
|
# Fix Rust OOM errors on emulated aarch64: https://github.com/rust-lang/cargo/issues/10583
|
|
|
|
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
|
|
|
CIBW_ENVIRONMENT_PASS_LINUX: CARGO_NET_GIT_FETCH_WITH_CLI
|
2022-09-06 21:01:37 +03:00
|
|
|
|
2024-11-06 03:24:40 +03:00
|
|
|
- uses: actions/upload-artifact@v4
|
2022-09-06 21:01:37 +03:00
|
|
|
with:
|
2024-11-06 18:21:45 +03:00
|
|
|
name: Wheel-${{ matrix.os }}-${{ matrix.arch }}
|
2022-09-06 21:01:37 +03:00
|
|
|
path: ./wheelhouse/*.whl
|
|
|
|
|
2021-07-13 02:20:11 +03:00
|
|
|
build-sdist:
|
2022-09-06 21:01:37 +03:00
|
|
|
name: Build sdist
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: ${{ !startsWith(github.ref, 'refs/pull/') }}
|
|
|
|
|
|
|
|
steps:
|
2023-09-25 18:39:54 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-12 12:59:10 +03:00
|
|
|
- uses: actions/setup-python@v5
|
2022-09-06 21:01:37 +03:00
|
|
|
with:
|
|
|
|
python-version: '3.10'
|
|
|
|
|
|
|
|
- run: pip install build
|
|
|
|
|
|
|
|
- name: Build sdist
|
|
|
|
run: python -m build --sdist
|
|
|
|
|
2024-11-06 03:24:40 +03:00
|
|
|
- uses: actions/upload-artifact@v4
|
2022-09-06 21:01:37 +03:00
|
|
|
with:
|
|
|
|
name: Sdist
|
|
|
|
path: dist/*.tar.gz
|
|
|
|
|
2021-07-13 13:50:14 +03:00
|
|
|
|
|
|
|
# if it's a tag, create a release and attach the artifacts to it
|
|
|
|
attach-assets:
|
|
|
|
name: "Attach assets to release"
|
2021-07-14 16:41:23 +03:00
|
|
|
if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
|
2021-07-13 13:50:14 +03:00
|
|
|
needs:
|
|
|
|
- build-debs
|
2022-09-06 21:01:37 +03:00
|
|
|
- build-wheels
|
2021-07-13 13:50:14 +03:00
|
|
|
- build-sdist
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Download all workflow run artifacts
|
2024-11-06 03:24:40 +03:00
|
|
|
uses: actions/download-artifact@v4
|
2021-07-13 13:50:14 +03:00
|
|
|
- name: Build a tarball for the debs
|
2024-11-11 17:32:45 +03:00
|
|
|
# We need to merge all the debs uploads into one folder, then compress
|
|
|
|
# that.
|
|
|
|
run: |
|
|
|
|
mkdir debs
|
|
|
|
mv debs*/* debs/
|
|
|
|
tar -cvJf debs.tar.xz debs
|
2021-07-13 13:50:14 +03:00
|
|
|
- name: Attach to release
|
2024-12-02 13:54:14 +03:00
|
|
|
# Pinned to work around https://github.com/softprops/action-gh-release/issues/445
|
2024-12-04 15:53:51 +03:00
|
|
|
uses: softprops/action-gh-release@v0.1.15
|
2021-07-13 13:50:14 +03:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
files: |
|
2022-03-08 18:11:50 +03:00
|
|
|
Sdist/*
|
2024-11-11 17:32:45 +03:00
|
|
|
Wheel*/*
|
2021-07-13 13:50:14 +03:00
|
|
|
debs.tar.xz
|