Skip to content

Commit 92c7bfa

Browse files
authored
Merge pull request #17842 from MinaProtocol/dkijana/port_publish_fix_master
Port publishing improvements from compatible
2 parents 0782553 + 603e96a commit 92c7bfa

File tree

5 files changed

+97
-8
lines changed

5 files changed

+97
-8
lines changed

buildkite/scripts/release/manager.sh

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ function publish_debian() {
371371
local __dry_run=$8
372372
local __backend=$9
373373
local __debian_repo=${10}
374-
local __debian_sign_key=${11}
374+
local __arch=${11:-DEFAULT_ARCHITECTURE}
375+
local __force_upload_debians=${12:-0}
376+
local __debian_sign_key=${13}
377+
local __new_artifact_name=${14:-""}
375378

376379
get_cached_debian_or_download $__backend $__artifact $__codename "$__network"
377380
local __artifact_full_name
@@ -405,6 +408,7 @@ function publish_debian() {
405408
--names "$DEBIAN_CACHE_FOLDER/$__codename/${__artifact_full_name}_${__target_version}.deb" \
406409
--version $__target_version \
407410
--bucket $__debian_repo \
411+
"$(if [[ $__force_upload_debians == 1 ]]; then echo "--force"; fi)" \
408412
-c $__codename \
409413
-r $__channel \
410414
${__sign_arg[@]}
@@ -558,6 +562,8 @@ function publish_help(){
558562
printf " %-25s %s\n" "--backend" "[string] backend to use for storage. e.g gs,hetzner. default: gs";
559563
printf " %-25s %s\n" "--debian-repo" "[string] debian repository to publish to. default: $DEBIAN_REPO";
560564
printf " %-25s %s\n" "--debian-sign-key" "[string] debian signing key to use. default: lack of presence = no signing";
565+
printf " %-25s %s\n" "--strip-network-from-archive" "[bool] strip network from archive name. E.g mina-archive-devnet -> mina-archive";
566+
printf " %-25s %s\n" "--force-upload-debians" "[bool] force upload debian packages even if they exist already in the repository";
561567
echo ""
562568
echo "Example:"
563569
echo ""
@@ -588,6 +594,9 @@ function publish(){
588594
local __backend="gs"
589595
local __debian_repo=$DEBIAN_REPO
590596
local __debian_sign_key=""
597+
local __strip_network_from_archive=0
598+
local __arch=${DEFAULT_ARCHITECTURE}
599+
local __force_upload_debians=0
591600

592601
while [ ${#} -gt 0 ]; do
593602
error_message="❌ Error: a value is needed for '$1'";
@@ -655,6 +664,18 @@ function publish(){
655664
__debian_sign_key=${2:?$error_message}
656665
shift 2;
657666
;;
667+
--strip-network-from-archive )
668+
__strip_network_from_archive=1
669+
shift 1;
670+
;;
671+
--arch )
672+
__arch=${2:?$error_message}
673+
shift 2;
674+
;;
675+
--force-upload-debians )
676+
__force_upload_debians=1
677+
shift 1;
678+
;;
658679
* )
659680
echo -e "${RED} !! Unknown option: $1${CLEAR}\n";
660681
echo "";
@@ -700,6 +721,9 @@ function publish(){
700721
echo " - Backend: $__backend"
701722
echo " - Debian repo: $__debian_repo"
702723
echo " - Debian sign key: $__debian_sign_key"
724+
echo " - Strip network from archive: $__strip_network_from_archive"
725+
echo " - Architecture: $__arch"
726+
echo " - Force upload debians: $__force_upload_debians"
703727
echo ""
704728

705729
if [[ $__backend != "gs" && $__backend != "hetzner" && $__backend != "local" ]]; then
@@ -739,6 +763,8 @@ function publish(){
739763
$__dry_run \
740764
$__backend \
741765
$__debian_repo \
766+
"$__arch" \
767+
"$__force_upload_debians" \
742768
"$__debian_sign_key"
743769
fi
744770

@@ -749,6 +775,13 @@ function publish(){
749775
;;
750776
mina-archive)
751777
for network in "${__networks_arr[@]}"; do
778+
779+
if [[ $__strip_network_from_archive == 1 ]]; then
780+
new_name="mina-archive"
781+
else
782+
new_name=""
783+
fi
784+
752785
if [[ $__only_dockers == 0 ]]; then
753786
publish_debian $artifact \
754787
$__codename \
@@ -760,7 +793,10 @@ function publish(){
760793
$__dry_run \
761794
$__backend \
762795
$__debian_repo \
763-
"$__debian_sign_key"
796+
"$__arch" \
797+
"$__force_upload_debians" \
798+
"$__debian_sign_key" \
799+
"$new_name"
764800
fi
765801

766802
if [[ $__only_debians == 0 ]]; then
@@ -781,6 +817,8 @@ function publish(){
781817
$__dry_run \
782818
$__backend \
783819
$__debian_repo \
820+
"$__arch" \
821+
"$__force_upload_debians" \
784822
"$__debian_sign_key"
785823
fi
786824

@@ -802,6 +840,8 @@ function publish(){
802840
$__dry_run \
803841
$__backend \
804842
$__debian_repo \
843+
"$__arch" \
844+
"$__force_upload_debians" \
805845
"$__debian_sign_key"
806846
fi
807847

buildkite/src/Command/Packages/Publish.dhall

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ let publish
229229
++ "--target-version ${r.value} "
230230
++ "--codenames ${codenames} "
231231
++ "--only-dockers "
232+
++ "--force-upload-debians "
232233
)
233234
]
234235
, label = "Docker Packages Publishing"

buildkite/src/Jobs/Promote/AutoPromoteNightly.dhall

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ let specs_for_branch =
5656
-> \(channel : DebianChannel.Type)
5757
-> PublishPackages.Spec::{
5858
, artifacts =
59-
[ Artifacts.Type.Daemon
59+
[ Artifacts.Type.LogProc
60+
, Artifacts.Type.Daemon
6061
, Artifacts.Type.Archive
6162
, Artifacts.Type.Rosetta
6263
]
@@ -95,5 +96,8 @@ in Pipeline.build
9596
# PublishPackages.publish
9697
(specs_for_branch "develop" DebianChannel.Type.Develop)
9798
# PublishPackages.publish
98-
(specs_for_branch "master" DebianChannel.Type.Master)
99+
( specs_for_branch
100+
"dkijana/port_publish_fix_master"
101+
DebianChannel.Type.Master
102+
)
99103
}

dockerfiles/stages/3-toolchain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt-get update --yes \
1919
aptly \
2020
apt-transport-https \
2121
apt-utils \
22+
dnsutils \
2223
fakeroot \
2324
gnupg2 \
2425
jq \

scripts/debian/publish.sh

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ RED='\033[0;31m'
77
ARCH=amd64
88
BUCKET=packages.o1test.net
99

10+
# Forcing upload debian even if it exists already
11+
FORCE=0
12+
1013
while [[ "$#" -gt 0 ]]; do case $1 in
1114
-n|--names) DEB_NAMES="$2"; shift;;
1215
-r|--release) DEB_RELEASE="$2"; shift;;
1316
-v|--version) DEB_VERSION="$2"; shift;;
1417
-c|--codename) DEB_CODENAME="$2"; shift;;
1518
-b|--bucket) BUCKET="$2"; shift;;
19+
-f|--force) FORCE=1;;
1620
-s|--sign) SIGN="$2"; shift;;
1721
*) echo "❌ Unknown parameter passed: $1"; exit 1;;
1822
esac; shift; done
@@ -33,6 +37,45 @@ function usage() {
3337
exit 1
3438
}
3539

