zhamao-framework/.github/workflows/increment-build-number.yml
sunxyw 182a4e7b06
Merge pull request #87 from zhamao-robot/doc-regenerate
API 文档重新生成并加入Workflow
2022-04-02 19:15:25 +08:00

66 lines
2.0 KiB
YAML

name: Increment Build Number
on:
pull_request:
branches:
- master
types:
- closed
paths:
- 'src/**.php'
jobs:
incremental-build-number:
if: github.event.pull_request.merged == true
name: Incremental Build Number
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: '8.1'
extensions: swoole, posix, json
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Generate API Docs
run: bin/gendoc
- name: Commit api docs
run: |
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add docs
git commit -m "update api docs"
git push
- name: Increment build number
run: sed -i -r 's/(.*)(\VERSION_ID\s=\s)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' src/ZM/ConsoleApplication.php
- name: Commit build number
run: |
BUILD_ID=$(cat src/ZM/ConsoleApplication.php | grep "VERSION_ID = " | sed 's/[^0-9]//g')
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add src/ZM/ConsoleApplication.php
git commit -m "increment build number (build $BUILD_ID)"
git push