Skip to content

Commit

Permalink
Add test and release workflows
Browse files Browse the repository at this point in the history
Remove Travis CI config, which wasn't working anymore. The test workflow
tests Perls 5.8 - 5.36 on Linux, macOS, and Windows. The release
workflow uses a custom Build.PL targets to build a list of changes and
to print the name of the tarball for releasing on GitHub. Requires
GitHub secrets `CPAN_PASSWORD` and `CPAN_USERNAME` to release on CPAN.
  • Loading branch information
theory committed May 9, 2023
1 parent b86fa5d commit 61e1dad
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 45 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ✅ CI
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
perl: [ '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12', '5.10', '5.8' ]
name: 🐪 Perl ${{ matrix.perl }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
env:
AUTHOR_TESTING: 1
RELEASE_TESTING: 1
- name: Build and Test
# Have to build on Windows to get scripts\psql.bat.
run: |
perl -V
cpanm --notest --installdeps . # https://github.com/Perl-Toolchain-Gang/extutils-pl2bat/issues/7
perl Build.PL
perl Build code
prove -lv t
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🚀 Release
on:
push:
tags: [v*]
jobs:
release:
name: 🚀 Release
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Setup Perl
uses: shogo82148/actions-setup-perl@v1
- name: Install Release Dependencies
run: cpanm -qn Module::Build CPAN::Uploader

# CPAN
- name: Package the Release
id: package
run: perl Build.PL && ./Build manifest && ./Build dist && echo "tarball=$(./Build tarball_name)" >> $GITHUB_OUTPUT
- name: Generate Release Changes
run: ./Build latest_changes
- name: Release on CPAN
env:
CPANPASS: ${{ secrets.CPAN_PASSWORD }}
CPANUSER: ${{ secrets.CPAN_USERNAME }}
run: cpan-upload --user "$CPANUSER" --password "$CPANPASS" '${{ steps.package.outputs.tarball }}'

# GitHub
- name: Create GitHub Release
id: release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: latest_changes.md
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./${{ steps.package.outputs.tarball }}
asset_name: ${{ steps.package.outputs.tarball }}
asset_content_type: application/gzip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/Build
/Makefile*
/pm_to_blib
/latest_changes.md
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

28 changes: 27 additions & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,33 @@ use strict;
use warnings;
use Module::Build;

Module::Build->new(
my $class = Module::Build->subclass(
class => 'My::Builder',
code => q{
sub ACTION_tarball_name { print shift->dist_dir . ".tar.gz\n" }
sub ACTION_latest_changes {
my $self = shift;
(my $dv = $self->dist_version) =~ s/^v//;
open my $in, '<:raw', 'Changes' or die "Cannot open Changes: $!\n";
open my $out, '>:raw', 'latest_changes.md' or die "Cannot open latest_changes.md: $!\n";
while (<$in>) { last if /^\Q$dv\E\b/ }
print {$out} "Changes for v$dv\n";
while (<$in>) {
last if /^\s*$/;
chomp;
if (s/^\s+-/- /) {
print {$out} "\n";
} else {
s/^\s+/ /;
}
print {$out} $_;
}
$self->add_to_cleanup('latest_changes.md');
}
},
);

$class->new(
module_name => 'URI::db',
license => 'perl',
configure_requires => { 'Module::Build' => '0.30', },
Expand Down

0 comments on commit 61e1dad

Please sign in to comment.