Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Perl with Makefile.PL release and test

name: CI Makefile

# Run the tests and build the distribution on a recent version of Perl.
# Store the distribution as an artifact.
# Use the artifact on various versions of Perl both in a Docker image
# and natively on macOS, Linux, and Windows to see if it can be installed.

on:
    push:
    pull_request:
    workflow_dispatch:

    # Optionally enable scheduled run
    #schedule:
    #    - cron: '42 5 * * 0'

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: perldocker/perl-tester:5.42
      # https://hub.docker.com/r/perldocker/perl-tester
    name: Build
    steps:
      - uses: actions/checkout@v6

      - name: Install dependencies
        run: |
            cpanm --installdeps --notest .

      - name: Run tests
        run: |
            perl Makefile.PL
            make
            make test

      - name: Create release
        run: |
            # Add 1 digit at the beginning to increase the version number
            # So we can verify we are installing this version and not one from CPAN.
            perl -i -p -e "s/VERSION\s*=\s*'([\d.]+)'/VERSION = '1\1'/" $(find lib | grep pm$)
            perl Makefile.PL
            make
            make manifest
            make dist
            ls -l

      - name: Archive artifacts
        uses: actions/upload-artifact@v6
        with:
          name: the-release
          path: |
            *.tar.gz


  test-on-clean-perl:
    runs-on: ubuntu-latest
    needs: build

    strategy:
      fail-fast: false
      matrix:
        perl-version:
          - "5.42"
          - "5.40"
          - "5.38"
          - "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"

    container:
      image: perl:${{ matrix.perl-version }}

    name: Test on ${{ matrix.perl-version }}
    steps:
      - name: Download a single artifact
        uses: actions/download-artifact@v7
        with:
          name: the-release

      - name: Show Perl version
        run: |
            perl -v
            ls -l *.tar.gz

      - name: Install Module
        run: |
            cpanm --verbose *.tar.gz

      - name: Print module version
        run: |
            perl -MApp -E 'say $App::VERSION'

  native:
    needs: build
    strategy:
      fail-fast: false
      matrix:
        runner:
          - ubuntu-latest
          - macos-latest
          - windows-latest
        perl:
          - '5.32'

    runs-on: ${{matrix.runner}}
    name: Native on OS ${{matrix.runner}} Perl ${{matrix.perl}}

    steps:
      - name: Download a single artifact
        uses: actions/download-artifact@v7
        with:
          name: the-release

      - name: Set up perl
        uses: shogo82148/actions-setup-perl@v1
        with:
            perl-version: ${{ matrix.perl }}
            distribution: ${{ ( startsWith( matrix.runner, 'windows-' ) && 'strawberry' ) || 'default' }}

      - name: Install Module on Windows
        if: ${{ startsWith( matrix.runner, 'windows-' )  }}
        run: |
            perl -v

            Set-Content -NoNewline "cpanm --verbose " install.bat
            Get-ChildItem -Name $App* >> install.bat
            dir
            type install.bat
            .\install.bat

      - name: Install Module on Linux and OSX
        if: ${{ ! startsWith( matrix.runner, 'windows-' )  }}
        run: |
          cpanm --verbose *.tar.gz

      - name: Print module version
        run: |
          perl -MApp -E 'say $App::VERSION'


repository