Skip to content

Commit

Permalink
[ci] Refactor release notes release detection
Browse files Browse the repository at this point in the history
Now (hopefully) better automatic detection of types/urls
  • Loading branch information
dennisjbell committed Mar 12, 2022
1 parent 1b69f69 commit e9148b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 60 deletions.
61 changes: 36 additions & 25 deletions ci/scripts/release-notes
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,26 @@ sub get_releases {

my @months = qw(ignored January February March April May June July August September October November December);
sub github {
my ($org, $repo, $tag, $type, $orig_url) = @_;
my ($url, $day, $mon, $year);
my ($org, $repo, $versions, $type, $orig_url) = @_;
my ($url, $day, $mon, $year, $out, $tag);

unless ($org && $repo) {
if ($orig_url =~ m|https://bosh.io/d/github.com/([^/]*)/([^/]*)\?v=(.*)$|) {
$org = $1;
$repo = $2;
} elsif ($orig_url =~ m|https://github.com/([^/]*)/([^/]*)/releases|) {
$org = $1;
$repo = $2;
}
return ("-","-") unless ($org && $repo);
}

# Try release
# Try release - the preferred method
my $lookup_url="https://api.github.com/repos/$org/$repo/releases";
my $out = qx(curl -Ls -u "$ENV{GITHUB_ACCESS_TOKEN}:" "$lookup_url" | jq -r --arg t "$tag" '.[] | select(.tag_name == \$t)');
for $tag (@$versions) {
$out = qx(curl -Ls -u "$ENV{GITHUB_ACCESS_TOKEN}:" "$lookup_url" | jq -r --arg t "$tag" '.[] | select(.tag_name == \$t)');
last if $out;
}
if ($out) {
printf STDERR " - $org/$repo release $tag\n";
my $data = decode_json($out);
Expand All @@ -159,20 +173,26 @@ sub github {
} else {
# Next try tag
my $lookup_url="https://api.github.com/repos/$org/$repo/tags";
my $out = qx(curl -Ls -u "$ENV{GITHUB_ACCESS_TOKEN}:" "$lookup_url");
$out = qx(curl -Ls -u "$ENV{GITHUB_ACCESS_TOKEN}:" "$lookup_url");
my $target_tag;
if ($out) {
printf STDERR " - $org/$repo tag $tag\n";
my $tags = decode_json($out);
my $target_tag = (grep {$_->{name} eq $tag} @$tags)[0];
return ("Tag $tag not found",''); # TBD...
for $tag (@$versions) {
$target_tag = (grep {$_->{name} eq $tag} @$tags)[0];
last if $target_tag;
}
}
if ($target_tag) {
printf STDERR " - $org/$repo tag $tag\n";
my $commit_url = $target_tag->{commit}{url};
$out = qx(curl -Ls -u "$ENV{GITHUB_ACCESS_TOKEN}:" "$commit_url");
my $data = decode_json($out);
(my $url = $data->{html_url}) =~ s#/commit/#/tree/#;
($year, $mon, $day) = ($data->{commit}{author}{date} =~ m/^(\d{4})-(\d{2})-(\d{2})/);

} else {
printf STDERR " - $org/$repo version $tag not found!";
return ("Tag $tag not found",'') unless $out;
return ('-','-');
}
}
return ("$day $months[$mon] $year", $url);
Expand Down Expand Up @@ -224,22 +244,13 @@ sub calculate_software_updates {

$found{$section} ||= {};
unless (defined($found{$section}{"$name/$version"})) {
my ($date,$release_url);
if ($upstream->{$section}{$name}{org} && $upstream->{$section}{$name}{repo}) {
for my $prefix (@prefixes) {
($date,$release_url) = github(
$upstream->{$section}{$name}{org},
$upstream->{$section}{$name}{repo},
$prefix.$version,
$upstream->{$section}{$name}{type},
$upstream->{$section}{$name}{url}
);
last if $release_url;
}
} else {
$date = "";
$release_url = "";
}
my ($date,$release_url) = github(
$upstream->{$section}{$name}{org},
$upstream->{$section}{$name}{repo},
[map {$_.$version} @prefixes],
$upstream->{$section}{$name}{type},
$url
);
$found{$section}{"$name/$version"} = {
name => $name,
version => $version,
Expand Down
35 changes: 0 additions & 35 deletions ci/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,142 +8,107 @@ core:
bpm:
org: cloudfoundry
repo: bpm-release
type: release
capi:
org: cloudfoundry
repo: capi-release
type: release
cf-networking:
org: cloudfoundry
repo: cf-networking-release
type: release
cf-smoke-tests:
org: cloudfoundry
repo: cf-smoke-tests-release
type: release
cflinuxfs3:
org: cloudfoundry
repo: cflinuxfs3-release
type: release
cf-cli:
org: bosh-packages
repo: cf-cli-release
type: release
diego:
org: cloudfoundry
repo: diego-release
type: release
garden-runc:
org: cloudfoundry
repo: garden-runc-release
type: release
loggregator:
org: cloudfoundry
repo: loggregator-release
type: release
loggregator-agent:
org: cloudfoundry
repo: loggregator-agent-release
type: release
log-cache:
org: cloudfoundry
repo: log-cache-release
type: release
nats:
org: cloudfoundry
repo: nats-release
type: release
routing:
org: cloudfoundry
repo: routing-release
type: release
statsd-injector:
org: cloudfoundry
repo: statsd-injector-release
type: release
cf-syslog-drain:
org: cloudfoundry
repo: cf-syslog-drain-release
type: release
uaa:
org: cloudfoundry
repo: uaa-release
type: release
silk:
org: cloudfoundry
repo: silk-release
type: release
bosh-dns-aliases:
org: cloudfoundry
repo: bosh-dns-aliases-release
type: release
cflinuxfs2:
org: cloudfoundry
repo: cflinuxfs2-release
type: release
app-autoscaler:
org: cloudfoundry-incubator
repo: app-autoscaler-release
type: release
nfs-volume:
org: cloudfoundry
repo: nfs-volume-release
type: release
mapfs:
org: cloudfoundry
repo: mapfs-release
type: release
postgres:
org: cloudfoundry-community
repo: postgres-boshrelease
type: release
haproxy:
org: cloudfoundry-incubator
repo: haproxy-boshrelease
type: release

buildpacks:
binary-buildpack:
org: cloudfoundry
repo: binary-buildpack-release
type: release
dotnet-core-buildpack:
org: cloudfoundry
repo: dotnet-core-buildpack-release
type: release
go-buildpack:
org: cloudfoundry
repo: go-buildpack-release
type: release
java-buildpack:
org: cloudfoundry
repo: java-buildpack-release
type: release
nginx-buildpack:
org: cloudfoundry
repo: nginx-buildpack-release
type: release
nodejs-buildpack:
org: cloudfoundry
repo: nodejs-buildpack-release
type: release
php-buildpack:
org: cloudfoundry
repo: php-buildpack-release
type: release
python-buildpack:
org: cloudfoundry
repo: python-buildpack-release
type: release
r-buildpack:
org: cloudfoundry
repo: r-buildpack-release
type: release
ruby-buildpack:
org: cloudfoundry
repo: ruby-buildpack-release
type: release
staticfile-buildpack:
org: cloudfoundry
repo: staticfile-buildpack-release
type: release

0 comments on commit e9148b4

Please sign in to comment.