Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PHP version "latest" #293

Closed
1 task done
marekdedic opened this issue Sep 20, 2020 · 5 comments · Fixed by #300
Closed
1 task done

Add support for PHP version "latest" #293

marekdedic opened this issue Sep 20, 2020 · 5 comments · Fixed by #300
Assignees
Labels
enhancement New feature or request

Comments

@marekdedic
Copy link

Describe the feature
Hi, for some of my GH action runs, I'd like them to run on the latest PHP (7.4 at the time of writing), without having to think about updating it in the config every time a new version is released. I imagined I would be able to specify php-version: latest, but according to the documentation, it's not so.

I would even propose making it the default choice, but that's up to you...

Version

  • I have checked releases and the feature is missing in the latest patch version of v2.

Underlying issue
Having to remember to update the PHP version every year

Describe alternatives
Doing it by hand...

Are you willing to submit a PR?
Yes, if I know the feature is considered merge-able. But someone would probably have to maintain this...

@marekdedic marekdedic added the enhancement New feature or request label Sep 20, 2020
@shivammathur
Copy link
Owner

I did not add aliases like latest for PHP versions specifically because it would not be a good practice. With aliases deprecation warning with minor releases can be missed as the workflow continues to run successfully unattended until it breaks when a major version is released.

That said, if you want to do this, here is how -

  • In a single job, do not specify php-version input, it will default currently to 7.4

For example: setup default version

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    extensions: intl  #inputs other than php-version
  • In a matrix job, use null in the matrix for php versions and specify inputs using env instead of with.

For example to have a workflow with 7.3 and the default (7.4)

strategy:
  matrix:      
    php-versions: [7.3, null]
- name: Setup PHP
  uses: shivammathur/setup-php@v2
  env:
    php-version: ${{ matrix.php-version }}

@marekdedic
Copy link
Author

Hi,
well, yes and no - For things like unit tests, I wouldn't use it, but for things like building a library, where PHP is just a runtime, I see no issue with it...

I noticed the field having a default in action.yml, but it's also marked as required, wouldn't it cause an issue to omit it?

Thanks!

@shivammathur
Copy link
Owner

ok,
Although It won't have any issues to use null as it would be valid YAML. It uses the default value when php-version is not specified or it is null.

I will add support for latest in next release as that would make sense.

@shivammathur
Copy link
Owner

@marekdedic latest will work now

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  env:
    php-version: latest

@marekdedic
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants