From d4d37db2f0168498068e8fa0adfff500fc10a33f Mon Sep 17 00:00:00 2001 From: Se7enZ Date: Wed, 6 Nov 2024 19:59:04 +0100 Subject: [PATCH] build: Matrix strategy for release builds ([#7776]). Also modifies the `build-release.sh` script to optionally accept specific distribution targets for Ubuntu releases. --- .github/workflows/release.yml | 48 ++++++++++++++++++++++++++++++----- tools/build-release.sh | 7 +++-- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7288036db7ba..12012dd9ad90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: check: name: Check outputs: - version: steps.capture.outputs.version + version: ${{ steps.capture.outputs.version }} runs-on: ubuntu-24.04 steps: - name: Git checkout @@ -46,10 +46,18 @@ jobs: id: capture run: echo "version=${VERSION}" >> "$GITHUB_OUTPUT" - release: - name: Release + releases: + name: Releases needs: check runs-on: ubuntu-24.04 + strategy: + fail-fast: false # Let each build finish. + matrix: + target: + - 'bin-Fedora-28-amd64' + - 'bin-Ubuntu-focal' + - 'bin-Ubuntu-jammy' + - 'bin-Ubuntu-noble' steps: - name: Git checkout uses: actions/checkout@v4 @@ -63,13 +71,41 @@ jobs: ./configure - name: Build environment setup - run: contrib/cl-repro.sh + run: | + distribution=$(echo ${{ matrix.target }} | cut -d'-' -f3) + echo "Building base image for ${distribution}" + sudo docker run --rm -v $(pwd):/build ubuntu:${distribution} bash -c "\ + apt-get update && \ + apt-get install -y debootstrap && \ + debootstrap ${distribution} /build/${distribution}" + sudo tar -C ${distribution} -c . | docker import - ${distribution} + + # Build Docker image + docker build -t cl-repro-${distribution} - < contrib/reprobuild/Dockerfile.${distribution} + if: contains(matrix.target, 'Ubuntu') - name: Build release - run: tools/build-release.sh bin-Fedora-28-amd64 bin-Ubuntu + run: tools/build-release.sh ${{ matrix.target }} - - name: Upload release artifacts + - name: Upload target artifacts uses: actions/upload-artifact@v4 with: path: release/ + name: ${{ matrix.target }} if-no-files-found: error + + artifact: + name: Construct release artifact + needs: + - check + - releases + env: + version: ${{ needs.check.outputs.version }} + runs-on: ubuntu-24.04 + steps: + - name: Merge artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: c-lightning-${{ env.version }} + pattern: bin-* + delete-merged: true diff --git a/tools/build-release.sh b/tools/build-release.sh index 0924ff675f84..f98b47961156 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -153,8 +153,11 @@ for target in $TARGETS; do docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform" /build echo "Fedora Image Built" ;; - Ubuntu) - for d in focal jammy noble; do + Ubuntu*) + distributions=${platform#Ubuntu-} + echo "distributions=$distributions" + [ "$distributions" == "Ubuntu" ] && distributions="focal jammy noble" + for d in $distributions; do # Capitalize the first letter of distro D=$(echo "$d" | awk '{print toupper(substr($0,1,1))substr($0,2)}') echo "Building Ubuntu $D Image"