Files
Peya/.gitea/workflows/build.yml
2026-03-19 17:15:38 +01:00

213 lines
7.8 KiB
YAML

name: build
on:
push:
paths-ignore:
- "docs/**"
- "**/README.md"
pull_request:
paths-ignore:
- "docs/**"
- "**/README.md"
jobs:
build-cross:
name: ${{ matrix.toolchain.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
# external/ cache is shared across all hosts, so start with the most
# commonly used release targets before the slower specialty targets.
- name: x86_64 Linux
host: x86_64-linux-gnu
packages: gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev
package_artifact: true
- name: Win64
host: x86_64-w64-mingw32
packages: cmake python3 g++-mingw-w64-x86-64
package_artifact: true
- name: ARM v8
host: aarch64-linux-gnu
packages: python3 gperf g++-aarch64-linux-gnu
package_artifact: true
- name: i686 Linux
host: i686-pc-linux-gnu
packages: gperf cmake g++-multilib python3-zmq
package_artifact: false
- name: i686 Win
host: i686-w64-mingw32
packages: python3 g++-mingw-w64-i686
package_artifact: false
- name: ARM v7
host: arm-linux-gnueabihf
packages: python3 gperf g++-arm-linux-gnueabihf
package_artifact: false
- name: RISCV 64bit
host: riscv64-linux-gnu
packages: python3 gperf g++-riscv64-linux-gnu
package_artifact: false
- name: Cross-Mac aarch64
host: aarch64-apple-darwin
packages: cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools-git
package_artifact: true
- name: Cross-Mac x86_64
host: x86_64-apple-darwin
packages: cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools-git
package_artifact: false
- name: x86_64 Freebsd
host: x86_64-unknown-freebsd
packages: gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev
package_artifact: false
steps:
- name: Checkout
uses: https://github.com/actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true
submodules: false
- name: Prepare cache keys
run: |
git submodule status --cached --recursive > .ci-submodules.lock
DEPENDS_KEY="$(cat contrib/depends/Makefile contrib/depends/funcs.mk contrib/depends/hosts/*.mk contrib/depends/packages/*.mk contrib/depends/toolchain.cmake.in | sha256sum | cut -d' ' -f1)"
echo "EXTERNAL_CACHE_KEY=v2-$(sha256sum .ci-submodules.lock | cut -d' ' -f1)" >> "$GITHUB_ENV"
echo "DEPENDS_CACHE_KEY=${DEPENDS_KEY}" >> "$GITHUB_ENV"
- name: Restore external cache
run: |
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
EXTERNAL_ARCHIVE="${CACHE_ROOT}/external-${EXTERNAL_CACHE_KEY}.tar.zst"
if [ -f "${EXTERNAL_ARCHIVE}" ]; then
echo "Restoring external cache from ${EXTERNAL_ARCHIVE}"
rm -rf external .git/modules/external
mkdir -p external .git/modules
tar --zstd -xf "${EXTERNAL_ARCHIVE}"
if [ -d ".git/modules/external" ]; then
echo "EXTERNAL_CACHE_HIT=true" >> "$GITHUB_ENV"
else
echo "External cache is missing .git/modules/external, ignoring it"
rm -rf external .git/modules/external
echo "EXTERNAL_CACHE_HIT=false" >> "$GITHUB_ENV"
fi
else
echo "No external cache found"
echo "EXTERNAL_CACHE_HIT=false" >> "$GITHUB_ENV"
fi
- name: Sync submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive --depth 1 --jobs "$(nproc)"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
automake \
autotools-dev \
build-essential \
ca-certificates \
ccache \
clang \
cmake \
curl \
git \
libssl-dev \
libtool \
pkg-config \
zip \
${{ matrix.toolchain.packages }}
- name: Restore depends cache
run: |
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
DEPENDS_ARCHIVE="${CACHE_ROOT}/depends-${{ matrix.toolchain.host }}-${DEPENDS_CACHE_KEY}.tar.zst"
if [ -f "${DEPENDS_ARCHIVE}" ]; then
echo "Restoring depends cache from ${DEPENDS_ARCHIVE}"
tar --zstd -xf "${DEPENDS_ARCHIVE}"
echo "DEPENDS_CACHE_HIT=true" >> "$GITHUB_ENV"
else
echo "No depends cache found"
echo "DEPENDS_CACHE_HIT=false" >> "$GITHUB_ENV"
fi
- name: Prepare MinGW alternatives
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'i686-w64-mingw32' }}
run: |
sudo update-alternatives --set ${{ matrix.toolchain.host }}-g++ "$(which ${{ matrix.toolchain.host }}-g++-posix)"
sudo update-alternatives --set ${{ matrix.toolchain.host }}-gcc "$(which ${{ matrix.toolchain.host }}-gcc-posix)"
- name: Build
run: |
make depends target=${{ matrix.toolchain.host }} -j"$(nproc)"
- name: Save external cache
if: success()
run: |
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
EXTERNAL_ARCHIVE="${CACHE_ROOT}/external-${EXTERNAL_CACHE_KEY}.tar.zst"
mkdir -p "${CACHE_ROOT}"
if [ ! -f "${EXTERNAL_ARCHIVE}" ]; then
tar --zstd -cf "${EXTERNAL_ARCHIVE}" external .git/modules/external
fi
- name: Save depends cache
if: success()
run: |
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
DEPENDS_ARCHIVE="${CACHE_ROOT}/depends-${{ matrix.toolchain.host }}-${DEPENDS_CACHE_KEY}.tar.zst"
mkdir -p "${CACHE_ROOT}"
if [ ! -f "${DEPENDS_ARCHIVE}" ]; then
tar --zstd -cf "${DEPENDS_ARCHIVE}" \
contrib/depends/built \
contrib/depends/sources \
contrib/depends/work/build \
contrib/depends/${{ matrix.toolchain.host }}
fi
- name: Package release archive
if: ${{ matrix.toolchain.package_artifact }}
run: |
REF_NAME="${GITHUB_REF_NAME:-$(git rev-parse --short=9 HEAD)}"
if [ "${{ matrix.toolchain.host }}" = "x86_64-w64-mingw32" ]; then
ARCHIVE="/tmp/peya-${REF_NAME}-${{ matrix.toolchain.host }}.zip"
else
ARCHIVE="/tmp/peya-${REF_NAME}-${{ matrix.toolchain.host }}.tar.gz"
fi
cd "build/${{ matrix.toolchain.host }}/release/bin"
FILES=()
for pattern in peyad* peya-wallet-cli* peya-wallet-rpc* peya-gen-multisig*; do
for file in $pattern; do
if [ -e "$file" ]; then
FILES+=("$file")
fi
done
done
if [ "${#FILES[@]}" -eq 0 ]; then
echo "No release binaries found in $(pwd)"
exit 1
fi
if [ "${ARCHIVE##*.}" = "zip" ]; then
zip -ur "${ARCHIVE}" "${FILES[@]}"
else
tar -czf "${ARCHIVE}" "${FILES[@]}"
fi
ls -lh "${ARCHIVE}"
- name: Upload build artifact
if: ${{ matrix.toolchain.package_artifact }}
uses: https://github.com/actions/upload-artifact@v3
with:
name: peya-${{ matrix.toolchain.host }}
path: |
/tmp/peya-*-${{ matrix.toolchain.host }}.zip
/tmp/peya-*-${{ matrix.toolchain.host }}.tar.gz
if-no-files-found: error