40+
# Invalidate CloudFront cache for the given bucket or CNAME and paths
41+
# This is to ensure that after uploading new debs, users don't get stale
42+
# package lists from CloudFront cache
43+
# Usage: invalidate_cache [bucket-or-cname] codename
44+
# Example: invalidate_cache nightly.apt.packages.minaprotocol.com bookworm
45+
function invalidate_cache() {
46+
BUCKET_OR_CNAME="${1:-nightly.apt.packages.minaprotocol.com}"
47+
PATHS_TO_INVALIDATE="/dists/$2/*"
48+
49+
echo "🔎 Resolving ${BUCKET_OR_CNAME}..."
50+
CF_DOMAIN=$(dig +short CNAME "${BUCKET_OR_CNAME}" | sed 's/\.$//')
51+
CF_DOMAIN=$(dig +short CNAME "${BUCKET_OR_CNAME}" | sed 's/\.$//')
52+
53+
if [[ -z "$CF_DOMAIN" ]]; then
54+
echo "❌ Could not resolve ${BUCKET_OR_CNAME} to a CloudFront domain."
55+
exit 1
56+
fi
57+
58+
echo "✅ Found CloudFront domain: ${CF_DOMAIN}"
59+
60+
echo "📋 Searching for distribution ID in CloudFront..."
61+
DIST_ID=$(aws cloudfront list-distributions \
62+
--query "DistributionList.Items[?DomainName=='${CF_DOMAIN}'].Id" \
63+
--output text)
64+
65+
if [[ -z "$DIST_ID" ]]; then
66+
echo "❌ No CloudFront distribution found for domain ${CF_DOMAIN}"
67+
exit 1
68+
fi
69+
70+
echo "✅ Found CloudFront distribution ID: ${DIST_ID}"
71+
72+
echo "🚀 Creating invalidation for paths: ${PATHS_TO_INVALIDATE}"
73+
aws cloudfront create-invalidation \
74+
--distribution-id "${DIST_ID}" \
75+
--paths "${PATHS_TO_INVALIDATE}"
76+
}
77+
78+
3679
if [[ -z "$DEB_NAMES" ]]; then usage "❌ Debian(s) to upload are not set!"; fi;
3780
if [[ -z "$DEB_VERSION" ]]; then usage "❌ Version is not set!"; fi;
3881
if [[ -z "$DEB_CODENAME" ]]; then usage "❌ Codename is not set!"; fi;
@@ -54,8 +97,6 @@ else
5497
GPG_OPTS=("--gpg-options=\"--batch" "--pinentry-mode=loopback" "--yes")
5598
fi
5699

