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

pick up PHP version from composer.json #629

Closed
1 task done
watarukura opened this issue Aug 12, 2022 · 3 comments
Closed
1 task done

pick up PHP version from composer.json #629

watarukura opened this issue Aug 12, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@watarukura
Copy link

Describe the feature

for example actions/setup-go@v3, pick up Golang version from go.mod

steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-go@v3
    with:
      go-version-file: "go.mod"
  - run: go version

I want to pick up PHP version from composer.json, like this

steps:
  - uses: actions/checkout@v3
  - uses: shivammathur/setup-php@v2
    with:
      php-version-file: 'composer.json'
  - run: php --version

composer.json like this

{
  "name": "foo/bar",
  "version": "0.0.1",
  "license": "MIT",
  "require": {
    "php": "^8.0|^8.1"
  }
}

Version

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

Underlying issue

When PHP version up, I must do same change to composer.json and GHA workflow yaml files.

Describe alternatives

Additional context

Are you willing to submit a PR?

I can try!

@watarukura watarukura added the enhancement New feature or request label Aug 12, 2022
@shivammathur
Copy link
Owner

@watarukura

go.mod specifies the exact version, but it can be a range in composer.json.

So it will need another input say php-version-preference which takes an input highest or lowest, or minimum or maximum to resolve the range to an exact version. It can default to the highest version similar to how composer works.

If you would like to work on a PR to add this, please go ahead.

@watarukura watarukura mentioned this issue Aug 31, 2022
7 tasks
@stevelacey
Copy link
Contributor

stevelacey commented Nov 14, 2022

Similar actions like setup-node and setup-python have gone with pulling the version from a standalone file, that'd be great to see here rather than parsing out from composer.json which, as above, could be a range, and confusing.

In addition to allowing the file to be specified via php-version-file, it'd also be good if there was a default file used if version has not been specified any other way e.g. .php-version or .phpenv-version.

Fwiw setup-node supports .nvmrc but does not default to it (and that's kinda annoying). The setup-python action uses .python-version if neither python-version or python-version-file is supplied and that is 👌🏼 when you're using the language across a few actions/steps and simply want consistency.

@TomAdam
Copy link

TomAdam commented Nov 16, 2022

Symfony CLI uses .php-version. Seems as good a choice as any. https://symfony.com/doc/current/setup/symfony_server.html#selecting-a-different-php-version

stevelacey added a commit to stevelacey/setup-php that referenced this issue Jan 29, 2023
stevelacey added a commit to stevelacey/setup-php that referenced this issue Jan 29, 2023
stevelacey added a commit to stevelacey/setup-php that referenced this issue Jan 29, 2023
stevelacey added a commit to stevelacey/setup-php that referenced this issue Jan 29, 2023
@shivammathur shivammathur added the awaiting-release Added/Fixed and tested, awaiting release label Jan 29, 2023
@shivammathur shivammathur removed the awaiting-release Added/Fixed and tested, awaiting release label Feb 22, 2024
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.

5 participants
@stevelacey @watarukura @shivammathur @TomAdam and others