Skip to content

Commit

Permalink
action builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jxmx committed Mar 30, 2024
1 parent 14f4351 commit b2bce77
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/make_and_publish_pkgs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: make_and_publish_pkgs
run-name: Package ${{ github.event.repository.name }}(${{ github.ref_name }}) for ${{ inputs.os }}/${{ inputs.arch }}, Publish to ${{ inputs.deployment-environment }}
on:
workflow_dispatch:
inputs:
arch:
description: 'Platform Architecture'
type: choice
options:
- amd64
os:
description: 'Debian Release Version'
type: choice
options:
- bookworm
- bullseye
gh-rel:
description: 'GitHub Release Tag (for debs)'
type: string
deployment-environment:
description: 'Aptly Repository Stream'
type: choice
options:
- development
- testing
- production
commit-versioning:
description: 'Commit Versioning'
type: choice
options:
- default
- yes
- no

jobs:
make-packages:
uses: AllStarLink/asl3-asterisk/.github/workflows/ephemeral_ec2_run-this.yml@develop
with:
run-this: ./builder/dockerbuild.sh -a ${{ inputs.arch }} -o ${{ inputs.os }} --ast-ver ${{ inputs.ast-ver }} --rpt-ver ${{ inputs.rpt-ver }} --asl3-ver ${{ inputs.asl3-ver}} --gh-rel ${{ inputs.gh-rel }} ${{ (inputs.commit-versioning == 'yes' || (inputs.commit-versioning == 'default' && inputs.deployment-environment == 'development')) && '-r' || null }}
arch: ${{ inputs.arch == 'armhf' && 'arm64' || inputs.arch == 'aarch64' && 'arm64' || inputs.arch == 'amd64' && 'x86_64' || inputs.arch == 'riscv64' && 'x86_64' || inputs.arch }}
artifact-path: '_debs/*'
secrets: inherit
# publish-packages:
# uses: AllStarLink/asl3-asterisk/.github/workflows/publish_artifacts_to_aptly.yml@develop
# with:
# repo-name: asl_builds-${{inputs.os}}${{ inputs.deployment-environment == 'production' && '' || inputs.deployment-environment == 'testing' && '-testing' || inputs.deployment-environment == 'development' && '-devel' || null }}
# secrets: inherit
# needs: make-packages
42 changes: 42 additions & 0 deletions builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG ARCH
ARG OS

FROM $ARCH/debian:$OS

ARG ARCH
ARG OS
ARG ASL_REPO
ARG USER_ID
ARG GROUP_ID

RUN addgroup --gid $GROUP_ID user; exit 0
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user; exit 0

# Install build dependencies
RUN apt-get update && apt-get -y install \
apt-utils build-essential devscripts fakeroot debhelper git \
gh ca-certificates wget --no-install-recommends

# Install application dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
autoconf automake binutils-dev cmark-gfm dahdi-source debhelper-compat \
default-libmysqlclient-dev freetds-dev libasound2-dev libavcodec-dev libavdevice-dev \
libbluetooth-dev libc-client2007e-dev libcap-dev libcodec2-dev libcurl4-openssl-dev \
libedit-dev libfftw3-dev libgmime-3.0-dev libgsm1-dev libical-dev libiksemel-dev \
libjack-dev libjansson-dev libldap-dev liblua5.1-dev libncurses-dev libneon27-dev \
libnewt-dev libogg-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenr2-dev libopus-dev \
libopusfile-dev libpopt-dev libpq-dev libpri-dev libradcli-dev libreadline-dev \
libresample1-dev libsdl-image1.2-dev libsndfile1-dev libsnmp-dev libspandsp-dev \
libspeex-dev libspeexdsp-dev libsqlite3-dev libsrtp2-dev libss7-dev \
libssl-dev libswscale-dev libsystemd-dev libtonezone-dev libunbound-dev \
liburiparser-dev libusb-dev libvo-amrwbenc-dev libvorbis-dev libxml2-dev \
libxslt1-dev perl portaudio19-dev subversion unixodbc-dev \
uuid-dev zlib1g-dev devscripts lsb-release --no-install-recommends

# Import entrypoint script
COPY ./entrypoint.sh /entrypoint.sh

# Make Executable
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
88 changes: 88 additions & 0 deletions builder/dockerbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

set -e
set -x

while [[ $# -gt 0 ]]; do
case $1 in
-a|--architecture)
ARCH_ASK="$2"
shift
shift
;;
-o|--operating-systems)
OPERATING_SYSTEMS="$2"
shift
shift
;;
--gh-rel)
GH_REL="$2"
shift
shift
;;
-*|--*|*)
echo "Unknown option $1"
;;
esac
done

if [ -z "$ARCH_ASK" ]
then
ARCH="all"
fi

case $ARCH_ASK in
arm64)
ARCH=arm64v8
;;
armhf)
ARCH=arm32v7
;;
*)
ARCH=$ARCH_ASK
;;
esac

if [ -z "$OPERATING_SYSTEMS" ]
then
OPERATING_SYSTEMS="bookworm"
fi

BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [ $BRANCH == "develop" ]; then
REPO_ENV="-devel"
elif [ $BRANCH = "testing"]; then
REPO_ENV="-testing"
else
REPO_ENV=""
fi

## Need to clean this up to be more elegant
echo "Architectures: $ARCH"
echo "Targets: $TARGETS"
echo "Operating Systems: $OPERATING_SYSTEMS"
echo "PWD: $(pwd)"
echo "BS: ${BASH_SOURCE[0]}"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "DIR: ${DIR}"
PDIR=$(dirname $DIR)
echo "PDIR: ${PDIR}"
ALL_PKG_ROOT=$(dirname ${PDIR})
echo "ALL_PKG_ROOT: ${ALL_PKG_ROOT}"

D_TAG="dahdi-linux_builder.${OPERATING_SYSTEMS}.${ARCH}${REPO_ENV}"

docker build -f $DIR/Dockerfile -t $D_TAG \
--build-arg ARCH="$ARCH" \
--build-arg OS="$OPERATING_SYSTEMS" \
--build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \
$DIR

docker run -v $ALL_PKG_ROOT:/build $D_TAG

DEBIAN_FRONTEND=noninteractive apt-get -y install gh
gh release upload -R AllStarLink/dahdi-linux $GH_REL $ALL_PKG_ROOT/_debs/*.deb

docker image rm --force $D_TAG
24 changes: 24 additions & 0 deletions builder/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e
set -x

if [ -f /etc/os-release ] ; then
OS_CODENAME=$(cat /etc/os-release | grep "^VERSION_CODENAME=" | sed 's/VERSION_CODENAME=\(.*\)/\1/g')
elif [ command -v lsb_release ] ; then
OS_CODENAME=$(lsb_release -a 2>/dev/null | grep "^Codename:" | sed 's/^Codename:\s*\(.*\)/\1/g')
elif [ command -v hostnamectl ] ; then
OS_CODENAME=$(hostnamectl | grep "Operating System: " | sed 's/.*Operating System: [^(]*(\([^)]*\))/\1/g')
else
OS_CODENAME=unknown
fi

echo "OS_CODENAME: ${OS_CODENAME}"

cd /build

export EMAIL="AllStarLink <[email protected]>"
pushd dahdi-linux
make deb
popd
mkdir _debs
mv *.deb _debs/

0 comments on commit b2bce77

Please sign in to comment.