build cross-compiled and emulated targets for releases only

This commit is contained in:
acetone
2026-10-03 02:51:57 -04:00
parent 296481f213
commit 70c3f0611a
5 changed files with 49 additions and 37 deletions
+27 -8
View File
@@ -20,8 +20,17 @@ on:
jobs:
build:
name: Build universal binary
runs-on: macos-15
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# the universal binary needs cross-compilation, so it is built for releases only
include: ${{ fromJSON(github.ref_type == 'tag' && '[{"name":"universal","runner":"macos-15","archs":"arm64 x86_64"}]' || '[{"name":"arm64","runner":"macos-15","archs":"arm64"},{"name":"x86_64","runner":"macos-15-intel","archs":"x86_64"}]') }}
env:
ARCHS: ${{ matrix.archs }}
steps:
- name: Checkout
@@ -32,24 +41,34 @@ jobs:
- name: Check binary
run: |
lipo -archs i2pd | grep -w arm64
lipo -archs i2pd | grep -w x86_64
for arch in $ARCHS; do lipo -archs i2pd | grep -w $arch; done
otool -L i2pd
test -z "$(otool -L i2pd | grep -E '^[[:space:]]' | grep -vE '^[[:space:]]+(/usr/lib/|/System/Library/)')"
vtool -show-build i2pd | grep -E 'architecture|minos|sdk'
test "$(vtool -show-build i2pd | grep -c 'minos 12\.0$')" = 2
set -- $ARCHS
test "$(vtool -show-build i2pd | grep -c 'minos 12\.0$')" = $#
./i2pd --version
./i2pd --version | grep -E '^OpenSSL (3\.([5-9]|[1-9][0-9])|[4-9])\.'
./i2pd --version | grep -E '^Boost version 1\.(8[1-9]|9[0-9])\.'
- name: Run
run: |
mkdir datadir
./i2pd --datadir=datadir --log=file --logfile=datadir/i2pd.log --loglevel=info &
sleep 15
kill -0 $!
grep 'Daemon: Starting NetDB' datadir/i2pd.log
kill -9 $!
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: i2pd-macos
name: i2pd-macos-${{ matrix.name }}
path: i2pd
test:
name: Run on ${{ matrix.target-name }}
name: Run universal binary on ${{ matrix.target-name }}
if: github.ref_type == 'tag'
needs: build
runs-on: ${{ matrix.target }}
@@ -66,7 +85,7 @@ jobs:
- name: Download binary
uses: actions/download-artifact@v4
with:
name: i2pd-macos
name: i2pd-macos-universal
- name: Run
run: |
+8 -22
View File
@@ -22,41 +22,27 @@ on:
jobs:
build:
name: musl ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-latest
platform: linux/amd64
- arch: aarch64
runner: ubuntu-24.04-arm
platform: linux/arm64
- arch: armhf
runner: ubuntu-latest
platform: linux/arm/v6
qemu: true
- arch: x86
runner: ubuntu-latest
platform: linux/386
setarch: linux32
- arch: s390x
runner: ubuntu-latest
platform: linux/s390x
qemu: true
# armhf and s390x run under QEMU, so they are built for releases only
arch: ${{ fromJSON(github.ref_type == 'tag' && '["x86_64", "aarch64", "x86", "armhf", "s390x"]' || '["x86_64", "aarch64", "x86"]') }}
env:
PLATFORM: ${{ fromJSON('{"x86_64":"linux/amd64","aarch64":"linux/arm64","x86":"linux/386","armhf":"linux/arm/v6","s390x":"linux/s390x"}')[matrix.arch] }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
if: ${{ matrix.qemu }}
if: ${{ matrix.arch == 'armhf' || matrix.arch == 's390x' }}
uses: docker/setup-qemu-action@v3
- name: Build in Alpine
run: docker run --rm --platform ${{ matrix.platform }} -v "$PWD":/src -w /src alpine:3.22 ${{ matrix.setarch }} sh contrib/static/build-musl.sh
run: docker run --rm --platform $PLATFORM -v "$PWD":/src -w /src alpine:3.22 ${{ matrix.arch == 'x86' && 'linux32' || '' }} sh contrib/static/build-musl.sh
- name: Check binary
run: |
+2 -2
View File
@@ -80,8 +80,8 @@ jobs:
zip -qr9 release/i2pd_${TAG}_${build#*:}_mingw.zip i2pd.exe README.txt \
contrib/i2pd.conf contrib/tunnels.conf contrib/certificates contrib/tunnels.d contrib/webconsole
done
chmod +x artifacts/i2pd-macos/i2pd
tar -czf release/i2pd_${TAG}_osx.tar.gz -C artifacts/i2pd-macos i2pd
chmod +x artifacts/i2pd-macos-universal/i2pd
tar -czf release/i2pd_${TAG}_osx.tar.gz -C artifacts/i2pd-macos-universal i2pd
for dir in artifacts/i2pd-freebsd-*; do
chmod +x $dir/i2pd
rel=${dir##*-}
+9 -4
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# Universal i2pd for macOS with OpenSSL, Boost and miniupnpc built from source and linked statically
# i2pd for macOS, universal unless ARCHS is set, with OpenSSL, Boost and miniupnpc built from source and linked statically
set -e
OPENSSL_VERSION=3.5.8
@@ -7,7 +7,7 @@ BOOST_VERSION=1.92.0
BOOST_SHA256=ea7b982002cc9dfbe59b0b217b206f470dc75f3de0bb2973d844118934d82411
MINIUPNPC_VERSION=2.3.3
MINIUPNPC_SHA256=d52a0afa614ad6c088cc9ddff1ae7d29c8c595ac5fdd321170a05f41e634bd1a
ARCHS="arm64 x86_64"
ARCHS=${ARCHS:-"arm64 x86_64"}
JOBS=4
export MACOSX_DEPLOYMENT_TARGET=12.0
@@ -63,5 +63,10 @@ for ARCH in $ARCHS; do
done
cd "$SRC"
lipo -create -output i2pd i2pd-arm64 i2pd-x86_64
rm i2pd-arm64 i2pd-x86_64
set -- $ARCHS
if [ $# -eq 1 ]; then
mv i2pd-$1 i2pd
else
lipo -create -output i2pd $(printf 'i2pd-%s ' "$@")
for ARCH in "$@"; do rm i2pd-$ARCH; done
fi
+3 -1
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# Packages static binaries from BIN/i2pd-static-<arch>/i2pd, run inside debian (deb) or rocky/fedora (rpm)
# Packages the static binaries present in BIN/i2pd-static-<arch>/i2pd, run inside debian (deb) or rocky/fedora (rpm)
# usage: package.sh deb|rpm BIN OUT, with VERSION (deb), RPM_VERSION and RPM_RELEASE in the environment
set -e
@@ -30,6 +30,7 @@ if [ "$FORMAT" = deb ]; then
"$VERSION" "$(sed -n 's/^Maintainer: //p' $PKG/debian/control)" "$(date -R)" > $PKG/debian/changelog
for a in $ARCHS; do
alpine=${a%%:*}; rest=${a#*:}; deb=${rest%%:*}
[ -f "$BIN/i2pd-static-$alpine/i2pd" ] || continue
install -m 755 "$BIN/i2pd-static-$alpine/i2pd" $PKG/bin/i2pd-$deb
(cd $PKG && dpkg-buildpackage -b -us -uc -a$deb -d)
mv $WORK/i2pd_$VERSION-1_$deb.deb "$OUT/i2pd_${VERSION}_linux-all_$deb.deb"
@@ -40,6 +41,7 @@ elif [ "$FORMAT" = rpm ]; then
mkdir -p $WORK/sources
for a in $ARCHS; do
alpine=${a%%:*}; rpm=${a##*:}
[ -f "$BIN/i2pd-static-$alpine/i2pd" ] || continue
install -m 755 "$BIN/i2pd-static-$alpine/i2pd" $WORK/sources/i2pd-$rpm
rpmbuild -bb --target $rpm -D "ver $RPM_VERSION" -D "rel $RPM_RELEASE" -D "srcdir $SRC" \
-D "_topdir $WORK/rpmbuild" -D "_sourcedir $WORK/sources" -D "_rpmdir $WORK/rpms" "$SRC/contrib/static/i2pd.spec"