Linuxfabrik: Build Linux (x86_64) #13
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
name: 'Linuxfabrik: Build Linux (x86_64)' | |
on: | |
workflow_dispatch: | |
inputs: | |
# package-version: | |
# description: 'The version ("major.minor.patch"). If empty, version is taken from `version.txt`, and revision is auto-incremented.' | |
# required: false | |
# default: '' | |
# lib-repo-ref: | |
# description: 'The branch, tag, or SHA to checkout from the lib repo. Defaults to the current branch or tag.' | |
# required: false | |
# default: '' | |
check-plugin: | |
description: 'If you only want to compile a specific check plugin, specify its name, for example `cpu-usage`, otherwise leave empty to build all plugins.' | |
required: false | |
default: 'cpu-usage' | |
distros: | |
description: 'Comma-separated list of operating systems to build on. Supported: `debian11,debian12,rocky8,rocky9,ubuntu2004,ubuntu2204,ubuntu2404`.' | |
required: false | |
default: 'rocky9' | |
# modify the default permissions granted to the GITHUB_TOKEN | |
permissions: | |
contents: 'read' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
set-matrix: | |
runs-on: | |
- 'ubuntu-24.04' | |
outputs: | |
matrix: '${{ steps.generate-matrix.outputs.matrix }}' | |
steps: | |
- name: 'Generate Matrix' | |
id: 'generate-matrix' | |
run: | | |
distros="${{ inputs.distros }}" | |
matrix=$(echo "$distros" | jq --compact-output --raw-input '{"distros": split(",")}') | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
build-packages: | |
runs-on: | |
- 'ubuntu-24.04' | |
needs: | |
- 'set-matrix' | |
strategy: | |
matrix: | |
distro: '${{ fromJson(needs.set-matrix.outputs.matrix).distros }}' | |
steps: | |
- name: 'Debug Environment and Inputs' | |
run: > | |
echo | |
check-plugin=${{ inputs.check-plugin }} | |
lib-repo-ref=${{ inputs.lib-repo-ref }} | |
package-iteration=${{ inputs.package-iteration }} | |
distros=${{ inputs.distros }} | |
- name: 'Checkout the monitoring-plugins repo' | |
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # v4.2.2 | |
with: | |
path: 'repos/monitoring-plugins' | |
- name: 'Cache the checkout' | |
uses: 'actions/cache@v4' | |
with: | |
path: 'repos/monitoring-plugins' | |
- name: 'Checkout the lib repo' | |
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # v4.2.2 | |
with: | |
repository: 'Linuxfabrik/lib' | |
ref: '${{ inputs.lib-repo-ref || github.ref_name }}' | |
path: 'repos/lib' | |
- name: 'Cache the checkout' | |
uses: 'actions/cache@v4' | |
with: | |
path: 'repos/lib' | |
- name: 'mkdir -p build' | |
run: 'mkdir -p build' | |
- name: 'mkdir -p build/${{ matrix.distro }}' | |
run: 'mkdir -p build/${{ matrix.distro }}' | |
- name: 'Synchronize cached writes to persistent storage' | |
run: 'sync' | |
- name: '⚙️ apt-get -y install podman' | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install podman | |
- name: 'Build the container for ${{ matrix.distro }}' | |
run: > | |
podman build | |
--file "repos/monitoring-plugins/build/${{ matrix.distro }}/Containerfile" | |
--tag "lfmp-build-${{ matrix.distro }}" | |
- name: 'Build the packages for ${{ matrix.distro }}' | |
run: > | |
podman run | |
--rm | |
--mount type=bind,source=build/${{ matrix.distro }},destination=/build,relabel=private | |
--mount type=bind,source=repos,destination=/repos,relabel=shared,ro=true | |
"lfmp-build-${{ matrix.distro }}" | |
/bin/bash -x | |
/repos/monitoring-plugins/build/${{ matrix.distro }}/build.sh | |
${{ inputs.package-version || github.ref_name }} | |
${{ inputs.package-iteration || '1' }} | |
${{ inputs.check-plugin || '' }} | |
- name: 'Upload build output as artifact for packaging later on' | |
uses: 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08' # v4.6.0 | |
with: | |
path: 'build/' | |
name: 'monitoring-plugins-linux.${{ matrix.distro }}.x86_64.zip' |