Skip to content

Commit

Permalink
Add cache workflow [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur authored Jan 26, 2022
1 parent d2cb825 commit c687c62
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Cache PHP'
on:
workflow_dispatch:
jobs:
cache:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create artifact directory
run: mkdir builds
- name: Fetch files
run: bash scripts/fetch.sh ${{ matrix.php }} builds
- name: Update release
run: |
set -x
assets=()
for asset in ./builds/*; do
assets+=("$asset")
done
for release in php${{ matrix.php }}; do
if ! gh release view "$release"; then
gh release create "$release" "${assets[@]}" -t "$release" -n "$release"
else
gh release upload "$release" "${assets[@]}" --clobber
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 12 additions & 0 deletions scripts/fetch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version=$1
directory=$2
(
cd "$directory" || exit 1
trunk=https://windows.php.net/downloads/releases
semver=$(curl -sL "$trunk"/releases.json | jq -r ".[\"$version\"].version")
if [ "$version" != "${semver%.*}" ]; then
semver=$(curl -sL "$trunk"/archives/ | grep -Po '(?<=HREF=")[^"]*' | grep -Po "$version.[0-9]+" | sort -V | tail -1)
trunk="$trunk"/archives
fi
curl -sL "$trunk" | grep -Po '(?<=HREF=")[^"]*' | grep -E "$semver" | xargs -n 1 -I{} curl -sLO https://windows.php.net/{}
)

0 comments on commit c687c62

Please sign in to comment.