* feat: add nu script that generates build matrix for github action * chore: push initial version of new github action for testing * fix: properly close github template sequence * chore: screw this i'll write the whole build in nu (nu build script started, continue later) * fix: individual misspellings and such (yeah, i'm tired) * fix: containerfile path * fix: docker arg syntax * fix: docker build path? * feat: code structure, buildx, pushing to registry * fix: tag image properly * fix: split arguments properly * fix: use registry properly * refactor: move docker build to a separate par-each * feat: correctly tag versioned modules * feat: cosign signing, better logging * fix: cosign syntax * fix: differentiate log types with more expressive colors * chore: fix cosign syntax in logs * fix: capture errors, colocate logs while running paraller * chore: partly revert "fix: capture errors, colocate logs while running paraller" This reverts commit 9238a0f1d68183e712b567fc50849964cc964c78. * chore: bring back capture errors, keep order in logs apparently do --capture-errors is required for nushell to catch external commands errors * chore: Revert "chore: bring back capture errors, keep order in logs" These changes didn't do anything... This reverts commit 020b9a1bce9456f2167397b49aa24a65f6bec8e6. * fix: properly tag images in PRs and secondary branches * fix: use tags-variable instead of "tags" string * chore: change default-flatpaks module folder structure to be versioned * fix: also log generated tags for versioned modules * fix: don't add tags meant for latest image for every version of versioned module * fix: better logging and inline docs * fix: better logging pt2 * feat: build-unified for building the legacy modules container with just the latest versions * fix: correct workflow names * fix: add missing ansi resets * chore: add nushell extension to recommendations * fix: update unified job name Co-authored-by: Gerald Pinder <gmpinder@gmail.com> * chore: remove matrix output left over from a previous version --------- Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
59 lines
No EOL
2.1 KiB
Text
59 lines
No EOL
2.1 KiB
Text
#!/usr/bin/env nu
|
|
# generates modules-latest directory with only latest versions of modules and builds the Containerfile
|
|
|
|
print $"(ansi green_bold)Gathering images(ansi reset)"
|
|
|
|
rm -rf ./modules-latest
|
|
mkdir ./modules-latest
|
|
|
|
ls modules | each { |moduleDir|
|
|
|
|
# module is unversioned
|
|
if ($"($moduleDir.name)/($moduleDir.name | path basename).sh" | path exists) {
|
|
|
|
print $"(ansi cyan)Found(ansi reset) (ansi cyan_bold)unversioned(ansi reset) (ansi cyan)module:(ansi reset) ($moduleDir.name | path basename)"
|
|
|
|
cp --recursive ($moduleDir.name) $"./modules-latest/($moduleDir.name | path basename)"
|
|
|
|
} else { # module is versioned
|
|
|
|
print -n $"(ansi cyan)Found(ansi reset) (ansi blue_bold)versioned(ansi reset) (ansi cyan)module:(ansi reset) ($moduleDir.name | path basename), "
|
|
|
|
let latest = glob $"./($moduleDir.name)/v*" | last # the glob result is already orderer such that the last value is the biggest
|
|
|
|
print $"(ansi blue_bold)Latest version:(ansi reset) ($latest | path basename)"
|
|
|
|
cp --recursive ($latest) $"./modules-latest/($moduleDir.name | path basename)"
|
|
|
|
}
|
|
}
|
|
|
|
print $"(ansi green_bold)Starting image build(ansi reset)"
|
|
|
|
let tags = (
|
|
if ($env.GH_EVENT_NAME != "pull_request" and $env.GH_BRANCH == "main") {
|
|
["latest"]
|
|
} else if ($env.GH_EVENT_NAME != "pull_request") {
|
|
[$env.GH_BRANCH]
|
|
} else {
|
|
[$"pr-($env.GH_PR_NUMBER)"]
|
|
}
|
|
)
|
|
|
|
print $"(ansi green_bold)Generated tags for image:(ansi reset) ($tags | str join ' ')"
|
|
|
|
(docker build .
|
|
-f ./unified.Containerfile
|
|
...($tags | each { |tag| ["-t", $"($env.REGISTRY)/modules:($tag)"] } | flatten) # generate and spread list of tags
|
|
)
|
|
|
|
print $"(ansi cyan)Pushing image:(ansi reset) ($env.REGISTRY)/modules"
|
|
let digest = (
|
|
docker push --all-tags $"($env.REGISTRY)/modules"
|
|
| split row "\n" | last | split row " " | get 2 # parse push output to get digest for signing
|
|
)
|
|
|
|
print $"(ansi cyan)Signing image:(ansi reset) ($env.REGISTRY)/modules@($digest)"
|
|
cosign sign -y --key env://COSIGN_PRIVATE_KEY $"($env.REGISTRY)/modules@($digest)"
|
|
|
|
print $"(ansi green_bold)DONE!(ansi reset)" |