ci: add dependency-aware main fastlane [CI SKIP]
This commit is contained in:
1 parent
479f8c25b0
commit
deb5a97802
8 files changed
+412
-21
No files matched your search
+35
-20
@@ -5,10 +5,19 @@ set -euo pipefail
|
||||
arch="${1:?usage: release-linux.sh <amd64|arm64>}"
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
tag="${CI_COMMIT_TAG:-}"
|
||||
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || {
|
||||
echo "release must run from a vMAJOR.MINOR.PATCH tag" >&2
|
||||
exit 2
|
||||
}
|
||||
if [[ -n "$tag" ]]; then
|
||||
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || {
|
||||
echo "release must run from a vMAJOR.MINOR.PATCH tag" >&2
|
||||
exit 2
|
||||
}
|
||||
version="${tag#v}"
|
||||
else
|
||||
[[ "${CI_PIPELINE_EVENT:-}" == push && "${CI_COMMIT_BRANCH:-}" == main ]] || {
|
||||
echo "untagged image builds are restricted to pushes on main" >&2
|
||||
exit 2
|
||||
}
|
||||
version=main
|
||||
fi
|
||||
[[ -n "${ZOT_USERNAME:-}" && -n "${ZOT_SECRET:-}" ]] || {
|
||||
echo "Zot credentials are required" >&2; exit 2;
|
||||
}
|
||||
@@ -17,9 +26,8 @@ case "$arch" in
|
||||
*) echo "unsupported architecture: $arch" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
version="${tag#v}"
|
||||
project_version="$(sed -n 's#.*<Version>\(.*\)</Version>.*#\1#p' "$root/backend/Directory.Build.props" | head -1)"
|
||||
if [[ "$version" != "$project_version" ]]; then
|
||||
if [[ -n "$tag" && "$version" != "$project_version" ]]; then
|
||||
echo "tag version $version does not match project version $project_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -43,7 +51,7 @@ cp -a "$output/." "$container_context/app/"
|
||||
# Woodpecker's local backend isolates HOME per workflow. Keep Buildah's image
|
||||
# store outside that temporary directory so the runtime base image is reusable
|
||||
# across releases. Separate stores avoid concurrent amd64/arm64 writers.
|
||||
buildah_home="/home/justme/woodpecker/buildah-home/$arch"
|
||||
buildah_home="${BUILDAH_HOME:-/home/justme/woodpecker/buildah-home/$arch}"
|
||||
mkdir -p "$buildah_home"
|
||||
export HOME="$buildah_home"
|
||||
|
||||
@@ -66,16 +74,23 @@ buildah bud --tls-verify=true --arch "$arch" \
|
||||
--build-arg "APP_VERSION=$version" \
|
||||
-f "$root/packaging/container/Backend.Containerfile" \
|
||||
-t "$local_image" "$container_context"
|
||||
pushed=false
|
||||
for attempt in 1 2 3; do
|
||||
if buildah push --tls-verify=true "$local_image" "docker://$image:$version-$arch"; then
|
||||
pushed=true
|
||||
break
|
||||
fi
|
||||
if [[ "$attempt" -lt 3 ]]; then
|
||||
echo "Zot push attempt $attempt failed; retrying in 5 seconds" >&2
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
[[ "$pushed" == true ]] || { echo "could not push image to Zot after 3 attempts" >&2; exit 1; }
|
||||
echo "pushed Zot image $image:$version-$arch"
|
||||
push_tag() {
|
||||
local target_tag="$1" pushed=false
|
||||
for attempt in 1 2 3; do
|
||||
if buildah push --tls-verify=true "$local_image" "docker://$image:$target_tag"; then
|
||||
pushed=true
|
||||
break
|
||||
fi
|
||||
if [[ "$attempt" -lt 3 ]]; then
|
||||
echo "Zot push attempt $attempt failed; retrying in 5 seconds" >&2
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
[[ "$pushed" == true ]] || { echo "could not push image to Zot after 3 attempts" >&2; return 1; }
|
||||
echo "pushed Zot image $image:$target_tag"
|
||||
}
|
||||
|
||||
push_tag "$version-$arch"
|
||||
if [[ -z "$tag" ]]; then
|
||||
push_tag "$version"
|
||||
fi
|
||||
Reference in new issue
Block a user