Skip to content
Open
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
61 changes: 46 additions & 15 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,69 @@ on:
platforms-to-build:
type: string
required: true
# JSON array; see the plan job for the known ones.
variants:
type: string
default: '["lightningd", "lightningd-vls-signer"]'
# lightningd-signed: good signatures each manifest must carry.
min-signatures:
type: string
default: '1'

jobs:
# Turn the comma-separated platforms-to-build input into a JSON matrix array,
# so we can fan out per-platform without hardcoding the list twice.
# One job per variant and platform.
plan:
name: Plan platform matrix
name: Plan build matrix
runs-on: ubuntu-24.04
outputs:
platforms: ${{ steps.plan.outputs.platforms }}
matrix: ${{ steps.plan.outputs.matrix }}
steps:
- id: plan
env:
PLATFORMS_TO_BUILD: ${{ inputs.platforms-to-build }}
VARIANTS: ${{ inputs.variants }}
run: |
IFS=',' read -ra ARR <<< "$PLATFORMS_TO_BUILD"
JSON=$(printf '%s\n' "${ARR[@]}" | jq -R . | jq -sc .)
echo "platforms=$JSON" >> "$GITHUB_OUTPUT"
# variant -> Dockerfile target + LIGHTNINGD_FROM build-arg;
# docker-publish.yml maps it to a tag suffix.
MATRIX=$(jq -nc --arg platforms "$PLATFORMS_TO_BUILD" --argjson variants "$VARIANTS" '
{
"lightningd": {target: "lightningd", from: "source"},
"lightningd-vls-signer": {target: "lightningd-vls-signer", from: "source"},
"lightningd-signed": {target: "lightningd", from: "release"}
} as $known
| [ $variants[] as $v
| ($known[$v] // error("unknown variant \($v)"))
| ($platforms | split(",")[]) as $p
| {variant: $v, target: .target, from: .from, platform: $p} ]')
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"

build:
name: Build ${{ matrix.target == 'lightningd-vls-signer' && 'vls' || 'normal' }} / ${{ matrix.platform }}
name: Build ${{ matrix.variant }} / ${{ matrix.platform }}
needs: plan
strategy:
fail-fast: false
matrix:
target:
- lightningd
- lightningd-vls-signer
platform: ${{ fromJson(needs.plan.outputs.platforms) }}
include: ${{ fromJson(needs.plan.outputs.matrix) }}
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
# Build the tag the image is labelled with.
ref: ${{ inputs.version }}
fetch-depth: 0

- name: Check this release has the signed image
if: matrix.from == 'release'
env:
VERSION: ${{ inputs.version }}
run: |
# An older Dockerfile would silently compile from source.
if [ ! -f tools/verify-release-tarball.sh ]; then
echo "::error::$VERSION predates the -signed image"
exit 1
fi

- name: Set up QEMU
if: matrix.platform == 'linux/arm/v7'
uses: docker/setup-qemu-action@v4
Expand All @@ -68,11 +96,14 @@ jobs:
file: ./Dockerfile
target: ${{ matrix.target }}
platforms: ${{ matrix.platform }}
# release mode fetches the tarballs from the GitHub release.
build-args: |
VERSION=${{ inputs.version }}
LIGHTNINGD_FROM=${{ matrix.from }}
CLN_RELEASE_MIN_SIGNATURES=${{ inputs.min-signatures }}
outputs: type=image,name=${{ inputs.dh-repository-owner }}/lightningd,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.target }}-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.target }}-${{ matrix.platform }}
cache-from: type=gha,scope=${{ matrix.variant }}-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}-${{ matrix.platform }}

