tighten / phpreleases-action

GitHub action that integrates with the PHP Releases API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Releases Cover Image Release Build Status

PHP Releases Action

Tired of manually keeping your GitHub actions workflow up to date with the PHP support schedule? Use this action to generate an array of supported PHP versions for a GitHub Actions matrix.

By default, this action uses the PHP Releases API to retrieve the PHP versions that are currently supported and formats them for a GitHub Actions matrix. Additional versions can be added to the matrix utilizing the with parameter.

Usage

  # This job will need to run before the job that defines the matrix.
  output_releases:
    name: Generate PHP Releases Array
    # Requires a machine that can execute bash and make http requests.
    runs-on: ubuntu-latest
    # Expose the variable for your dependent job.
    outputs:
      range: ${{ steps.releases.outputs.range }}
    steps:
      - name: Fetch Current Releases
        uses: tighten/phpreleases-action@v1
        id: releases

Create a matrix from the return value

  current_php_releases:
    runs-on: ubuntu-latest
    # The matrix cannot be built before the job has finished.
    needs: output_releases
    strategy:
      matrix:
        # GitHub Actions expression to get the return value.
        php: ${{ fromJSON(needs.output_releases.outputs.range) }}
    name: PHP ${{ matrix.php }}

A full sample is available in this repo's .github/workflows directory.

Add PHP versions that are not included by default

  # This job will need to run before the job that defines the matrix.
  output_releases:
    name: Generate PHP Releases Array
    # Requires a machine that can execute bash and make http requests.
    runs-on: ubuntu-latest
    # Expose the variable for your dependent job.
    outputs:
      range: ${{ steps.releases.outputs.range }}
    steps:
      - name: Fetch Current Releases
        uses: tighten/phpreleases-action@v1
        id: releases
        with:
          # Comma delimited string of all versions that should be included in the matrix.
          releases: '7.4, 7.3'

Example

name: Run Tests

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  output_releases:
    name: Generate PHP Releases Array
    runs-on: ubuntu-latest
    outputs:
      range: ${{ steps.releases.outputs.range }}
    steps:
      - name: Fetch Current Releases
        uses: tighten/phpreleases-action@v1
        id: releases
        with:
          releases: '7.4'
  tests:
    needs: output_releases
    strategy:
      matrix:
        os: [Ubuntu, Windows, macOS]
        php: ${{ fromJSON(needs.output_releases.outputs.range) }}

        include:
        - os: Ubuntu
          os-version: ubuntu-latest

        - os: Windows
          os-version: windows-latest

        - os: macOS
          os-version: macos-latest

    name: ${{ matrix.os }} - PHP ${{ matrix.php }}

    runs-on: ${{ matrix.os-version }}

    steps:
    - name: Checkout code
      uses: actions/checkout@v1

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
          php-version: ${{ matrix.php }}
          extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, bcmath, soap, intl, gd, exif, iconv, imagick

Issues

If you need to report an issue or a feature idea, let us know by opening a GitHub Issue.

Thanks for using the PHP releases GitHub Action!

Contributing

Please see CONTRIBUTING for details.

Credits

Support us

Tighten is a web development firm that works in Laravel, Vue, and React. You can learn more about us on our web site.

License

The MIT License (MIT). Please see License File for more information.

About

GitHub action that integrates with the PHP Releases API.

License:MIT License