Skip to content

Commit ec71149

Browse files
committed
add github actions script
1 parent 50b333d commit ec71149

File tree

4 files changed

+116
-2
lines changed

4 files changed

+116
-2
lines changed

.github/workflows/php.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Unit-Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'composer.json'
8+
- '**.yml'
9+
10+
jobs:
11+
test:
12+
name: Test on php ${{ matrix.php}} and ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
timeout-minutes: 10
15+
strategy:
16+
fail-fast: true
17+
matrix:
18+
php: [7.3, 7.4] # 7.2,
19+
os: [ubuntu-latest, macOS-latest] # windows-latest,
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Set ENV vars
26+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
27+
run: |
28+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
29+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
30+
31+
- name: Display Env
32+
run: env
33+
34+
# usage refer https://github.com/shivammathur/setup-php
35+
- name: Setup PHP
36+
timeout-minutes: 5
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: ${{ matrix.php}}
40+
tools: pecl, php-cs-fixer, phpunit
41+
extensions: mbstring, dom, fileinfo, mysql, openssl, igbinary, redis # , swoole-4.4.19 #optional, setup extensions
42+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
43+
coverage: none #optional, setup coverage driver: xdebug, none
44+
45+
- name: Install dependencies
46+
run: composer install --no-progress --no-suggest
47+
48+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
49+
# Docs: https://getcomposer.org/doc/articles/scripts.md
50+
51+
- name: Run test suite
52+
run: echo 'hello'

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Tag-release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Test on php ${{ matrix.php}}
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [7.3]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set ENV for github-release
23+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
24+
run: |
25+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
26+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
27+
28+
# usage refer https://github.com/shivammathur/setup-php
29+
- name: Setup PHP
30+
timeout-minutes: 5
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php}}
34+
tools: pecl, php-cs-fixer, phpunit
35+
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
36+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
37+
coverage: none #optional, setup coverage driver: xdebug, none
38+
39+
- name: Install dependencies # eg: v1.0.3
40+
run: |
41+
tag1=${GITHUB_REF#refs/*/}
42+
echo "release tag: ${tag1}"
43+
composer install --no-progress --no-suggest
44+
45+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
46+
# Docs: https://getcomposer.org/doc/articles/scripts.md
47+
48+
- name: Build phar and send to github assets
49+
run: |
50+
echo $RELEASE_TAG
51+
echo $RELEASE_NAME
52+
php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress
53+
php kite-${RELEASE_TAG}.phar -V
54+
55+
# https://github.com/actions/create-release
56+
- uses: meeDamian/github-release@2.0
57+
with:
58+
gzip: false
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
tag: ${{ env.RELEASE_TAG }}
61+
name: ${{ env.RELEASE_TAG }}
62+
files: kite-${{ env.RELEASE_TAG }}.phar

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# system utils
1+
# System Utils
22

33
[![License](https://img.shields.io/packagist/l/toolkit/sys-utils.svg?style=flat-square)](LICENSE)
44
[![Php Version](https://img.shields.io/badge/php-%3E7.1.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/toolkit/sys-utils)

example/proc-editor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
require dirname(__DIR__) . '/test/bootstrap.php';
1111

1212
$editor = 'vim';
13-
\Toolkit\Sys\Proc\ProcWrapper::runEditor($editor, 'test.txt');
13+
Toolkit\Sys\Proc\ProcWrapper::runEditor($editor, 'test.txt');

0 commit comments

Comments
 (0)