Skip to content

Commit fb74934

Browse files
committed
Fix zstd setup --skip-build-php
1 parent 9fd5c85 commit fb74934

File tree

3 files changed

+57
-11
lines changed

3 files changed

+57
-11
lines changed

.github/workflows/ci.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
done
120120
package:
121121
name: Update dist
122-
if: "!contains(github.event.head_commit.message, 'skip-release')"
122+
if: "always() && !contains(github.event.head_commit.message, 'skip-release')"
123123
needs: test
124124
runs-on: ubuntu-latest
125125
strategy:
@@ -129,9 +129,14 @@ jobs:
129129
steps:
130130
- name: Checkout
131131
uses: actions/checkout@v2
132+
- name: Add ZSTD
133+
env:
134+
REPO: ${{ github.repository }}
135+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
USER: ${{ github.repository_owner }}
137+
run: bash scripts/install-zstd.sh
132138
- name: Package
133139
run: |
134-
bash scripts/install-zstd.sh
135140
mkdir builds
136141
bash scripts/version-files.sh "$PHP_VERSION"
137142
bash scripts/stage.sh "$PHP_VERSION"
@@ -149,7 +154,7 @@ jobs:
149154
path: builds
150155
release:
151156
runs-on: ubuntu-latest
152-
if: "!contains(github.event.head_commit.message, 'skip-release')"
157+
if: "always() && !contains(github.event.head_commit.message, 'skip-release')"
153158
needs: package
154159
steps:
155160
- uses: actions/checkout@v2

.github/workflows/zstd.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Cache ZSTD
2+
on:
3+
- workflow_dispatch
4+
jobs:
5+
cache:
6+
container: ubuntu:${{ matrix.container }}
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
container: [20.04, 18.04, 16.04]
12+
if: "!contains(github.event.head_commit.message, 'skip-build')"
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
- name: Install requirements
17+
run: apt-get update && apt-get install sudo curl make gcc jq unzip -y
18+
- name: Get ZSTD_DIR
19+
id: zstd
20+
run: echo "::set-output name=ZSTD_DIR::$(curl -sL https://github.com/facebook/zstd/releases/latest | grep -Po "zstd-(\d+\.\d+\.\d+)" | head -n 1)"
21+
- name: Add ZSTD
22+
env:
23+
REPO: ${{ github.repository }}
24+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
USER: ${{ github.repository_owner }}
26+
run: bash scripts/install-zstd.sh
27+
- name: Upload zstd Artifact
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: ${{ steps.zstd.outputs.zstd_dir }}-ubuntu${{ matrix.container }}
31+
path: /opt/zstd

scripts/install-zstd.sh

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
if command -v brew >/dev/null; then
2-
export PATH="$HOME/.linuxbrew/bin:$PATH"
3-
echo "export PATH=$HOME/.linuxbrew/bin:\$PATH" >> "$GITHUB_ENV"
4-
brew install zstd >/dev/null 2>&1
1+
sudo mkdir -p /opt/zstd
2+
. /etc/os-release
3+
zstd_dir=$(curl -sL https://github.com/facebook/zstd/releases/latest | grep -Po "zstd-(\d+\.\d+\.\d+)" | head -n 1)
4+
zstd_url=$(curl -sL https://api.github.com/repos/"$REPO"/actions/artifacts | jq -r --arg zstd_dir "$zstd_dir-ubuntu$VERSION_ID" '.artifacts[] | select(.name=="\($zstd_dir)").archive_download_url' 2>/dev/null | head -n 1)
5+
if [ "x$zstd_url" = "x" ]; then
6+
sudo apt-get install zlib1g liblzma-dev liblz4-dev -y
7+
curl -o /tmp/zstd.tar.gz -sL https://github.com/facebook/zstd/releases/latest/download/"$zstd_dir".tar.gz
8+
tar -xzf /tmp/zstd.tar.gz -C /tmp
9+
(
10+
cd /tmp/"$zstd_dir" || exit 1
11+
sudo make install -j"$(nproc)" PREFIX=/opt/zstd
12+
)
513
else
6-
curl -sSLO http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-10/gcc-10-base_10-20200411-0ubuntu1_amd64.deb
7-
curl -sSLO http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-10/libgcc-s1_10-20200411-0ubuntu1_amd64.deb
8-
curl -sSLO http://archive.ubuntu.com/ubuntu/pool/universe/libz/libzstd/zstd_1.4.4+dfsg-3_amd64.deb
9-
sudo DEBIAN_FRONTEND=noninteractive dpkg -i --force-conflicts ./*.deb && rm -rf ./*.deb
14+
curl -u "$USER":"$TOKEN" -o /tmp/zstd.zip -sL "$zstd_url"
15+
ls /tmp
16+
sudo unzip /tmp/zstd.zip -d /opt/zstd
17+
sudo chmod -R a+x /opt/zstd/bin
1018
fi
19+
sudo ln -sf /opt/zstd/bin/* /usr/local/bin
20+
rm -rf /tmp/zstd*
1121
zstd -V

0 commit comments

Comments
 (0)