Major updates, now adds timestamps for stable tags, also creates a few dozen more types of tags and calculates non-patch tags for future use
This commit is contained in:
parent
df2057c032
commit
c47bb9a3c8
5 changed files with 118 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
output/
|
output/
|
||||||
|
.env
|
||||||
|
|
|
@ -11,7 +11,7 @@ steps:
|
||||||
- tar -xvJf output.tar.xz
|
- tar -xvJf output.tar.xz
|
||||||
- cpanm --installdeps .
|
- cpanm --installdeps .
|
||||||
- docker login -u simcop2387 -p $GITEA_DOCKER_TOKEN gitea.simcop2387.info
|
- docker login -u simcop2387 -p $GITEA_DOCKER_TOKEN gitea.simcop2387.info
|
||||||
- perl build.pl
|
- perl build.pl --suffix ${CI_PIPELINE_STARTED}
|
||||||
secrets: [gitea_docker_token]
|
secrets: [gitea_docker_token]
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
87
build.pl
87
build.pl
|
@ -17,13 +17,36 @@ use Time::Piece;
|
||||||
|
|
||||||
my @bases = qw/bullseye-backports bookworm-backports/;
|
my @bases = qw/bullseye-backports bookworm-backports/;
|
||||||
my @options = ("main", "main-threaded", "main-longdouble", "main-quadmath", "main-debugging", "main-longdouble-threaded", "main-quadmath-threaded", "main-debugging-threaded", "main-debugging-longdouble-threaded", "main-debugging-quadmath-threaded", "main-debugging-longdouble", "main-debugging-quadmath");
|
my @options = ("main", "main-threaded", "main-longdouble", "main-quadmath", "main-debugging", "main-longdouble-threaded", "main-quadmath-threaded", "main-debugging-threaded", "main-debugging-longdouble-threaded", "main-debugging-quadmath-threaded", "main-debugging-longdouble", "main-debugging-quadmath");
|
||||||
my @versions = ("5.20.3", "5.22.4", "5.24.4", "5.26.3", "5.28.3", "5.30.3", "5.32.1", "5.34.0", "5.34.1", "5.36.0");
|
my @versions = ("5.20.3", "5.22.4", "5.24.4", "5.26.3", "5.28.3", "5.30.3", "5.32.1", "5.34.0", "5.34.1", "5.36.0", "5.36.1", "5.38.0");
|
||||||
my $max_workers = 8;
|
my $max_workers = 8;
|
||||||
my $verbose = 1;
|
my $verbose = 1;
|
||||||
my $suffix = "";
|
my $suffix = "";
|
||||||
my $push_repo = "gitea.simcop2387.info/simcop2387/perl-container";
|
my $push_repo = "gitea.simcop2387.info/simcop2387/perl-container";
|
||||||
my $arch = 'amd64';
|
my $arch = 'amd64';
|
||||||
my %build_args = ();
|
my %build_args = ();
|
||||||
|
my $skip_build = 0;
|
||||||
|
|
||||||
|
my %major_versions = (
|
||||||
|
5.10 => '5.10.1',
|
||||||
|
5.12 => '5.12.5',
|
||||||
|
5.14 => '5.14.4',
|
||||||
|
5.16 => '5.16.3',
|
||||||
|
5.18 => '5.18.4',
|
||||||
|
5.20 => '5.20.3',
|
||||||
|
5.22 => '5.22.4',
|
||||||
|
5.24 => '5.24.4',
|
||||||
|
5.26 => '5.26.3',
|
||||||
|
5.28 => '5.28.3',
|
||||||
|
5.30 => '5.30.3',
|
||||||
|
5.32 => '5.32.1',
|
||||||
|
5.34 => '5.34.1',
|
||||||
|
5.36 => '5.36.1',
|
||||||
|
5.38 => '5.38.0',
|
||||||
|
);
|
||||||
|
|
||||||
|
my $filter_tags_str = '.';
|
||||||
|
|
||||||
|
my $commit_ref = $ENV{CI_COMMIT_REF} // 'unknown';
|
||||||
|
|
||||||
GetOptions('verbose' => \$verbose,
|
GetOptions('verbose' => \$verbose,
|
||||||
'quiet' => sub {$verbose = 0},
|
'quiet' => sub {$verbose = 0},
|
||||||
|
@ -32,8 +55,12 @@ GetOptions('verbose' => \$verbose,
|
||||||
'push_repo=s' => \$push_repo,
|
'push_repo=s' => \$push_repo,
|
||||||
'arch=s' => \$arch,
|
'arch=s' => \$arch,
|
||||||
'build_args=s%' => \%build_args,
|
'build_args=s%' => \%build_args,
|
||||||
|
'skip_build' => \$skip_build,
|
||||||
|
'filter_tags=s' => \$filter_tags_str,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $filter_tags_re = qr/$filter_tags_str/;
|
||||||
|
|
||||||
my $arch_suffix="-$arch";
|
my $arch_suffix="-$arch";
|
||||||
|
|
||||||
if ($suffix) {
|
if ($suffix) {
|
||||||
|
@ -42,6 +69,31 @@ if ($suffix) {
|
||||||
|
|
||||||
my $loop = IO::Async::Loop::Epoll->new();
|
my $loop = IO::Async::Loop::Epoll->new();
|
||||||
|
|
||||||
|
sub get_tags {
|
||||||
|
my ($version, $options, $os_base, $suffix, $arch_suffix) = @_;
|
||||||
|
|
||||||
|
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
||||||
|
my $short_version = "$+{major}.$+{minor}";
|
||||||
|
|
||||||
|
my @t = (
|
||||||
|
"$version-$options-$os_base$suffix$arch_suffix", "$expanded_version-$options-$os_base$suffix$arch_suffix",
|
||||||
|
"$version-$options-$os_base$suffix", "$expanded_version-$options-$os_base$suffix",
|
||||||
|
"$version-$options-$os_base$arch_suffix", "$expanded_version-$options-$os_base$arch_suffix",
|
||||||
|
"$version-$options-$os_base", "$expanded_version-$options-$os_base",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (grep {$version eq $_} values %major_versions) {
|
||||||
|
push @t, (
|
||||||
|
"$short_version-$options-$os_base$suffix$arch_suffix",
|
||||||
|
"$short_version-$options-$os_base$suffix",
|
||||||
|
"$short_version-$options-$os_base$arch_suffix",
|
||||||
|
"$short_version-$options-$os_base"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return \@t;
|
||||||
|
}
|
||||||
|
|
||||||
sub get_ts {
|
sub get_ts {
|
||||||
my $t = time();
|
my $t = time();
|
||||||
|
|
||||||
|
@ -72,6 +124,8 @@ sub run_cmd {
|
||||||
|
|
||||||
print "Running command $disp_prefix ".$cmd->[0], "\n";
|
print "Running command $disp_prefix ".$cmd->[0], "\n";
|
||||||
|
|
||||||
|
return if $skip_build;
|
||||||
|
|
||||||
my $handle = IPC::Run::start $cmd, \$input, \$raw_out, \$raw_err; # no timeout here, that's part of the ::Function
|
my $handle = IPC::Run::start $cmd, \$input, \$raw_out, \$raw_err; # no timeout here, that's part of the ::Function
|
||||||
|
|
||||||
while ($handle->pumpable) {
|
while ($handle->pumpable) {
|
||||||
|
@ -110,8 +164,7 @@ my $builder = IO::Async::Function->new(
|
||||||
try {
|
try {
|
||||||
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
||||||
|
|
||||||
# TODO other calcs for image names
|
my $tags = get_tags($version, $options, $os_base, $suffix, $arch_suffix);
|
||||||
my $tags = ["${push_repo}:$version-$options-$os_base$suffix$arch_suffix", "${push_repo}:$expanded_version-$options-$os_base$suffix$arch_suffix"];
|
|
||||||
|
|
||||||
my $build_date = Time::Piece::gmtime()->datetime();
|
my $build_date = Time::Piece::gmtime()->datetime();
|
||||||
|
|
||||||
|
@ -123,8 +176,8 @@ my $builder = IO::Async::Function->new(
|
||||||
"org.opencontainers.image.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
"org.opencontainers.image.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
"org.label-schema.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
"org.label-schema.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
"org.label-schema.usage"=> "https://gitea.simcop2387.info/simcop2387/docker-perl",
|
"org.label-schema.usage"=> "https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
"org.opencontainers.image.revision"=>$ENV{CI_COMMIT_REF},
|
"org.opencontainers.image.revision"=>$commit_ref,
|
||||||
"org.label-schema.vcs-ref"=> $ENV{CI_COMMIT_REF},
|
"org.label-schema.vcs-ref"=> $commit_ref,
|
||||||
"org.label-schema.version"=> $version,
|
"org.label-schema.version"=> $version,
|
||||||
"org.label-schema.name"=> "perl-$options",
|
"org.label-schema.name"=> "perl-$options",
|
||||||
"org.label-schema.schema-version"=> "1.0",
|
"org.label-schema.schema-version"=> "1.0",
|
||||||
|
@ -141,13 +194,13 @@ my $builder = IO::Async::Function->new(
|
||||||
|
|
||||||
if ($workdir->exists()) {
|
if ($workdir->exists()) {
|
||||||
chdir($workdir);
|
chdir($workdir);
|
||||||
my @tag_args = map {("-t", $_)} @$tags;
|
my @tag_args = map {("-t", "${push_repo}:$_")} @$tags;
|
||||||
my @labels = map {my $k=$_; my $v=$labels{$k}; ("--label", "$k=$v")} keys %labels;
|
my @labels = map {my $k=$_; my $v=$labels{$k}; ("--label", "$k=$v")} keys %labels;
|
||||||
my @buildargs = map {my $k=$_; my $v=$build_args{$k}; ("--build-arg", "$k=$v")} keys %build_args;
|
my @buildargs = map {my $k=$_; my $v=$build_args{$k}; ("--build-arg", "$k=$v")} keys %build_args;
|
||||||
|
|
||||||
my $cmd = [qw(docker buildx build --rm=true -f Dockerfile ./ --push --pull=true), @buildargs, @tag_args, @labels];
|
my $cmd = [qw(docker buildx build --rm=true -f Dockerfile ./ --push --pull=true), @buildargs, @tag_args, @labels];
|
||||||
use Data::Dumper;
|
|
||||||
print Dumper($cmd);
|
print "tags: [", join(', ', @$tags), "]\n";
|
||||||
|
|
||||||
my ($output, $error, $retval) = run_cmd($cmd, $tags->[0], $log_fh, "");
|
my ($output, $error, $retval) = run_cmd($cmd, $tags->[0], $log_fh, "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,11 +238,19 @@ ALL: for my $version (@versions) {
|
||||||
# print "---> $count\n";
|
# print "---> $count\n";
|
||||||
# last ALL if $count++ == 10;
|
# last ALL if $count++ == 10;
|
||||||
|
|
||||||
my $rend = "$version-$option-$base";
|
my $tags = get_tags($version, $option, $base, $suffix, $arch_suffix);
|
||||||
my $future = $builder->call(args => [$version, $option, $base])->on_ready(sub {
|
|
||||||
delete $calls{$rend};
|
if (grep {$_ =~ /$filter_tags_re/} @$tags) {
|
||||||
});
|
|
||||||
$calls{$rend} = $future;
|
|
||||||
|
my $rend = "$version-$option-$base";
|
||||||
|
my $future = $builder->call(args => [$version, $option, $base])->on_ready(sub {
|
||||||
|
delete $calls{$rend};
|
||||||
|
});
|
||||||
|
$calls{$rend} = $future;
|
||||||
|
} else {
|
||||||
|
print "Not building $version-$option-$base due to filter\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
clean_gitea.sh
Executable file
26
clean_gitea.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# comment out when not dev
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
source .env
|
||||||
|
|
||||||
|
# Let this also get pulled from a secret value if needed
|
||||||
|
GITEA_DOCKER_CLEANER_TOKEN=${GITEA_DOCKER_CLEANER_TOKEN:-$SECRET_DOCKER_CLEANER_TOKEN}
|
||||||
|
|
||||||
|
for page in $(seq 30 -1 1); do
|
||||||
|
PACK_LIST=$(curl --silent -X 'GET' 'https://gitea.simcop2387.info/api/v1/packages/simcop2387?limit=100&page='$page'&type=container&q=perl-container&token='$GITEA_DOCKER_CLEANER_TOKEN -H 'accept: application/json')
|
||||||
|
|
||||||
|
if [[ $PACK_LIST != "[]" ]]; then
|
||||||
|
|
||||||
|
for version in $(echo $PACK_LIST | jq -r '.[].version'); do
|
||||||
|
echo $version
|
||||||
|
curl -X 'DELETE' 'https://gitea.simcop2387.info/api/v1/packages/simcop2387/container/perl-container/'$version'?token='$GITEA_DOCKER_CLEANER_TOKEN -H 'accept: application/json'
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
16
config.yml
16
config.yml
|
@ -89,3 +89,19 @@ releases:
|
||||||
debian_release:
|
debian_release:
|
||||||
- bookworm-backports
|
- bookworm-backports
|
||||||
- bullseye-backports
|
- bullseye-backports
|
||||||
|
|
||||||
|
- version: 5.36.1
|
||||||
|
sha256: bd91217ea8a8c8b81f21ebbb6cefdf0d13ae532013f944cdece2cd51aef4b6a7
|
||||||
|
run_tests: no
|
||||||
|
type: xz
|
||||||
|
debian_release:
|
||||||
|
- bookworm-backports
|
||||||
|
- bullseye-backports
|
||||||
|
|
||||||
|
- version: 5.38.0
|
||||||
|
sha256: eca551caec3bc549a4e590c0015003790bdd1a604ffe19cc78ee631d51f7072e
|
||||||
|
run_tests: no
|
||||||
|
type: xz
|
||||||
|
debian_release:
|
||||||
|
- bookworm-backports
|
||||||
|
- bullseye-backports
|
||||||
|
|
Loading…
Add table
Reference in a new issue