Skip to content

Commit

Permalink
feat(gh-actions/build-debian): Support running a workflow script at b…
Browse files Browse the repository at this point in the history
…uild-source phase (#54)

When building some packages we may need to prepare the build environment
before preparing the source package, for example in some cases we may
need to enable git access (to compute the package version or similar) or
we may need to install tools that are used during debian source building
that are not provided in the archive (such as rust crates, hello
cargo-vendor-filterer!!).

So instead of polluting this generic action with package-specific
requirements, let's just make it support running a script that can do
more advanced configurations in the docker instance that is used only
during the source-preparation phase.

This is required in order to be able to do a `cargo install --root=/usr
cargo-vendor-filterer` to build the source package of rust programs as
required by authd in ubuntu/authd#130

UDENG-2343
  • Loading branch information
3v1n0 authored Dec 18, 2024
2 parents 6cbd292 + 2632841 commit d671aa3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test-build-deb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ jobs:
docker-image: ubuntu:devel
lintian: --fail-on error
extra-source-build-deps: ''
extra-source-build-script: |
echo '$HOME' is "${HOME}"
echo "::group::Get some system information"
uname -a
cat /etc/os-release
echo "::endgroup::"
lintian-to-md:
name: Test lintian results parser to markdown
Expand Down
27 changes: 25 additions & 2 deletions gh-actions/common/build-debian/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ inputs:
description: A list of extra build dependencies required during source build.
required: false
# FIXME: this should default to '', but we don't want to break job depending on us for now
default: 'ca-certificates git'
default: 'ca-certificates'
extra-source-build-script:
description: |
A script to run to prepare the source build machine.
This happens after the dependencies have been installed, but before
running `dpkg-buildpackage -S`.
required: false
default: ''
lintian:
required: false
description: Arguments to pass to lintian, if any. Set to `skip` to skip the lintian check.
Expand Down Expand Up @@ -133,9 +140,17 @@ runs:
echo "::group::Install build dependencies"
apt build-dep .
GITHUB_TOKEN="${{ inputs.token }}"
if [ -n "${{ inputs.extra-source-build-deps }}" ]; then
# Install extra packages for build-deps, to allow downloading vendored sources
deps=(${{ inputs.extra-source-build-deps }})
if [ -n "${GITHUB_TOKEN}" ]; then
deps+=(git)
fi
apt install ${deps[@]}
fi
echo "::endgroup::"
Expand All @@ -144,11 +159,19 @@ runs:
git config --system --add safe.directory "${{ github.workspace }}"
fi
GITHUB_TOKEN="${{ inputs.token }}"
if [ -n "${GITHUB_TOKEN}" ]; then
git config --system url."https://api:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ -n "${{ inputs.extra-source-build-script != '' && 'true' || '' }}" ]; then
echo "::group::Run source build script"
(
set -eux
${{ inputs.extra-source-build-script }}
)
echo "::endgroup::"
fi
echo "::group::Build debian source package"
dpkg-buildpackage -D -S --sanitize-env
echo "::endgroup::"
Expand Down

0 comments on commit d671aa3

Please sign in to comment.