Skip to content

Commit

Permalink
up: update the release action script, and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 7, 2022
1 parent 99c5c8c commit 41b9084
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 58 deletions.
49 changes: 29 additions & 20 deletions .github/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
options:
title: '## Change Log'
style: gh-release
title: '## Change Log'
# style allow: simple, markdown(mkdown), ghr(gh-release)
style: gh-release
# group names
names: [Refactor, Fixed, Feature, Update, Other]
#repo_url: https://github.com/gookit/gcli

filters:
# message length >= 12
- name: msgLen
minLen: 12
# message words >= 3
- name: wordsLen
minLen: 3
# message length should >= 12
- name: msg_len
min_len: 12
# message words should >= 3
- name: words_len
min_len: 3
- name: keyword
keyword: format code
exclude: true
- name: keywords
keywords: ['format code']
keywords: format code, action test
exclude: true

# group match rules
# not matched will use 'Other' group.
groups:
- name: New
keywords: [add, new]
rules:
- name: Refactor
start_withs: [refactor, break]
contains: ['refactor:', 'break:']
- name: Fixed
startWiths: [add, new]
keywords: [add, new]
- name: Feat
startWiths: [feat]
keywords: [feature]
start_withs: [fix]
contains: ['fix:']
- name: Feature
start_withs: [feat, new]
contains: ['feat:', 'new:']
- name: Update
startWiths: [update, 'up:']
keywords: [update]
start_withs: [up]
contains: ['update:', 'up:']
41 changes: 7 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,31 @@ on:

jobs:
release:
name: Test on php ${{ matrix.php}}
name: Tag release
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
php: [8.0]

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set ENV for github-release
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
# usage refer https://github.com/shivammathur/setup-php
- name: Setup PHP
timeout-minutes: 5
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php}}
tools: pecl, php-cs-fixer, phpunit
extensions: mbstring, dom, fileinfo, openssl # , swoole-4.4.19 #optional, setup extensions
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
coverage: none #optional, setup coverage driver: xdebug, none

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Install dependencies
run: |
echo $RELEASE_TAG
echo $RELEASE_NAME
tag1=${GITHUB_REF#refs/*/}
echo "release tag: ${tag1}"
composer update --no-progress
# more see https://github.com/inhere/kite
- name: Generate changelog file
id: changelog
- name: Generate changelog
run: |
wget -c -q https://github.com/inhere/kite/releases/latest/download/kite.phar
php kite.phar git cl prev last --style gh-release --no-merges --fetch-tags --unshallow --file changelog.md
cat changelog.md
curl https://github.com/gookit/gitw/releases/latest/download/chlog-linux-amd64 -L -o /usr/local/bin/chlog
chmod a+x /usr/local/bin/chlog
chlog -c .github/changelog.yml -o changelog.md prev last
# https://github.com/softprops/action-gh-release
- name: Create release and upload assets
uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
[![Latest Stable Version](http://img.shields.io/packagist/v/phppkg/config.svg)](https://packagist.org/packages/phppkg/config)
[![Actions Status](https://github.com/phppkg/easytpl/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/easytpl/actions)

Config load, management, get, set and more.
Config load, management, merge, get, set and more.

- Config data load, management
- Support load multi config data, will auto merge
- Supports INI,JSON,YAML,TOML,NEON,PHP format file
- Support for exporting configuration data to file
- Language data management

> **[中文说明](README.zh-CN.md)**
## Install

**composer**
Expand All @@ -23,7 +27,7 @@ composer require phppkg/config

## Usage

**Config**
create and load config data.

```php
use PhpPkg\Config\ConfigBox;
Expand Down Expand Up @@ -63,7 +67,7 @@ array(7) {
}
```

### Get value
## Get value

```php
/** @var PhpPkg\Config\ConfigBox $config */
Expand All @@ -77,7 +81,27 @@ $config->getInt('arr0.1'); // int(23)
$config->getString('map0.key0'); // string('val0')
```

### More load methods
## Set value

```php
/** @var PhpPkg\Config\ConfigBox $config */
$config->set('name', 'INHERE');
$config->set('map0.key0', 'new value');
```

## Export to file

Export config data to file.

```php
use PhpPkg\Config\ConfigBox;

/** @var ConfigBox $config */
$config->exportTo('/path/to/file.json');
$config->exportTo('/path/to/my.conf', ConfigBox::FORMAT_YAML);
```

## More load methods

- `loadFromFiles(array $filePaths, string $format = '')`
- `loadFromStrings(string $format, string ...$strings)`
Expand Down
118 changes: 118 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Config

[![License](https://img.shields.io/packagist/l/phppkg/config.svg?style=flat-square)](LICENSE)
[![Php Version](https://img.shields.io/badge/php-%3E=8.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/phppkg/config)
[![Latest Stable Version](http://img.shields.io/packagist/v/phppkg/config.svg)](https://packagist.org/packages/phppkg/config)
[![Actions Status](https://github.com/phppkg/easytpl/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/easytpl/actions)

PHP的配置数据加载,管理,获取,支持多种数据格式.

- 配置数据加载,管理,获取
- 支持加载多个配置数据,会自动合并
- 支持 INI,JSON,YAML,TOML,NEON,PHP 等格式的文件内容
- 支持导出整个配置数据到文件
- 简单的多语言配置数据管理

> **[EN README](README.md)**
## 安装

**composer**

- Required PHP 8.0+

```bash
composer require phppkg/config
```

## 快速开始

先创建一个配置实例,就可以加载指定的配置数据了.

```php
use PhpPkg\Config\ConfigBox;

$config = ConfigBox::new();
$config->loadFromFiles([
__DIR__ . '/test/testdata/config.ini',
__DIR__ . '/test/testdata/config.neon',
__DIR__ . '/test/testdata/config.yml',
__DIR__ . '/test/testdata/config.toml',
]);
```

### 查看加载的数据

```php
// dump config
vdump($config->getData());
```

**Output**:

```php
CALL ON PhpPkg\ConfigTest\ConfigBoxTest(24):
array(7) {
["name"]=> string(6) "inhere"
["age"]=> int(89)
["atIni"]=> string(6) "value0"
["arr0"]=> array(3) {
[0]=> string(2) "ab"
[1]=> int(23)
[2]=> string(2) "de"
}
["map0"]=> array(2) {
["key0"]=> string(4) "val0"
["key1"]=> string(4) "val1"
}
["atNeon"]=> string(6) "value1"
["atYaml"]=> string(6) "value2"
["atToml"]=> string(6) "val at toml"
}
```

## 获取值

可以获取指定类型的返回值,同时支持链式key方式获取值

```php
/** @var PhpPkg\Config\ConfigBox $config */
$config->getInt('age'); // int(89)
$config->getString('name'); // string('inhere')
$config->get('arr0');
$config->get('map0');

// get value by key-path.
$config->getInt('arr0.1'); // int(23)
$config->getString('map0.key0'); // string('val0')
```

## 设置值

```php
/** @var PhpPkg\Config\ConfigBox $config */
$config->set('name', 'INHERE');
$config->set('map0.key0', 'new value');
```

## 导出到文件

支持导出整个配置数据到文件.

```php
use PhpPkg\Config\ConfigBox;

/** @var ConfigBox $config */
$config->exportTo('/path/to/file.json');
$config->exportTo('/path/to/my.conf', ConfigBox::FORMAT_YAML);
```

## More load methods

- `loadFromFiles(array $filePaths, string $format = '')`
- `loadFromStrings(string $format, string ...$strings)`
- `loadFromSteam(string $format, resource $stream)`

## License

[MIT](LICENSE)

0 comments on commit 41b9084

Please sign in to comment.