12
README.md
12
README.md
@@ -65,13 +65,13 @@ jobs:
|
|||||||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
||||||
env:
|
env:
|
||||||
extensions: intl, pcov
|
extensions: intl, pcov
|
||||||
key: cache # can be any string
|
key: cache-v1 # can be any string, change to clear the extension cache.
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup cache environment
|
- name: Setup cache environment
|
||||||
id: cache-extensions
|
id: cache-env
|
||||||
uses: shivammathur/cache-extensions@v1
|
uses: shivammathur/cache-extensions@v1
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
@@ -81,14 +81,14 @@ jobs:
|
|||||||
- name: Cache extensions
|
- name: Cache extensions
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.cache-extensions.outputs.ext_dir }}
|
path: ${{ steps.cache-env.outputs.dir }}
|
||||||
key: ${{ runner.os }}-ext-${{ matrix.php-versions }}-${{ steps.cache-extensions.outputs.ext_hash }}
|
key: ${{ steps.cache-env.outputs.key }}
|
||||||
restore-keys: ${{ runner.os }}-ext-${{ matrix.php-versions }}-${{ steps.cache-extensions.outputs.ext_hash }}
|
restore-keys: ${{ steps.cache-env.outputs.key }}
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: ${{ env.extensions }}
|
extensions: ${{ env.extensions }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache-extensions",
|
"name": "cache-extensions",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache-extensions",
|
"name": "cache-extensions",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Cache extensions in GitHub Actions",
|
"description": "Cache extensions in GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
linux_extension_dir() {
|
linux_extension_dir() {
|
||||||
apiv=$1
|
apiv=$1
|
||||||
|
old_versions_linux="5.[4-5]"
|
||||||
if [ "$version" = "5.3" ]; then
|
if [ "$version" = "5.3" ]; then
|
||||||
echo "/home/runner/php/5.3.29/lib/php/extensions/no-debug-non-zts-$apiv"
|
echo "/home/runner/php/5.3.29/lib/php/extensions/no-debug-non-zts-$apiv"
|
||||||
elif [[ "$version" =~ $old_versions_linux ]]; then
|
elif [[ "$version" =~ $old_versions_linux ]]; then
|
||||||
@@ -13,6 +14,7 @@ linux_extension_dir() {
|
|||||||
|
|
||||||
darwin_extension_dir() {
|
darwin_extension_dir() {
|
||||||
apiv=$1
|
apiv=$1
|
||||||
|
old_versions_darwin="5.[3-5]"
|
||||||
if [[ "$version" =~ $old_versions_darwin ]]; then
|
if [[ "$version" =~ $old_versions_darwin ]]; then
|
||||||
echo "/opt/local/lib/php${version/./}/extensions/no-debug-non-zts-$apiv"
|
echo "/opt/local/lib/php${version/./}/extensions/no-debug-non-zts-$apiv"
|
||||||
else
|
else
|
||||||
@@ -22,30 +24,14 @@ darwin_extension_dir() {
|
|||||||
|
|
||||||
get_apiv() {
|
get_apiv() {
|
||||||
case $version in
|
case $version in
|
||||||
5.3)
|
5.3) echo "20090626" ;;
|
||||||
echo "20090626"
|
5.4) echo "20100525" ;;
|
||||||
;;
|
5.5) echo "20121212" ;;
|
||||||
5.4)
|
5.6) echo "20131226" ;;
|
||||||
echo "20100525"
|
7.0) echo "20151012" ;;
|
||||||
;;
|
7.1) echo "20160303" ;;
|
||||||
5.5)
|
7.2) echo "20170718" ;;
|
||||||
echo "20121212"
|
7.3) echo "20180731" ;;
|
||||||
;;
|
|
||||||
5.6)
|
|
||||||
echo "20131226"
|
|
||||||
;;
|
|
||||||
7.0)
|
|
||||||
echo "20151012"
|
|
||||||
;;
|
|
||||||
7.1)
|
|
||||||
echo "20160303"
|
|
||||||
;;
|
|
||||||
7.2)
|
|
||||||
echo "20170718"
|
|
||||||
;;
|
|
||||||
7.3)
|
|
||||||
echo "20180731"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
if [ "$version" = "8.0" ]; then
|
if [ "$version" = "8.0" ]; then
|
||||||
php_h="https://raw.githubusercontent.com/php/php-src/master/main/php.h"
|
php_h="https://raw.githubusercontent.com/php/php-src/master/main/php.h"
|
||||||
@@ -59,21 +45,21 @@ get_apiv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
version=$2
|
version=$2
|
||||||
old_versions_linux="5.[4-5]"
|
extensions=$1
|
||||||
old_versions_darwin="5.[3-5]"
|
|
||||||
os=$(uname -s)
|
os=$(uname -s)
|
||||||
if [ "$os" = "Linux" ]; then
|
if [ "$os" = "Linux" ]; then
|
||||||
flags='-Po'
|
flags='-Po'
|
||||||
apiv=$(get_apiv)
|
apiv=$(get_apiv)
|
||||||
dir=$(linux_extension_dir "$apiv")
|
dir=$(linux_extension_dir "$apiv")
|
||||||
sudo mkdir -p "$dir" && sudo chown -R "$USER":"$(id -g -n)" $(dirname "$dir")
|
sudo mkdir -p "$dir" && sudo chown -R "$USER":"$(id -g -n)" "$(dirname "$dir")"
|
||||||
elif [ "$os" = "Darwin" ]; then
|
elif [ "$os" = "Darwin" ]; then
|
||||||
flags='-Eo'
|
flags='-Eo'
|
||||||
apiv=$(get_apiv)
|
apiv=$(get_apiv)
|
||||||
dir=$(darwin_extension_dir "$apiv")
|
dir=$(darwin_extension_dir "$apiv")
|
||||||
else
|
else
|
||||||
|
os="Windows"
|
||||||
dir='C:\\tools\\php\\ext'
|
dir='C:\\tools\\php\\ext'
|
||||||
fi
|
fi
|
||||||
hash=$(echo -n "$1" | openssl dgst -sha256 | cut -d ' ' -f 2)
|
key="$os"-ext-"$version"-$(echo -n "$extensions" | openssl dgst -sha256 | cut -d ' ' -f 2)
|
||||||
echo "::set-output name=ext_dir::$dir"
|
echo "::set-output name=dir::$dir"
|
||||||
echo "::set-output name=ext_hash::$hash"
|
echo "::set-output name=key::$key"
|
||||||
Reference in New Issue
Block a user