57-
58-
59100
echo "Publishing debs: ${DEB_NAMES} to Release: ${DEB_RELEASE} and Codename: ${DEB_CODENAME}"
60101
# Upload the deb files to s3.
61102
# If this fails, attempt to remove the lockfile and retry.
@@ -68,17 +109,19 @@ for _ in {1..10}; do (
68109
#>> Attempting to obtain a lock
69110
#/var/lib/gems/2.3.0/gems/deb-s3-0.10.0/lib/deb/s3/lock.rb:24:in `throw': uncaught throw #"Unable to obtain a lock after 60, giving up."
70111
deb-s3 upload $BUCKET_ARG $S3_REGION_ARG \
71-
--fail-if-exists \
112+
"$([ "$FORCE" -eq 0 ] && echo "--fail-if-exists")" \
72113
--lock \
73114
--preserve-versions \
74-
--cache-control=max-age=120 \
115+
--cache-control "no-store,no-cache,must-revalidate" \
75116
$SIGN_ARG \
76117
--component "${DEB_RELEASE}" \
77118
--codename "${DEB_CODENAME}" \
78119
"${GPG_OPTS[@]}" \
79120
"${DEB_NAMES}"
80121
) && break || (MINA_DEB_BUCKET=${BUCKET} scripts/debian/clear-s3-lockfile.sh); done
81122

123+
invalidate_cache "$BUCKET" "$DEB_CODENAME"
124+
82125
for deb in $DEB_NAMES
83126
do
84127
# extracting name from debian package path. E.g:

0 commit comments

Comments
 (0)