Skip to content

Commit 78077f0

Browse files
authored
Add automatic releases. (#101)
A new phar and ZPK files will be generated on merge in the master branch.
1 parent bf9fac4 commit 78077f0

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Automatic Releases
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-18.04
12+
steps:
13+
- name: Setup PHP 7.1
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '7.1'
17+
18+
- name: Environment
19+
run: |
20+
env
21+
22+
- name: Get Source Code
23+
uses: actions/checkout@v2
24+
25+
- name: Get Composer Dependencies
26+
run: |
27+
composer install --no-dev
28+
# Manually fix the zend-stdlib issue
29+
(cd vendor/zendframework/zend-stdlib/; patch -p1 < ../../../.patches/zend-stdlib.patch)
30+
31+
- name: Build Phar file
32+
run: php -d phar.readonly=0 bin/create-phar.php
33+
34+
- name: Test Phar file
35+
run: |
36+
(cp bin/zs-client.phar /tmp && \
37+
/tmp/zs-client.phar targetFileLocation && \
38+
rm /tmp/zs-client.phar
39+
)
40+
41+
- name: Build ZPK file
42+
run: php ./bin/build-zpk.php
43+
44+
- name: Store compiled Phar and ZPK files
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
if [ "${GITHUB_HEAD_REF}" != "master" ]; then
49+
echo "Not on master branch, skipping upload";
50+
exit 0;
51+
fi
52+
53+
set -x
54+
DIFF=$(git diff bin/zs-client.phar build/ZendServerSDK.zpk)
55+
if [ -n "$DIFF" ]; then
56+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
57+
git config user.email "release@zend.com"
58+
git config user.name "Automated Release"
59+
git stash
60+
git fetch origin ${GITHUB_HEAD_REF}
61+
git checkout ${GITHUB_HEAD_REF}
62+
git stash pop
63+
git commit -a -m "Update phar and zpk"
64+
git push origin ${GITHUB_HEAD_REF}
65+
fi

0 commit comments

Comments
 (0)