Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/scripts/identify-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -eo pipefail

# Env (all optional):
# VERSION_FILE file holding the package version (default: packaging/VERSION)
# CLOUDSMITH_PREFIX prefix of the cloudsmith version label (default: adi-scripts)
VERSION_FILE="${VERSION_FILE:-packaging/VERSION}"
CLOUDSMITH_PREFIX="${CLOUDSMITH_PREFIX:-adi-scripts}"

ci_version=""
[[ -f "$VERSION_FILE" ]] && ci_version=$(tr -d '[:space:]' < "$VERSION_FILE")

if [[ -z "$ci_version" ]]; then
echo "Failed to read version from ${VERSION_FILE}, using default"
ci_version="0.0.1+${GITHUB_SHA}"
fi

echo "CI Version to use: $ci_version"
echo "ci-version=$ci_version" >> "$GITHUB_OUTPUT"

# Extract version from ref for the CLOUDSMITH_VERSION
cloudsmith_version=""
if [[ "${GITHUB_REF}" == *"refs/tags/v"* ]]; then
cloudsmith_version="${CLOUDSMITH_PREFIX}-${GITHUB_REF#refs/tags/}"
elif [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
cloudsmith_version="${CLOUDSMITH_PREFIX}-main~latest"
elif [[ "${GITHUB_REF}" == *"refs/pull/"* ]]; then
pr_number=$(echo "$GITHUB_REF" | sed -e "s#refs/##g" -e "s#/merge##g" -e "s#/#-#g")
cloudsmith_version="${CLOUDSMITH_PREFIX}-${pr_number}"
fi

echo "Cloudsmith version to use: $cloudsmith_version"
echo "cloudsmith-version=$cloudsmith_version" >> "${GITHUB_OUTPUT}"
69 changes: 69 additions & 0 deletions .github/scripts/install-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -eo pipefail

# Env: ARCHITECTURE, CONTAINER, CI_VERSION, VERSION_SUFFIX, PACKAGE_NAME,
# CONTROL_PATH (default packaging/debian), ARTIFACTS_DIR (amd64/arm64:
# output of the deb action),
# GITHUB_ENV
CONTROL_PATH="${CONTROL_PATH:-packaging/debian}"
# Packages may be Architecture: all, so match any architecture in the filename
DEB_GLOB="${PACKAGE_NAME}_${CI_VERSION}-1${VERSION_SUFFIX}_*.deb"

if [[ "$ARCHITECTURE" == 'armhf' ]]; then
echo "Building debian package for armhf ..."
docker exec \
-e VERSION="$CI_VERSION" \
-e WORKING_DIRECTORY="/workspace" \
-e GITHUB_WORKSPACE="/workspace" \
-e IGNORE_PATH="packaging" \
-e CONTROL_PATH="$CONTROL_PATH" \
-e VERSION_SUFFIX="$VERSION_SUFFIX" \
-w /workspace \
debian-armhf \
/bin/bash -c "
set -e
git clone https://github.com/analogdevicesinc/shared-actions /tmp/shared-actions
/tmp/shared-actions/deb-generator-action/build-deb.sh
"

# Installation and verification of package
docker exec -w /workspace/artifacts debian-armhf \
/bin/bash -c "set -e; apt-get install -y ./${DEB_GLOB}"

# Artifacts are already on the host through the workspace mount
ARTIFACTS_DIR="${GITHUB_WORKSPACE}/artifacts"
else
[[ "$ARCHITECTURE" == "arm64" ]] && SUDO="" || SUDO="sudo"
${SUDO} apt-get install -y ${ARTIFACTS_DIR}/${DEB_GLOB}
fi

# Orig tarball is only needed for the source package
rm -rf "${ARTIFACTS_DIR}/${PACKAGE_NAME}_${CI_VERSION}.orig.tar" 2>/dev/null || true

# Create debian output name - differentiate by distro
if [[ "${CONTAINER}" == *"kuiper"* ]]; then
distro_tag="kuiper"
elif [[ "${CONTAINER}" == "debian:latest" || "${CONTAINER}" == "debian:forky" ]]; then
distro_tag="debian"
else
distro_tag="ubuntu"
fi

# On armhf the os-release has to be read from inside the container
if [[ "$ARCHITECTURE" == 'armhf' ]]; then
os_release=$(docker exec debian-armhf cat /etc/os-release)
else
os_release=$(cat /etc/os-release)
fi

version_id=$(echo "$os_release" | grep "^VERSION_ID" | cut -d "=" -f2 | tr -d '"' || true)

# Cloudsmith distribution (e.g. debian/trixie, ubuntu/noble) comes from the os-release of the build system
distribution_id=$(echo "$os_release" | grep "^ID=" | cut -d "=" -f2 | tr -d '"' || true)
distribution_codename=$(echo "$os_release" | grep "^VERSION_CODENAME" | cut -d "=" -f2 | tr -d '"' || true)
# Debian testing (forky) has no VERSION_ID - fall back to the codename
[[ -z "$version_id" ]] && version_id=$(echo "$os_release" | grep "^VERSION_CODENAME" | cut -d "=" -f2 | tr -d '"') || true

echo "DEBIAN_ARTIFACT=${PACKAGE_NAME}-deb-${ARCHITECTURE}-${distro_tag}-${version_id}" >> "$GITHUB_ENV"
echo "DISTRIBUTION_NAME=${distribution_id}/${distribution_codename}" >> "$GITHUB_ENV"
60 changes: 60 additions & 0 deletions .github/scripts/install-deps-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -eo pipefail

# Env: ARCHITECTURE, CONTAINER, PLATFORM (armhf only)
# The armhf build runs in a persistent emulated container (debian-armhf) with
# the workspace mounted at /workspace. amd64/arm64 build directly on the runner
# (arm64 inside the job container).

DEPS="build-essential devscripts debhelper gettext git curl ca-certificates rsync"

if [[ "$ARCHITECTURE" == "armhf" ]]; then
docker run --platform "${PLATFORM}" \
--name debian-armhf \
-v "${GITHUB_WORKSPACE}:/workspace" \
-dit "${CONTAINER}"

echo "::group::Installing dependencies"
docker exec \
-e PACKAGE_NAME=${PACKAGE_NAME} \
-e CLOUDSMITH_ORG=${CLOUDSMITH_ORG} \
-e CLOUDSMITH_USERNAME=${CLOUDSMITH_USERNAME} \
-e CLOUDSMITH_REPO=${CLOUDSMITH_REPO} \
-e CLOUDSMITH_API_KEY=${CLOUDSMITH_API_KEY} \
-e GT_DEBIAN_VERSION=${GT_DEBIAN_VERSION} \
-w /workspace \
debian-armhf \
/bin/bash -c "
set -eo pipefail
apt-get update && apt-get install -y ${DEPS} sudo

# Install downloaded gt artifact
if [[ \"\$PACKAGE_NAME\" == \"adi-scripts\" ]]; then
/workspace/.github/scripts/setup-cloudsmith-apt.sh
apt-cache policy gt || true
apt-get install -y gt=\${GT_DEBIAN_VERSION}
fi
"
echo "::endgroup::"
else
[[ "$ARCHITECTURE" == "arm64" ]] && SUDO="" || SUDO="sudo"

echo "::group::Installing dependencies"
${SUDO} apt-get update
DEBIAN_FRONTEND=noninteractive ${SUDO} apt-get install -y ${DEPS} sudo

# Install downloaded gt artifact
if [[ "$PACKAGE_NAME" == "adi-scripts" ]]; then
[[ -n "${CLOUDSMITH_API_KEY}" ]] || { echo "::error::CLOUDSMITH_API_KEY is empty (Setup cloudsmith step did not export it)"; exit 1; }
[[ -n "${CLOUDSMITH_USERNAME}" && -n "${CLOUDSMITH_ORG}" && -n "${CLOUDSMITH_REPO}" ]] || { echo "::error::CLOUDSMITH_USERNAME/ORG/REPO is empty"; exit 1; }
# sudo-rs (Ubuntu 26.04) ignores -E, so pass the variables explicitly
${SUDO} env CLOUDSMITH_ORG="${CLOUDSMITH_ORG}" CLOUDSMITH_REPO="${CLOUDSMITH_REPO}" \
CLOUDSMITH_USERNAME="${CLOUDSMITH_USERNAME}" CLOUDSMITH_API_KEY="${CLOUDSMITH_API_KEY}" \
bash .github/scripts/setup-cloudsmith-apt.sh
apt-cache policy gt || true
${SUDO} apt-get install -y "gt=${GT_DEBIAN_VERSION}"
fi

echo "::endgroup::"
fi
43 changes: 43 additions & 0 deletions .github/scripts/setup-cloudsmith-apt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -eo pipefail

# Configure the private Cloudsmith apt repository manually (must run as root).
# The generated setup.deb.sh does not forward basic-auth credentials to its own
# requests (GPG key / config), so it fails on private repos - do it by hand.
# Env: CLOUDSMITH_ORG, CLOUDSMITH_REPO, CLOUDSMITH_USERNAME, CLOUDSMITH_API_KEY
# Optional: CLOUDSMITH_GPG_KEY_ID (repo signing key id), CLOUDSMITH_DISTRO, CLOUDSMITH_CODENAME
# The repo is flat, so a supported distro is forced - Ubuntu 24.04/26.04 and Debian
# testing (forky) are not reliably auto-detected.

: "${CLOUDSMITH_ORG:?}" "${CLOUDSMITH_REPO:?}" "${CLOUDSMITH_USERNAME:?}" "${CLOUDSMITH_API_KEY:?}"
KEY_ID="${CLOUDSMITH_GPG_KEY_ID:-85421AD6CC87F02A}"
DISTRO="${CLOUDSMITH_DISTRO:-debian}"
CODENAME="${CLOUDSMITH_CODENAME:-trixie}"

BASE="https://dl.cloudsmith.io/basic/${CLOUDSMITH_ORG}/${CLOUDSMITH_REPO}"
NAME="${CLOUDSMITH_ORG}-${CLOUDSMITH_REPO}"
KEYRING="/usr/share/keyrings/${NAME}-archive-keyring.gpg"
LIST="/etc/apt/sources.list.d/${NAME}.list"
AUTH="/etc/apt/auth.conf.d/${NAME}.conf"

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y apt-transport-https ca-certificates curl gnupg

CURL=(curl -u "${CLOUDSMITH_USERNAME}:${CLOUDSMITH_API_KEY}" -1sSL --fail-with-body)

rm -f "${KEYRING}"
"${CURL[@]}" "${BASE}/gpg.${KEY_ID}.key" | gpg --dearmor > "${KEYRING}"
"${CURL[@]}" "${BASE}/config.deb.txt?distro=${DISTRO}&codename=${CODENAME}&component=main" > "${LIST}"

# apt authentication for the private repo
mkdir -p /etc/apt/auth.conf.d
printf 'machine dl.cloudsmith.io login %s password %s\n' "${CLOUDSMITH_USERNAME}" "${CLOUDSMITH_API_KEY}" > "${AUTH}"
chmod 600 "${AUTH}"
chmod 644 "${KEYRING}" "${LIST}"

# Make sure the key path used by the list matches the one we installed
grep -q "signed-by" "${LIST}" && sed -i "s#signed-by=[^] ]*#signed-by=${KEYRING}#" "${LIST}"

apt-get update
13 changes: 13 additions & 0 deletions .github/scripts/upload-to-cloudsmith.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -eo pipefail

# Env: WORKSPACE, PACKAGE_NAME, CONTAINER, CLOUDSMITH_ORG, CLOUDSMITH_REPO, CLOUDSMITH_VERSION
cd "${WORKSPACE}/artifacts"

# Binary packages go to the debian repository. Source package files (.dsc, .orig.tar.gz, .debian.tar.xz) are not uploaded
for f in "${PACKAGE_NAME}"_*.deb; do
[[ -f "$f" ]] || continue
cloudsmith push deb --republish --no-wait-for-sync \
"${CLOUDSMITH_ORG}/${CLOUDSMITH_REPO}/${DISTRIBUTION_NAME}" "$f"
done
141 changes: 141 additions & 0 deletions .github/workflows/build-linux-image-adi-scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Build debian package for Linux ADI-scripts

permissions:
contents: read
id-token: write

on:
workflow_call:
inputs:
gt-version:
description: 'Gt debian version'
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
identify-version:
runs-on: ubuntu-latest
outputs:
ci-version: ${{ steps.set_version.outputs.ci-version }}
cloudsmith-version: ${{ steps.set_version.outputs.cloudsmith-version }}
steps:
- name: Checkout code repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set app version
id: set_version
shell: bash
run: |
.github/scripts/identify-version.sh
env:
VERSION_FILE: packaging/VERSION
CLOUDSMITH_PREFIX: adi-scripts
build-linux:
needs: identify-version
strategy:
fail-fast: false
matrix:
include:
- architecture: amd64
runs-on: ubuntu-24.04
version-suffix: +Ubuntu24.04
- architecture: amd64
runs-on: ubuntu-26.04
version-suffix: +Ubuntu26.04
- architecture: arm64
runs-on: ubuntu-26.04-arm
container: docker.cloudsmith.io/adi/containers/kuiper_basic_64:latest
version-suffix: +Debian13
- architecture: armhf
runs-on: ubuntu-26.04-arm
container: docker.cloudsmith.io/adi/containers/kuiper_basic_32:latest
platform: linux/arm/v7
version-suffix: +Debian13
- architecture: arm64
runs-on: ubuntu-26.04-arm
container: debian:forky
version-suffix: +Debian14
- architecture: armhf
runs-on: ubuntu-26.04-arm
container: debian:forky
platform: linux/arm/v7
version-suffix: +Debian14
runs-on: ${{ matrix.runs-on }}
container: ${{ matrix.architecture == 'arm64' && matrix.container || '' }}
env:
ARCHITECTURE: ${{ matrix.architecture }}
CONTAINER: ${{ matrix.container }}
PLATFORM: ${{ matrix.platform }}
CI_VERSION: ${{ needs.identify-version.outputs.ci-version }}
CLOUDSMITH_VERSION: ${{ needs.identify-version.outputs.cloudsmith-version }}
CLOUDSMITH_ORG: ${{ secrets.CLOUDSMITH_ORG }}
CLOUDSMITH_REPO: ${{ secrets.CLOUDSMITH_REPO }}
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_SVC }}
VERSION_SUFFIX: ${{ matrix.version-suffix }}
PACKAGE_NAME: adi-scripts
CONTROL_PATH: packaging/debian
OUTPUT_PREFIX: adi-scripts
GT_DEBIAN_VERSION: ${{ inputs.gt-version }}-1${{ matrix.version-suffix }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
# The cloudsmith action installer needs curl or wget, which the arm runner image / job container may not ship
- name: Install cloudsmith action prerequisites
shell: bash
run: |
# jq is required by the action's export-auth-token
if (command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1) && command -v jq >/dev/null 2>&1; then
echo "curl/wget and jq already available"
exit 0
fi
[[ "$(id -u)" == "0" ]] && SUDO="" || SUDO="sudo"
${SUDO} apt-get update
${SUDO} apt-get install -y curl ca-certificates jq
# Needed for installing gt from the private repo, regardless of publishing
- name: Setup cloudsmith
uses: cloudsmith-io/cloudsmith-cli-action@92b1383b22bbd36d804b858f273abcdf4d349f6b # v3
with:
oidc-namespace: ${{ secrets.CLOUDSMITH_ORG }}
oidc-service-slug: ${{ secrets.CLOUDSMITH_SVC }}
# Exports the OIDC token as CLOUDSMITH_API_KEY (and CLOUDSMITH_USERNAME=token) for the gt repo setup
export-auth-token: true
- name: Install deps
shell: sh
run: |
.github/scripts/install-deps-linux.sh
# This shared-action is compatible only with amd64/arm64 - armhf is built in install-app.sh
- name: Create debian package - amd64/arm64
if: ${{ matrix.architecture == 'amd64' || matrix.architecture == 'arm64' }}
id: build_deb
uses: analogdevicesinc/shared-actions/deb-generator-action@main
with:
working-directory: .
ignore-path: |
packaging
control-path: packaging/debian
version: ${{ env.CI_VERSION }}
version-suffix: ${{ env.VERSION_SUFFIX }}
# Also debian creation for armhf architecture
- name: Install and verify application
shell: sh
run: |
.github/scripts/install-app.sh
env:
ARTIFACTS_DIR: ${{ steps.build_deb.outputs.artifact-dir || '' }}
- name: Upload debian artifacts to github
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 #v7
with:
name: ${{ env.DEBIAN_ARTIFACT }}
path: |
artifacts/
if-no-files-found: error
- name: Push to cloudsmith
if: ${{ env.CLOUDSMITH_VERSION != '' }}
shell: bash
run: |
.github/scripts/upload-to-cloudsmith.sh
env:
WORKSPACE: ${{ github.workspace }}
Loading
Loading