Skip to content

Manage per-model recipe options without loading #4456

Manage per-model recipe options without loading

Manage per-model recipe options without loading #4456

Workflow file for this run

name: Launchpad PPA
permissions:
contents: read
on:
push:
branches:
- main
tags:
- '*'
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
merge_group:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' && 'pr' || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
prepare-matrix:
name: Prepare matrix
runs-on: ubuntu-latest
outputs:
package_matrix: ${{ steps.set-matrix.outputs.package_matrix }}
steps:
- name: Define shared matrix values
id: set-matrix
run: |
{
echo 'package_matrix<<EOF'
cat <<'JSON'
{
"include": [
{
"release": "24.04",
"distro": "ubuntu",
"codename": "noble",
"ppa": "ppa:lemonade-team/bleeding-edge"
},
{
"release": "25.10",
"distro": "ubuntu",
"codename": "questing",
"ppa": "ppa:lemonade-team/bleeding-edge"
},
{
"release": "26.04",
"distro": "ubuntu",
"codename": "resolute",
"ppa": ""
}
]
}
JSON
echo 'EOF'
} >> "$GITHUB_OUTPUT"
package:
name: Build
needs: prepare-matrix
runs-on: ubuntu-latest
permissions:
contents: read
# Label a PR `ci:distros` to opt it back in.
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci:distros')
strategy:
matrix: ${{ fromJSON(needs.prepare-matrix.outputs.package_matrix) }}
container:
image: ghcr.io/lemonade-sdk/lemonade/build-environment:${{ matrix.distro }}${{ matrix.release }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Configure git safe directory
run: git config --global --add safe.directory $(pwd)
- name: Prepare Debian build
id: get_version
uses: ./.github/actions/prepare-debian-build
with:
release: ${{ matrix.release }}
codename: ${{ matrix.codename }}
- name: Get short SHA
id: short_sha
run: echo "sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Catch missing build-deps
run: |
apt-get update && apt-get build-dep . -y
- name: Build binary package
id: build_binary
# Also on a labelled PR: the label has to reproduce what the queue runs,
# and a source-only package compiles nothing.
if: github.event_name == 'merge_group' || contains(github.event.pull_request.labels.*.name, 'ci:distros')
uses: ./.github/actions/build-debian-package
with:
package-type: binary
deb-version: ${{ steps.get_version.outputs.version }}
- name: Build source package
id: build_source
if: github.event_name != 'merge_group' && !contains(github.event.pull_request.labels.*.name, 'ci:distros')
uses: ./.github/actions/build-debian-package
with:
package-type: source
deb-version: ${{ steps.get_version.outputs.version }}
- name: Upload Debian package
if: github.event_name == 'merge_group' || contains(github.event.pull_request.labels.*.name, 'ci:distros')
uses: actions/upload-artifact@v7
with:
name: lemonade-${{ matrix.codename }}-deb
path: ${{ steps.build_binary.outputs.output-dir }}/*.deb
retention-days: 30
- name: Upload source package
if: github.event_name != 'merge_group' && !contains(github.event.pull_request.labels.*.name, 'ci:distros')
uses: actions/upload-artifact@v7
with:
name: lemonade-${{ matrix.codename }}-source-package
path: ${{ steps.build_source.outputs.output-dir }}/*
retention-days: 30
package-arm64:
name: Build (ARM64)
# Uses official ubuntu:${{ matrix.release }} images from Docker Hub instead of
# the custom build-environment images, because the latter do not yet carry
# linux/arm64 manifests. build-container.yml will publish multi-arch images
# post-merge; once that happens this can revert to the custom build-environment.
needs: prepare-matrix
runs-on: ubuntu-24.04-arm
permissions:
contents: read
# Label a PR `ci:distros` to opt it back in.
if: github.event_name == 'merge_group' || contains(github.event.pull_request.labels.*.name, 'ci:distros')
strategy:
matrix: ${{ fromJSON(needs.prepare-matrix.outputs.package_matrix) }}
container:
image: ubuntu:${{ matrix.release }}
steps:
- name: Install checkout prerequisites
run: |
apt-get update
apt-get install -y git ca-certificates software-properties-common
- name: Add PPA for build dependencies
if: matrix.ppa != ''
run: add-apt-repository -y ${{ matrix.ppa }}
- name: Checkout code
uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Configure git safe directory
run: git config --global --add safe.directory $(pwd)
- name: Install build dependencies
run: |
apt-get update
apt-get install -y \
build-essential \
curl \
debhelper \
devscripts \
dpkg-dev \
git \
python3-pip \
python3-venv \
unzip
- name: Prepare Debian build
id: get_version
uses: ./.github/actions/prepare-debian-build
with:
release: ${{ matrix.release }}
codename: ${{ matrix.codename }}
- name: Build binary package
id: build_binary
uses: ./.github/actions/build-debian-package
with:
package-type: binary
deb-version: ${{ steps.get_version.outputs.version }}
arch-only: 'true'
- name: Upload Debian package
uses: actions/upload-artifact@v7
with:
name: lemonade-${{ matrix.codename }}-arm64-deb
path: ${{ steps.build_binary.outputs.output-dir }}/*.deb
retention-days: 30
upload-stable:
name: Upload (Stable)
strategy:
matrix: ${{ fromJSON(needs.prepare-matrix.outputs.package_matrix) }}
needs: [prepare-matrix, package]
permissions:
contents: read
if: ${{ startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
uses: ./.github/workflows/upload.yml
with:
target: ppa:lemonade-team/stable
artifact: lemonade-${{ matrix.codename }}-source-package
secrets: inherit
upload-bleeding-edge:
name: Upload (Bleeding Edge)
strategy:
matrix: ${{ fromJSON(needs.prepare-matrix.outputs.package_matrix) }}
needs: [prepare-matrix, package]
permissions:
contents: read
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
uses: ./.github/workflows/upload.yml
with:
target: ppa:lemonade-team/bleeding-edge
artifact: lemonade-${{ matrix.codename }}-source-package
secrets: inherit
# Gate job that ensures: 1. in the merge queue, all jobs in `needs:` ran
# successfully (otherwise the merge is blocked), and 2. these jobs do not need
# to run on ordinary pull request pushes.
gate:
name: Launchpad PPA builds
needs: [prepare-matrix, package, package-arm64]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check gated jobs
env:
NEEDS: ${{ toJSON(needs) }}
run: |
# $NEEDS: {"job-id": {"result": "success|failure|skipped|cancelled"}, ...}
# Fail if any job broke. In the merge queue, also fail if any never ran.
echo "$NEEDS"
broke=$(jq -r 'to_entries[]|select(.value.result=="failure" or .value.result=="cancelled")|.key' <<<"$NEEDS")
if [ -n "$broke" ]; then
echo "FAILED: $broke"
exit 1
fi
if [ "${{ github.event_name }}" = "merge_group" ]; then
absent=$(jq -r 'to_entries[]|select(.value.result!="success")|.key' <<<"$NEEDS")
if [ -n "$absent" ]; then
echo "DID NOT RUN IN MERGE QUEUE: $absent"
exit 1
fi
fi