- name: Save digest
run: |
Expand All @@ -82,7 +113,7 @@ jobs:
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digest_${{ matrix.target }}_${{ strategy.job-index }}
name: digest_${{ matrix.variant }}_${{ strategy.job-index }}
path: /tmp/digests/digest.txt
if-no-files-found: error
retention-days: 1
74 changes: 74 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
# https://docs.corelightning.org/docs/release-checklist
#
# Run by hand once the release is public: <version> and <version>-vls are
# built from source, <version>-signed from the GPG-signed release tarballs.
name: "Publish Docker images 🐳"
on:
workflow_dispatch:
inputs:
version:
description: 'Published release tag, e.g. v26.06.9'
required: true
variants:
description: 'Images to publish, as a JSON array'
default: '["lightningd", "lightningd-vls-signer", "lightningd-signed"]'
min-signatures:
description: 'Good signatures each SHA256SUMS manifest must carry from keys in contrib/keys'
default: '2'
dh-repository-owner:
description: 'Dockerhub repository owner'
default: 'elementsproject'
platforms-to-build:
description: 'List of platforms to build'
default: 'linux/amd64,linux/arm64,linux/arm/v7'
push-latest:
description: 'Also tag latest, latest-vls, latest-signed'
type: boolean
default: false

jobs:
check-release:
name: Check the release is published
runs-on: ubuntu-24.04
steps:
- name: Release must exist and not be a draft
env:
GH_TOKEN: ${{ github.token }}
# Where the Dockerfile fetches the release from.
GH_REPO: ElementsProject/lightning
VERSION: ${{ inputs.version }}
run: |
# Draft releases serve no assets.
if [ "$(gh release view "$VERSION" --json isDraft --jq .isDraft)" != false ]; then
echo "::error::release $VERSION is a draft or does not exist"
exit 1
fi

docker-build:
name: Docker build
needs: check-release
uses: ./.github/workflows/docker-build.yml
with:
version: ${{ inputs.version }}
dh-repository-owner: ${{ inputs.dh-repository-owner }}
platforms-to-build: ${{ inputs.platforms-to-build }}
variants: ${{ inputs.variants }}
min-signatures: ${{ inputs.min-signatures }}
secrets: inherit

docker-publish:
name: Docker publish
needs: docker-build
# id-token for cosign; a called workflow cannot exceed the caller's.
permissions:
contents: read
actions: read
id-token: write
uses: ./.github/workflows/docker-publish.yml
with:
version: ${{ inputs.version }}
dh-repository-owner: ${{ inputs.dh-repository-owner }}
push-latest: ${{ github.event.inputs.push-latest }}
variants: ${{ inputs.variants }}
secrets: inherit
47 changes: 36 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ on:
push-latest:
type: string
required: true
# JSON array; see docker-build.yml.
variants:
type: string
default: '["lightningd", "lightningd-vls-signer"]'

jobs:
publish:
name: Tag and publish ${{ matrix.target }}
name: Tag and publish ${{ matrix.variant }}
runs-on: ubuntu-22.04
permissions:
contents: read
actions: read
id-token: write # cosign keyless signing
strategy:
fail-fast: false
matrix:
include:
- target: lightningd
tag_suffix: ''
- target: lightningd-vls-signer
tag_suffix: '-vls'
variant: ${{ fromJson(inputs.variants) }}
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
Expand All @@ -38,7 +42,7 @@ jobs:
- name: Download platform digests for this target
uses: actions/download-artifact@v8
with:
pattern: digest_${{ matrix.target }}_*
pattern: digest_${{ matrix.variant }}_*
path: /tmp/digests
merge-multiple: false

Expand All @@ -47,17 +51,24 @@ jobs:
DH_REPOSITORY_OWNER: ${{ inputs.dh-repository-owner }}
PUSH_LATEST: ${{ inputs.push-latest }}
VERSION: ${{ inputs.version }}
REF_TYPE: ${{ github.ref_type }}
VARIANT: ${{ matrix.variant }}
run: |
case "$VARIANT" in
lightningd) TAG_SUFFIX="";;
lightningd-vls-signer) TAG_SUFFIX="-vls";;
lightningd-signed) TAG_SUFFIX="-signed";;
*) echo "unknown variant $VARIANT" >&2; exit 1;;
esac
echo "TAG_SUFFIX=$TAG_SUFFIX" >> $GITHUB_ENV

