Compare commits
2 Commits
a0cfdfa8a5
...
be9542f9e3
Author | SHA1 | Date | |
---|---|---|---|
be9542f9e3 | |||
6af44ffa98 |
|
@ -37,19 +37,24 @@ image_tag_norm() {
|
|||
## misc CI things
|
||||
# CI_COMMIT_SHORT_SHA="${CI_COMMIT_SHA:0:8}"
|
||||
CI_COMMIT_SHORT_SHA=$(printf '%s' "${CI_COMMIT_SHA}" | cut -c 1-8)
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_BRANCH}")"
|
||||
if [ -n "${CI_COMMIT_BRANCH}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_BRANCH}")"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_SOURCE_BRANCH}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_SOURCE_BRANCH}")"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_TAG}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_TAG}")"
|
||||
fi
|
||||
|
||||
## image tag(s)
|
||||
IMAGE_TAG="${CI_COMMIT_SHORT_SHA}-b${CI_PIPELINE_NUMBER}-${CI_COMMIT_REF_SLUG}"
|
||||
EXTRA_TAGS=$(image_tag_norm "branch-${CI_COMMIT_BRANCH}")
|
||||
if [ -n "${CI_COMMIT_TAG}" ] ; then
|
||||
IMAGE_TAG="${CI_COMMIT_TAG}"
|
||||
unset EXTRA_TAGS
|
||||
IMAGE_TAG="${CI_COMMIT_SHORT_SHA}"
|
||||
EXTRA_TAGS="${CI_COMMIT_REF_SLUG}"
|
||||
## TODO: think about "latest" tag: it should be error-prone for "backward tag push"
|
||||
# EXTRA_TAGS='latest'
|
||||
# EXTRA_TAGS="${CI_COMMIT_REF_SLUG} latest"
|
||||
else
|
||||
if [ -n "${CI_COMMIT_SOURCE_BRANCH}" ] ; then
|
||||
echo "Running on branch '${CI_COMMIT_SOURCE_BRANCH}'"
|
||||
|
|
|
@ -10,6 +10,11 @@ set -ef
|
|||
## produce _real_ BASE_IMAGE because "static-debian12:debug-nonroot" is not multiarch image (yet)
|
||||
export BASE_IMAGE="${BASE_IMAGE:?}-${GOARCH:?}"
|
||||
|
||||
buildah pull \
|
||||
--platform "${TARGET_PLATFORM}" \
|
||||
--retry 3 --retry-delay 30s \
|
||||
"${BASE_IMAGE}"
|
||||
|
||||
## build image
|
||||
buildah bud \
|
||||
-t "${IMAGE_NAME}:${IMAGE_TAG}${PLATFORM_SUFFIX}" \
|
||||
|
|
|
@ -20,20 +20,25 @@ rm -rf "${oci_dir}" ; mkdir "${oci_dir}"
|
|||
|
||||
r=0
|
||||
|
||||
img_copy() { skopeo copy --retry-times 3 --all "$@" ; }
|
||||
|
||||
while : ; do
|
||||
skopeo copy --all "${image_src}:${IMAGE_TAG}" "${image_interim}" || r=$?
|
||||
img_copy "${image_src}:${IMAGE_TAG}" "${image_interim}" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
skopeo copy --all "${image_interim}" "${image_dst}:${IMAGE_TAG}" || r=$?
|
||||
echo " -> ${image_dst}:${IMAGE_TAG}"
|
||||
img_copy "${image_interim}" "${image_dst}:${IMAGE_TAG}" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
for tag in ${EXTRA_TAGS} ; do
|
||||
[ -n "${tag}" ] || continue
|
||||
|
||||
skopeo copy --all "${image_interim}" "${image_src}:${tag}" || r=$?
|
||||
echo " -> ${image_src}:${tag}"
|
||||
img_copy "${image_interim}" "${image_src}:${tag}" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
skopeo copy --all "${image_interim}" "${image_dst}:${tag}" || r=$?
|
||||
echo " -> ${image_dst}:${tag}"
|
||||
img_copy "${image_interim}" "${image_dst}:${tag}" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
done
|
||||
|
||||
|
|
|
@ -4,4 +4,3 @@ publish-nexus*
|
|||
.ci/*
|
||||
.woodpecker/*
|
||||
.woodpecker.yml
|
||||
dist/*
|
||||
|
|
3
Makefile
3
Makefile
|
@ -46,6 +46,9 @@ $(OUTBIN):
|
|||
echo "!!! git information is asbent !!!" >&2 ; \
|
||||
GO_BUILDFLAGS="-buildvcs=false $${GO_BUILDFLAGS}" ; \
|
||||
fi ; \
|
||||
for i in $$(seq 1 3) ; do \
|
||||
if $(GO) get ; then break ; fi ; \
|
||||
done ; \
|
||||
$(GO) build -o $@ \
|
||||
$${GO_BUILDFLAGS} \
|
||||
$(if $(strip $(TAGS)),-tags '$(strip $(TAGS))') \
|
||||
|
|
Loading…
Reference in New Issue
Block a user