6 Commits
0.01 ... 1.0.1

Author SHA1 Message Date
Shivam Mathur
08cc68f7fa Merge pull request #4 from shivammathur/develop
Fix reading php version
2020-02-17 21:50:00 +05:30
Shivam Mathur
6efc9a6099 Fix reading php version 2020-02-17 21:45:49 +05:30
Shivam Mathur
ac570d4c61 Merge pull request #2 from shivammathur/develop
1.0.0
2020-02-14 14:46:11 +05:30
Shivam Mathur
7afb25fd18 Simplify inputs 2020-02-14 14:41:53 +05:30
Shivam Mathur
79b498e8b8 Merge pull request #1 from shivammathur/develop
Fix usage workflow in README
2020-02-13 10:23:45 +05:30
Shivam Mathur
584c51c293 Fix usage workflow in README 2020-02-13 10:19:44 +05:30
6 changed files with 41 additions and 53 deletions

View File

@@ -65,13 +65,13 @@ jobs:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
env:
extensions: intl, pcov
key: cache # can be any string
key: cache-v1 # can be any string, change to clear the extension cache.
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-extensions
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
@@ -81,14 +81,14 @@ jobs:
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.extensioninfo.outputs.ext_dir }}
key: ${{ runner.os }}-ext-${{ matrix.php-versions }}-${{ steps.cache-extensions.outputs.ext_hash }}
restore-keys: ${{ runner.os }}-ext-${{ matrix.php-versions }}-${{ steps.cache-extensions.outputs.ext_hash }}
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
```

3
dist/index.js vendored
View File

@@ -1550,7 +1550,8 @@ const utils = __importStar(__webpack_require__(163));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const version = yield utils.getInput('php-version', true);
let version = yield utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const extensions = yield utils.getInput('extensions', true);
const key = yield utils.getInput('key', true);
const script_path = path.join(__dirname, '../src/extensions.sh');

28
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "cache-extensions",
"version": "0.0.1",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -584,9 +584,9 @@
}
},
"@types/babel__core": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz",
"integrity": "sha512-8fBo0UR2CcwWxeX7WIIgJ7lXjasFxoYgRnFHUj+hRvKkpiBJbxhdAPTCY6/ZKM0uxANFVzt4yObSLuTiTnazDA==",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.4.tgz",
"integrity": "sha512-c/5MuRz5HM4aizqL5ViYfW4iEnmfPcfbH4Xa6GgLT21dMc1NGeNnuS6egHheOmP+kCJ9CAzC4pv4SDCWTnRkbg==",
"dev": true,
"requires": {
"@babel/parser": "^7.1.0",
@@ -1324,9 +1324,9 @@
}
},
"compare-versions": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.5.1.tgz",
"integrity": "sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg==",
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz",
"integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==",
"dev": true
},
"component-emitter": {
@@ -2198,9 +2198,9 @@
}
},
"figures": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz",
"integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
"integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
@@ -4384,13 +4384,13 @@
"dev": true
},
"prompts": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.0.tgz",
"integrity": "sha512-NfbbPPg/74fT7wk2XYQ7hAIp9zJyZp5Fu19iRbORqqy1BhtrkZ0fPafBU+7bmn8ie69DpT0R6QpJIN2oisYjJg==",
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.1.tgz",
"integrity": "sha512-qIP2lQyCwYbdzcqHIUi2HAxiWixhoM9OdLCWf8txXsapC/X9YdsCoeyRIXE/GP+Q0J37Q7+XN/MFqbUa7IzXNA==",
"dev": true,
"requires": {
"kleur": "^3.0.3",
"sisteransi": "^1.0.3"
"sisteransi": "^1.0.4"
}
},
"psl": {

View File

@@ -1,6 +1,6 @@
{
"name": "cache-extensions",
"version": "0.0.1",
"version": "1.0.1",
"private": false,
"description": "Cache extensions in GitHub Actions",
"main": "dist/index.js",

View File

@@ -8,7 +8,8 @@ import * as utils from './utils';
*/
export async function run(): Promise<void> {
try {
const version: string = await utils.getInput('php-version', true);
let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const extensions: string = await utils.getInput('extensions', true);
const key: string = await utils.getInput('key', true);
const script_path: string = path.join(__dirname, '../src/extensions.sh');

View File

@@ -1,5 +1,6 @@
linux_extension_dir() {
apiv=$1
old_versions_linux="5.[4-5]"
if [ "$version" = "5.3" ]; then
echo "/home/runner/php/5.3.29/lib/php/extensions/no-debug-non-zts-$apiv"
elif [[ "$version" =~ $old_versions_linux ]]; then
@@ -13,6 +14,7 @@ linux_extension_dir() {
darwin_extension_dir() {
apiv=$1
old_versions_darwin="5.[3-5]"
if [[ "$version" =~ $old_versions_darwin ]]; then
echo "/opt/local/lib/php${version/./}/extensions/no-debug-non-zts-$apiv"
else
@@ -22,30 +24,14 @@ darwin_extension_dir() {
get_apiv() {
case $version in
5.3)
echo "20090626"
;;
5.4)
echo "20100525"
;;
5.5)
echo "20121212"
;;
5.6)
echo "20131226"
;;
7.0)
echo "20151012"
;;
7.1)
echo "20160303"
;;
7.2)
echo "20170718"
;;
7.3)
echo "20180731"
;;
5.3) echo "20090626" ;;
5.4) echo "20100525" ;;
5.5) echo "20121212" ;;
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
php_h="https://raw.githubusercontent.com/php/php-src/master/main/php.h"
@@ -59,21 +45,21 @@ get_apiv() {
}
version=$2
old_versions_linux="5.[4-5]"
old_versions_darwin="5.[3-5]"
extensions=$1
os=$(uname -s)
if [ "$os" = "Linux" ]; then
flags='-Po'
apiv=$(get_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
flags='-Eo'
apiv=$(get_apiv)
dir=$(darwin_extension_dir "$apiv")
else
os="Windows"
dir='C:\\tools\\php\\ext'
fi
hash=$(echo -n "$1" | openssl dgst -sha256 | cut -d ' ' -f 2)
echo "::set-output name=ext_dir::$dir"
echo "::set-output name=ext_hash::$hash"
key="$os"-ext-"$version"-$(echo -n "$extensions" | openssl dgst -sha256 | cut -d ' ' -f 2)
echo "::set-output name=dir::$dir"
echo "::set-output name=key::$key"