build: allow specific upstream versions to be ignored (#217)

This commit is contained in:
Markus Küffner
2025-07-05 20:34:40 +02:00
committed by GitHub
parent 706dcb6a80
commit 7121c94889
4 changed files with 73 additions and 48 deletions

View File

@@ -23,7 +23,7 @@ venv/bin/pip install -r scripts/build/requirements.txt
Usage description: Usage description:
```bash ```bash
$ python scripts/build/build.py --help $ python scripts/build/build.py --help
usage: Build [-h] [--backfill BACKFILL] [--registry REGISTRY] [--platform PLATFORM] [--push] [--dry-run] [--force] [--version VERSION] [--upstream UPSTREAM] app usage: Build [-h] [--backfill BACKFILL] [--registry REGISTRY] [--platform PLATFORM] [--push] [--dry-run] [--force] [--version VERSION] [--upstream UPSTREAM] [--suffix SUFFIX] [--config CONFIG] app
Build container images for prind Build container images for prind
@@ -40,4 +40,6 @@ options:
--force Build images even though they exist in the registry [default: False] --force Build images even though they exist in the registry [default: False]
--version VERSION Which upstream Ref to build. Will overwrite automatic Version extraction from upstream --version VERSION Which upstream Ref to build. Will overwrite automatic Version extraction from upstream
--upstream UPSTREAM Overwrite upstream Repo Url. Will skip Url extraction from Dockerfile --upstream UPSTREAM Overwrite upstream Repo Url. Will skip Url extraction from Dockerfile
--suffix SUFFIX Suffix to add after the image tag. Skips the creation of the 'latest' tag
--config CONFIG Path to the build.yaml file
``` ```

View File

@@ -10,6 +10,7 @@ import os
import re import re
import git import git
import sys import sys
import yaml
import getpass import getpass
import logging import logging
import argparse import argparse
@@ -33,6 +34,7 @@ parser.add_argument("--force",action="store_true",default=False,help="Build imag
parser.add_argument("--version",help="Which upstream Ref to build. Will overwrite automatic Version extraction from upstream") parser.add_argument("--version",help="Which upstream Ref to build. Will overwrite automatic Version extraction from upstream")
parser.add_argument("--upstream",help="Overwrite upstream Repo Url. Will skip Url extraction from Dockerfile") parser.add_argument("--upstream",help="Overwrite upstream Repo Url. Will skip Url extraction from Dockerfile")
parser.add_argument("--suffix",help="Suffix to add after the image tag. Skips the creation of the 'latest' tag") parser.add_argument("--suffix",help="Suffix to add after the image tag. Skips the creation of the 'latest' tag")
parser.add_argument("--config",help="Path to the build.yaml file",default="scripts/build/build.yaml")
args = parser.parse_args() args = parser.parse_args()
#--- #---
@@ -45,6 +47,11 @@ ch = logging.StreamHandler()
ch.setFormatter(formatter) ch.setFormatter(formatter)
logger.addHandler(ch) logger.addHandler(ch)
#---
# Read config
with open(args.config,"r") as file:
cfg = yaml.safe_load(file)
#--- #---
# static definitions # static definitions
context = "docker/" + args.app context = "docker/" + args.app
@@ -56,7 +63,8 @@ build = {
"summary": { "summary": {
"success": [], "success": [],
"failure": [], "failure": [],
"skipped": [] "skipped": [],
"ignored": []
}, },
"labels": { "labels": {
"org.prind.version": os.environ.get("GITHUB_SHA",(git.Repo(search_parent_directories=True)).head.object.hexsha), "org.prind.version": os.environ.get("GITHUB_SHA",(git.Repo(search_parent_directories=True)).head.object.hexsha),
@@ -127,6 +135,13 @@ else:
#--- #---
# Build all targets for all versions # Build all targets for all versions
for version in build["versions"].keys(): for version in build["versions"].keys():
# Check if specific version is in ignore list
if version in cfg["ignore"].get(args.app, []):
logger.warning("Version " + version + " will be ignored as configured in " + args.config)
build["summary"]["ignored"].append(version)
else:
for target in build["targets"]: for target in build["targets"]:
# Create list of docker tags # Create list of docker tags

7
scripts/build/build.yaml Normal file
View File

@@ -0,0 +1,7 @@
# This is a basic configuration file for build.py
# Ignore specific refs when building images
# This is helpful is upstream tags contain a bug that prevents the automated build system to succeed
ignore:
klipperscreen:
- v0.4.6 # https://github.com/KlipperScreen/KlipperScreen/commit/c520390fe459865eb96361bd04944d61cde27cf9#commitcomment-161345136

View File

@@ -1,2 +1,3 @@
GitPython==3.1.44 GitPython==3.1.44
python-on-whales==0.77.0 python-on-whales==0.77.0
PyYAML==6.0.2