Skip to content

Commit 1693db3

Browse files
committed
Cache PHP post-install
Cache same PHP packages for all versions Refactor workflow Remove bintray and use cloudsmith for build mirror Use latest zstd from homebrew
1 parent 0fd502b commit 1693db3

File tree

12 files changed

+186
-134
lines changed

12 files changed

+186
-134
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 129 deletions
This file was deleted.

.github/workflows/cache.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Cache PHP
2+
on:
3+
- push
4+
- repository_dispatch
5+
- workflow_dispatch
6+
jobs:
7+
cache:
8+
container: ubuntu:${{ matrix.container }}
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
container: [20.04, 18.04, 16.04]
14+
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
15+
if: "!contains(github.event.head_commit.message, 'skip-build')"
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
- name: Install requirements
20+
run: bash src/install-requirements.sh
21+
- name: Set up Homebrew
22+
env:
23+
HOMEBREW_FORCE_HOMEBREW_ON_LINUX: 1
24+
uses: shivammathur/actions/setup-homebrew@shivammathur-patch-git-retry
25+
- name: Install zstd
26+
run: bash src/install-zstd.sh
27+
- name: Configure git
28+
run: bash src/configure-git.sh
29+
- name: Setup PHP
30+
env:
31+
PHP_VERSION: ${{ matrix.php-versions }}
32+
run: bash src/install-php.sh
33+
- name: Build package
34+
env:
35+
GITHUB_WORKSPACE: ${{ github.workspace }}
36+
PHP_VERSION: ${{ matrix.php-versions }}
37+
run: bash src/package.sh
38+
- name: Upload Artifact
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: ${{ matrix.php-versions }}
42+
path: builds
43+
release:
44+
runs-on: ubuntu-latest
45+
needs: cache
46+
steps:
47+
- uses: actions/checkout@v2
48+
- run: mkdir builds
49+
- uses: actions/download-artifact@v2
50+
with:
51+
path: builds
52+
- name: Setup Python
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: 3.x
56+
- name: Install cloudsmith-cli
57+
run: pip install --upgrade cloudsmith-cli
58+
- name: Release
59+
run: bash src/release.sh
60+
env:
61+
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
62+
GITHUB_REPOSITORY: ${{ github.repository }}
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
GITHUB_WORKSPACE: ${{ github.workspace }}

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Shivam Mathur
3+
Copyright (c) 2020-21 Shivam Mathur
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# PHP Ubuntu
22

33
<a href="https://github.com/shivammathur/php-ubuntu" title="PHP Package Cache"><img alt="Build status" src="https://github.com/shivammathur/php-ubuntu/workflows/Cache%20PHP/badge.svg"></a>
4-
<a href="https://github.com/shivammathur/php-ubuntu/blob/main/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
5-
<a href="https://github.com/shivammathur/php-ubuntu/tree/main/builds" title="builds"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.6%20to%208.0-8892BF.svg"></a>
4+
<a href="https://github.com/shivammathur/php-ubuntu/blob/main/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
5+
<a href="https://github.com/shivammathur/php-ubuntu/tree/main/builds" title="builds"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.6%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
6+
<a href="https://cloudsmith.io/~shivammathur/repos/php-ubuntu" title="mirror"><img alt="cloudsmith mirror" src="https://img.shields.io/badge/builds-cloudsmith-blue?logo=cloudsmith"></a>
67

78
> Cache PHP packages for installing on GitHub Actions
89
@@ -13,5 +14,7 @@ The code in this project is licensed under the [MIT license](LICENSE).
1314

1415
## Dependencies
1516

16-
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "ppa:ondrej/php")
1717
- [actions/virtual-environments](https://github.com/actions/virtual-environments "actions/virtual-environments")
18+
- [facebook/zstd](https://github.com/facebook/zstd "facebook/zstd")
19+
- [homebrew/setup-homebrew](https://github.com/Homebrew/actions/tree/master/setup-homebrew "Setup Homebrew")
20+
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "ppa:ondrej/php")

src/configure-git.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set -x
2+
3+
cd / || exit 1
4+
git config --global user.email "[email protected]"
5+
git init
6+
git add /bin /lib /lib64 /sbin /usr /var
7+
find /etc -maxdepth 1 -mindepth 1 -type d -exec git add {} \;
8+
git commit -m "init"

src/install-php.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set -x
2+
3+
cd /tmp || exit
4+
curl -o /tmp/php.sh -sSL https://raw.githubusercontent.com/actions/virtual-environments/main/images/linux/scripts/installers/php.sh
5+
sed -i "s/^php_versions.*/php_versions=$PHP_VERSION/" /tmp/php.sh
6+
sed -i '/ snmp\|php-pear\|composer\|phpunit\|invoke_tests\|source/d' /tmp/php.sh
7+
sudo DEBIAN_FRONTEND=noninteractive bash /tmp/php.sh || true
8+
sudo rm -rf /var/cache/apt/archives/*.deb || true
9+
for extension in ast imagick pcov raphf propro http; do
10+
sudo apt-get install "php$PHP_VERSION-$extension" -y || true
11+
done

src/install-requirements.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set -x
2+
3+
export _APTMGR=apt-get
4+
apt-get update && apt-get install -y curl sudo software-properties-common
5+
add-apt-repository ppa:git-core/ppa
6+
add-apt-repository ppa:apt-fast/stable
7+
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
8+
apt-get update
9+
DEBIAN_FRONTEND=noninteractive apt-get install -y git sudo apt-fast gcc make automake pkg-config shtool snmp

src/install-zstd.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set -x
2+
3+
brew install zstd
4+
zstd -V

src/install.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
get() {
4+
file_path=$1
5+
shift
6+
links=("$@")
7+
for link in "${links[@]}"; do
8+
status_code=$(sudo curl -w "%{http_code}" -o "$file_path" -sL "$link")
9+
[ "$status_code" = "200" ] && break
10+
done
11+
}
12+
13+
install() {
14+
sudo mkdir -p /tmp/php
15+
get /tmp/"$tar_file" "https://github.com/shivammathur/php-ubuntu/releases/latest/download/$tar_file" "https://dl.cloudsmith.io/public/shivammathur/php-ubuntu/raw/files/$tar_file"
16+
sudo tar -I zstd -xf /tmp/"$tar_file" -C /
17+
}
18+
19+
. /etc/lsb-release
20+
version=$1
21+
tar_file=php_"$version"%2Bubuntu"$DISTRIB_RELEASE".tar.zst
22+
install

0 commit comments

Comments
 (0)