Add discover
This commit is contained in:
@@ -16,12 +16,47 @@ on:
|
||||
default: "false"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
discover:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: archlinux:latest
|
||||
outputs:
|
||||
packages: ${{ steps.list.outputs.packages }}
|
||||
steps:
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
# nodejs is required by JS actions like actions/checkout.
|
||||
pacman -Syu --noconfirm --needed git python nodejs
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: List packages
|
||||
id: list
|
||||
env:
|
||||
ONLY: ${{ github.event.inputs.only }}
|
||||
run: |
|
||||
packages=$(python3 autopackage.py --list-json ${ONLY:+--only $ONLY})
|
||||
echo "packages=$packages" >> "$GITHUB_OUTPUT"
|
||||
echo "Matrix: $packages"
|
||||
|
||||
build:
|
||||
needs: discover
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
container:
|
||||
image: archlinux:latest
|
||||
# makepkg refuses to run as root; we create a build user below.
|
||||
options: --privileged
|
||||
strategy:
|
||||
# Build every package even if one fails.
|
||||
fail-fast: false
|
||||
# Tune to your runner capacity; remove for unlimited parallelism.
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
pkg: ${{ fromJSON(needs.discover.outputs.packages) }}
|
||||
steps:
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
@@ -48,8 +83,8 @@ jobs:
|
||||
AUTOPKG_USER: ${{ github.actor }}
|
||||
AUTOPKG_TOKEN: ${{ secrets.PACKAGE_TOKEN || github.token }}
|
||||
AUTOPKG_REPLACE: ${{ github.event.inputs.replace }}
|
||||
ONLY: ${{ github.event.inputs.only }}
|
||||
PKG: ${{ matrix.pkg }}
|
||||
run: |
|
||||
# -E keeps AUTOPKG_*; force HOME to builder's so cargo/git/etc. can write their caches
|
||||
sudo -E -u builder env HOME=/home/builder \
|
||||
python3 autopackage.py --keep-going ${ONLY:+--only $ONLY}
|
||||
python3 autopackage.py --only "$PKG"
|
||||
|
||||
@@ -19,6 +19,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
@@ -355,6 +356,9 @@ def main(argv: List[str]) -> int:
|
||||
help="Scratch directory for clones/builds")
|
||||
ap.add_argument("--only", nargs="*", default=[],
|
||||
help="Only build these package directory names")
|
||||
ap.add_argument("--list-json", action="store_true",
|
||||
help="Print discovered package names as a JSON array and exit "
|
||||
"(used to build the CI matrix)")
|
||||
ap.add_argument("--cleanbuild", action="store_true",
|
||||
help="Pass --cleanbuild to makepkg")
|
||||
ap.add_argument("--sign", action="store_true",
|
||||
@@ -388,6 +392,11 @@ def main(argv: List[str]) -> int:
|
||||
args = ap.parse_args(argv)
|
||||
cfg = build_config(args)
|
||||
|
||||
if args.list_json:
|
||||
pkgs = discover_packages(cfg, args.only)
|
||||
print(json.dumps([p.name for p in pkgs]))
|
||||
return 0
|
||||
|
||||
pkgs = discover_packages(cfg, args.only)
|
||||
if not pkgs:
|
||||
print("No package directories found.", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user