Last active
May 12, 2023 20:48
-
-
Save kphrx/3b201cb88ad9e2bb70c571f2a7955803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my $current = `docker buildx version`; | |
use POSIX qw(uname); | |
my @uname = uname(); | |
my $os = lc($uname[0]); | |
my $arch = $uname[4]; | |
my %arch_map = ( | |
aarch64 => 'arm64', | |
armv6 => 'arm-v6', | |
armv7 => 'arm-v6', | |
x86_64 => 'amd64' | |
); | |
$arch = exists $arch_map{$arch} ? $arch_map{$arch} : $arch; | |
use JSON::PP; | |
my $latest = `curl -sL https://api.github.com/repos/docker/buildx/releases/latest`; | |
$latest = decode_json($latest); | |
$current =~ /(?<Version>v?(?:0|(?:[1-9]\d*))(?:\.(?:0|(?:[1-9]\d*))(?:\.(?:0|(?:[1-9]\d*)))?(?:\-(?:[0-9A-Z\.-]+))?(?:\+(?:[0-9A-Z\.-]+))?)?)/; | |
print "Docker buildx version: Current: $+{Version}, Latest: $latest->{tag_name}\n"; | |
if ("$+{Version}" eq "$latest->{tag_name}") { | |
print "up to date\n"; exit 0; | |
} | |
foreach my $asset (@{$latest->{assets}}) { | |
if ("$asset->{name}" eq "buildx-$latest->{tag_name}.${os}-${arch}") { | |
print "Download URL: $asset->{browser_download_url}\n"; | |
next; | |
} | |
if ("$asset->{name}" eq "buildx-$latest->{tag_name}.${os}-${arch}.sha256") { | |
print "Checksum URL: $asset->{browser_download_url}\n"; | |
next; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my $current = `docker compose version`; | |
use POSIX qw(uname); | |
my @uname = uname(); | |
my $os = lc($uname[0]); | |
my $arch = $uname[4]; | |
use JSON::PP; | |
my $latest = `curl -sL https://api.github.com/repos/docker/compose/releases/latest`; | |
$latest = decode_json($latest); | |
$current =~ /(?<Version>v?(?:0|(?:[1-9]\d*))(?:\.(?:0|(?:[1-9]\d*))(?:\.(?:0|(?:[1-9]\d*)))?(?:\-(?:[0-9A-Z\.-]+))?(?:\+(?:[0-9A-Z\.-]+))?)?)/; | |
print "Docker Compose version: Current: $+{Version}, Latest: $latest->{tag_name}\n"; | |
if ("$+{Version}" eq "$latest->{tag_name}") { | |
print "up to date\n"; exit 0; | |
} | |
foreach my $asset (@{$latest->{assets}}) { | |
if ("$asset->{name}" eq "docker-compose-${os}-${arch}") { | |
print "Download URL: $asset->{browser_download_url}\n"; | |
next; | |
} | |
if ("$asset->{name}" eq "docker-compose-${os}-${arch}.sha256") { | |
print "Checksum URL: $asset->{browser_download_url}\n"; | |
next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment