geerlingguy/php-apache-container

Automatically push specific version tags via Travis CI

Closed this issue · 4 comments

I don't want to have to manually push specific PHP version tags (e.g. 5.6.32 or 7.3.1), so I need to write a tiny bit of extra automation in the .travis.yml file which:

  1. Runs the built image:
docker run --rm image/name:latest ...
  1. Gets the PHP version like:
# This seems simplest:
php_version=$(php -r "echo PHP_VERSION;")

# Or this also works...
php_version=$(php -r 'echo phpversion();')
  1. Tags the image with that version and pushes that tag too.

Hmm...

version=$(docker run --rm geerlingguy/php-apache:7.3 bash -c "php -r 'echo phpversion();'")
$ echo $version
7.3.0-1+0~20181206202713.23+stretch~1.gbp076afd

Need to just get major/minor/patch.

This works. Annoyingly long, but it works:

$ php_version=$(docker run --rm geerlingguy/php-apache:7.3 bash -c "php -r 'echo PHP_MAJOR_VERSION . \".\" . PHP_MINOR_VERSION . \".\" . PHP_RELEASE_VERSION;'")
$ echo $php_version
7.3.0

I only needed the PHP_RELEASE_VERSION for tagging purposes (already had major.minor), so the commit above reflects that.

Works!