Skip to content

Commit

Permalink
ci: build deltachat-rpc-server with nix
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Feb 17, 2024
1 parent d49f26b commit f785538
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 154 deletions.
106 changes: 63 additions & 43 deletions .github/workflows/deltachat-rpc-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,59 @@ jobs:
# Build a version statically linked against musl libc
# to avoid problems with glibc version incompatibility.
build_linux:
name: Cross-compile deltachat-rpc-server for x86_64, i686, aarch64 and armv7 Linux
runs-on: ubuntu-22.04
name: Build deltachat-rpc-server for Linux
strategy:
fail-fast: false
matrix:
arch: [aarch64, armv7l, armv6l, i686, x86_64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false

- name: Install ziglang
run: pip install wheel ziglang==0.11.0
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build deltachat-rpc-server binaries
run: sh scripts/zig-rpc-server.sh
run: nix build .#deltachat-rpc-server-${{ matrix.arch }}-linux

- name: Upload dist directory with Linux binaries
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: linux
path: dist/
name: deltachat-rpc-server-${{ matrix.arch }}-linux
path: result/bin/deltachat-rpc-server
if-no-files-found: error

build_windows:
name: Build deltachat-rpc-server for Windows
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
artifact: win32.exe
path: deltachat-rpc-server.exe
target: i686-pc-windows-msvc

- os: windows-latest
artifact: win64.exe
path: deltachat-rpc-server.exe
target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.os }}
arch: [win32, win64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Setup rust target
run: rustup target add ${{ matrix.target }}

- name: Build
run: cargo build --release --package deltachat-rpc-server --target ${{ matrix.target }} --features vendored
- name: Build deltachat-rpc-server binaries
run: nix build .#deltachat-rpc-server-${{ matrix.arch }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: deltachat-rpc-server-${{ matrix.artifact }}
path: target/${{ matrix.target}}/release/${{ matrix.path }}
name: deltachat-rpc-server-${{ matrix.arch }}
path: result/bin/deltachat-rpc-server.exe
if-no-files-found: error

build_macos:
name: Build deltachat-rpc-server for macOS
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
- arch: aarch64
arch: [x86_64, aarch64]

runs-on: macos-latest
steps:
Expand All @@ -106,7 +96,7 @@ jobs:

publish:
name: Build wheels and upload binaries to the release
needs: ["build_linux", "build_windows", "build_macos"]
needs: ["build_linux", "build_macos"]
permissions:
contents: write
runs-on: "ubuntu-latest"
Expand All @@ -115,23 +105,47 @@ jobs:
with:
show-progress: false

- name: Download Linux binaries
- name: Download Linux aarch64 binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-aarch64-linux
path: deltachat-rpc-server-aarch64-linux.d

- name: Download Linux armv7l binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-armv7l-linux
path: deltachat-rpc-server-armv7l-linux.d

- name: Download Linux armv6l binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-armv6l-linux
path: deltachat-rpc-server-armv6l-linux.d

- name: Download Linux i686 binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-i686-linux
path: deltachat-rpc-server-i686-linux.d

- name: Download Linux x86_64 binary
uses: actions/download-artifact@v4
with:
name: linux
path: dist/
name: deltachat-rpc-server-x86_64-linux
path: deltachat-rpc-server-x86_64-linux.d

- name: Download win32 binary
- name: Download Win32 binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-win32.exe
path: deltachat-rpc-server-win32.exe.d
name: deltachat-rpc-server-win32
path: deltachat-rpc-server-win32.d

- name: Download win64 binary
- name: Download Win64 binary
uses: actions/download-artifact@v4
with:
name: deltachat-rpc-server-win64.exe
path: deltachat-rpc-server-win64.exe.d
name: deltachat-rpc-server-win64
path: deltachat-rpc-server-win64.d

- name: Download macOS binary for x86_64
uses: actions/download-artifact@v4
Expand All @@ -147,8 +161,14 @@ jobs:

- name: Flatten dist/ directory
run: |
mv deltachat-rpc-server-win32.exe.d/deltachat-rpc-server.exe dist/deltachat-rpc-server-win32.exe
mv deltachat-rpc-server-win64.exe.d/deltachat-rpc-server.exe dist/deltachat-rpc-server-win64.exe
mkdir -p dist
mv deltachat-rpc-server-aarch64-linux.d/deltachat-rpc-server dist/deltachat-rpc-server-aarch64-linux
mv deltachat-rpc-server-armv7l-linux.d/deltachat-rpc-server dist/deltachat-rpc-server-armv7l-linux
mv deltachat-rpc-server-armv6l-linux.d/deltachat-rpc-server dist/deltachat-rpc-server-armv6l-linux
mv deltachat-rpc-server-i686-linux.d/deltachat-rpc-server dist/deltachat-rpc-server-i686-linux
mv deltachat-rpc-server-x86_64-linux.d/deltachat-rpc-server dist/deltachat-rpc-server-x86_64-linux
mv deltachat-rpc-server-win32.d/deltachat-rpc-server.exe dist/deltachat-rpc-server-win32.exe
mv deltachat-rpc-server-win64.d/deltachat-rpc-server.exe dist/deltachat-rpc-server-win64.exe
mv deltachat-rpc-server-x86_64-macos.d/deltachat-rpc-server dist/deltachat-rpc-server-x86_64-macos
mv deltachat-rpc-server-aarch64-macos.d/deltachat-rpc-server dist/deltachat-rpc-server-aarch64-macos
Expand Down
2 changes: 0 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ and an own build machine.

- `run_all.sh` builds Python wheels

- `zig-rpc-server.sh` compiles binaries of `deltachat-rpc-server` using Zig toolchain statically linked against musl libc.

- `android-rpc-server.sh` compiles binaries of `deltachat-rpc-server` using Android NDK.

- `build-python-docs.sh` builds Python documentation into `dist/html/`.
Expand Down
8 changes: 6 additions & 2 deletions scripts/wheel-rpc-server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
"""Build Python wheels for deltachat-rpc-server.
Run scripts/zig-rpc-server.sh first."""
"""Build Python wheels for deltachat-rpc-server."""
from pathlib import Path
from wheel.wheelfile import WheelFile
import tomllib
Expand Down Expand Up @@ -160,6 +159,11 @@ def main():
"dist/deltachat-rpc-server-armv7-linux",
"py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.musllinux_1_1_armv7l",
)
build_wheel(
version,
"dist/deltachat-rpc-server-armv6-linux",
"py3-none-manylinux_2_17_armv6l.manylinux2014_armv6l.musllinux_1_1_armv6l",
)
build_wheel(
version,
"dist/deltachat-rpc-server-aarch64-linux",
Expand Down
57 changes: 0 additions & 57 deletions scripts/zig-cc

This file was deleted.

50 changes: 0 additions & 50 deletions scripts/zig-rpc-server.sh

This file was deleted.

0 comments on commit f785538

Please sign in to comment.