DIGEST_REFS=""
for f in /tmp/digests/*/digest.txt; do
D=$(cat "$f")
DIGEST_REFS="$DIGEST_REFS ${DH_REPOSITORY_OWNER}/lightningd@${D}"
done
echo "DIGEST_REFS=$DIGEST_REFS" >> $GITHUB_ENV

if [[ "$PUSH_LATEST" == "true" ]] ||
([[ "$REF_TYPE" == "tag" ]] && [[ ! "$VERSION" =~ rc ]]); then
if [[ "$PUSH_LATEST" == "true" ]]; then
echo "PUSHLATEST=true" >> $GITHUB_ENV
else
echo "PUSHLATEST=false" >> $GITHUB_ENV
Expand All @@ -67,10 +78,24 @@ jobs:
env:
DH_REPOSITORY_OWNER: ${{ inputs.dh-repository-owner }}
VERSION: ${{ inputs.version }}
TAG_SUFFIX: ${{ matrix.tag_suffix }}
run: |
TAG_ARGS=(-t "${DH_REPOSITORY_OWNER}/lightningd:${VERSION}${TAG_SUFFIX}")
if [[ "$PUSHLATEST" == "true" ]]; then
TAG_ARGS+=(-t "${DH_REPOSITORY_OWNER}/lightningd:latest${TAG_SUFFIX}")
fi
docker buildx imagetools create "${TAG_ARGS[@]}" $DIGEST_REFS

- name: Install cosign
uses: sigstore/[email protected]

# Keyless, under this workflow's OIDC identity; one signature covers
# every tag of the digest, --recursive the per-platform manifests too.
# Verification: doc/getting-started/getting-started/installation.md
- name: Sign the published image
env:
DH_REPOSITORY_OWNER: ${{ inputs.dh-repository-owner }}
VERSION: ${{ inputs.version }}
run: |
IMAGE="${DH_REPOSITORY_OWNER}/lightningd"
DIGEST=$(docker buildx imagetools inspect "${IMAGE}:${VERSION}${TAG_SUFFIX}" --format '{{.Manifest.Digest}}')
cosign sign --yes --recursive "${IMAGE}@${DIGEST}"
34 changes: 2 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ on:
description: Create a draft release
default: false
type: boolean
dh-repository-owner:
description: 'Dockerhub repository owner'
default: 'elementsproject'
platforms-to-build:
description: 'List of platforms to build'
default: 'linux/amd64,linux/arm64,linux/arm/v7'
push-latest:
description: 'Push the latest Docker tag'
type: boolean
default: false
dist-location:
description: 'PyPI distribution location'
type: choice
Expand All @@ -48,16 +38,6 @@ jobs:
skip_validation: ${{ github.event.inputs.skip_validation == 'true' }}


docker-build:
name: Docker build
needs: check-version
uses: ./.github/workflows/docker-build.yml
with:
version: ${{ needs.check-version.outputs.version }}
dh-repository-owner: ${{ github.event.inputs.dh-repository-owner || 'elementsproject' }}
platforms-to-build: ${{ github.event.inputs.platforms-to-build || 'linux/amd64,linux/arm64,linux/arm/v7' }}
secrets: inherit

pypi-build:
name: PyPI build
needs: check-version
Expand All @@ -77,20 +57,10 @@ jobs:

gate:
name: All builds succeeded
needs: [docker-build, pypi-build, release-build]
needs: [pypi-build, release-build]
runs-on: ubuntu-24.04
steps:
- run: echo "All three build paths succeeded — proceeding to publish."

docker-publish:
name: Docker publish
needs: [check-version, gate]
uses: ./.github/workflows/docker-publish.yml
with:
version: ${{ needs.check-version.outputs.version }}
dh-repository-owner: ${{ github.event.inputs.dh-repository-owner || 'elementsproject' }}
push-latest: ${{ github.event.inputs.push-latest }}
secrets: inherit
- run: echo "All build paths succeeded — proceeding to publish."

pypi-publish:
name: PyPI publish
Expand Down
Loading
Loading