-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cicd: revamp GH workflow for building artifacts
- Loading branch information
Showing
3 changed files
with
186 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
ARCH=${1} # arm, aarch64, i386, x86_64 | ||
ABI=${2} # gnu, gnueabihf | ||
DEBARCH=${3} # i386, amd64, armhf, arm64 | ||
BUILD_TYPE=${4} # slim, default, full | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
# Native sources | ||
cat > /etc/apt/sources.list << EOT_NATIVE | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse | ||
EOT_NATIVE | ||
|
||
# If building cross, cross sources | ||
if [ "${ARCH}" != "$(uname -m)" ]; then | ||
cat > /etc/apt/sources.list.d/cross.list << EOT_CROSS | ||
deb [arch=$DEBARCH] http://ports.ubuntu.com/ focal main restricted universe multiverse | ||
deb [arch=$DEBARCH] http://ports.ubuntu.com/ focal-updates main restricted universe multiverse | ||
deb [arch=$DEBARCH] http://ports.ubuntu.com/ focal-security main restricted universe multiverse | ||
EOT_CROSS | ||
else | ||
rm -f /etc/apt/sources.list.d/cross.list | ||
fi | ||
|
||
dpkg --add-architecture ${DEBARCH} | ||
apt-get update | ||
|
||
# Setup magic vars for foreign packages | ||
if [ "${ARCH}" != "$(uname -m)" ]; then | ||
CROSS=":${DEBARCH}" | ||
BUILD_PKGS="gcc-${ARCH}-linux-${ABI} libc6-${DEBARCH}-cross libc6-dev-${DEBARCH}-cross pkg-config" | ||
dpkg --add-architecture ${DEBARCH} | ||
else | ||
CROSS="" | ||
BUILD_PKGS="gcc libc6 libc6-dev pkg-config" | ||
fi | ||
|
||
# Always install all dependencies, even if we are building default or even slim | ||
BUILDDEP_SLIM="libasound2-dev${CROSS} libssl-dev${CROSS} libpulse-dev${CROSS} libdbus-1-dev${CROSS} libssl1.1${CROSS}" | ||
BUILDDEP_DEFAULT="libdbus-1-dev${CROSS} libdbus-1-3${CROSS} libsystemd0${CROSS} libgcrypt20${CROSS} liblzma5${CROSS} liblz4-1${CROSS} libgpg-error0${CROSS}" | ||
BUILDDEP_FULL="libpulse-dev${CROSS}" | ||
|
||
apt-get install -y \ | ||
${BUILD_PKGS} \ | ||
${BUILDDEP_SLIM} \ | ||
${BUILDDEP_DEFAULT} \ | ||
${BUILDDEP_FULL} | ||
|
||
# Tell rust to cross-compile | ||
if [ "${ARCH}" != "$(uname -m)" ]; then | ||
mkdir -p ~/.cargo | ||
cat >> ~/.cargo/config << EOT_CARGO | ||
[target.${ARCH}-unknown-linux-${ABI}] | ||
linker = "${ARCH}-linux-${ABI}-gcc" | ||
[target.${ARCH}-unknown-linux-${ABI}.dbus] | ||
rustc-link-lib = ["dbus-1", "gcrypt", "gpg-error", "lz4", "lzma", "systemd"] | ||
EOT_CARGO | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
BUILD_TARGET=${1} # macos, linux | ||
ARCH=${2} # armhf, arm64, x86_64 | ||
BINARCH=${3} # arm, aarch64, x86_64 | ||
ABI=${4} # gnu, gnueabihf | ||
ARTIFACT_TYPE=${5} # slim, default, full | ||
|
||
# "compute" rust-target | ||
if [ "${BUILD_TARGET}" == "macos" ]; then | ||
echo RUST_TARGET=x86_64-apple-darwin | ||
else | ||
echo RUST_TARGET=${BINARCH}-unknown-linux-${ABI} | ||
fi | ||
|
||
echo "ARTIFACT_NAME=spotifyd-${BUILD_TARGET}-${ARCH}-${ARTIFACT_TYPE}" | ||
|
||
# only on linux | ||
if [ "${BUILD_TARGET}" == "linux" ]; then | ||
echo "DEBIAN_FRONTEND=noninteractive" | ||
fi | ||
|
||
# only when cross-building on linux | ||
if [ "${BUILD_TARGET}" == "linux" ] && [ "${ARCH}" != "$(uname -m)" ]; then | ||
echo "RUSTFLAGS=-C linker=${BINARCH}-linux-${ABI}-gcc" | ||
echo "PKG_CONFIG_ALLOW_CROSS=1" | ||
echo "PKG_CONFIG_LIBDIR=/usr/lib/${BINARCH}-linux-${ABI}/pkgconfig/" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters