From 822752e57ad9da7f0cf0fb967d75f4a94900296c Mon Sep 17 00:00:00 2001 From: jvolkening Date: Sat, 10 Feb 2024 00:26:10 -0600 Subject: [PATCH] add version check to CI deploy --- .github/workflows/tests.yml | 1 + Build.PL | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f8a057b..198bd7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,6 +64,7 @@ jobs: submodules: recursive - run: perl -V - run: cpanm --notest --installdeps --verbose . + - run: cpanm MetaCPAN::Client - run: perl Build.PL - run: ./Build - run: ./Build deploy diff --git a/Build.PL b/Build.PL index 5208814..ba129b7 100644 --- a/Build.PL +++ b/Build.PL @@ -10,9 +10,21 @@ my $deployer = Module::Build->subclass( sub ACTION_deploy { require CPAN::Uploader; + require MetaCPAN::Client; + use version; + my $self = shift; $self->depends_on("dist"); + # check that this is a newer version + my $name = $self->dist_name; + my $mpan = MetaCPAN::Client->new(); + my $existing = $mpan->release($name)->version; + if (version->parse($existing) >= version->parse($self->dist_version)) { + warn "This version is <= the version on CPAN, aborting nicely\n"; + return 1; + } + my $tarball = $self->dist_dir() . '.tar.gz'; die "tarball not found" if (! -e $tarball);