From 50bfcb65e3b2ac9ec8522ce4b733e3c3e77ebf97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 16 Apr 2021 12:33:41 +0200 Subject: [PATCH] Update release builder (#1616) * Fix composer.json CS * Update release builder * Update release builder for UI * Add missing "version" to composer for develop * Prepare for release --- .../{release-drafter.yml => build-docs.yml} | 6 +- .github/workflows/build-release.yml | 83 +++++++++ .github/workflows/bundler.yml | 79 -------- .github/workflows/test-unit.yml | 3 +- composer.json | 172 +++++++++--------- 5 files changed, 174 insertions(+), 169 deletions(-) rename .github/workflows/{release-drafter.yml => build-docs.yml} (53%) create mode 100644 .github/workflows/build-release.yml delete mode 100644 .github/workflows/bundler.yml diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/build-docs.yml similarity index 53% rename from .github/workflows/release-drafter.yml rename to .github/workflows/build-docs.yml index 21a37882d0..ab60038a44 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/build-docs.yml @@ -1,4 +1,4 @@ -name: Release Drafter +name: Build Docs on: push: @@ -9,7 +9,7 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: toolmantim/release-drafter@v5.6.1 + - name: Run Release Drafter + uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000000..485e36edf1 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,83 @@ +name: Build Release + +on: + push: + branches: + - '**\.build/*' + - 'release/*' + - '!**\.gen' + +jobs: + autocommit: + name: Build Release + runs-on: ubuntu-latest + container: + image: atk4/image:latest-npm + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + + - name: Target variables - discover + id: target + run: | + echo "::set-output name=version_name::$(echo '${{ github.ref }}' | sed -E 's~.+/~~')" + + - name: Target variables - show + run: | + echo "Target Version: ${{ steps.target.outputs.version_name }}" + if ! echo "${{ steps.target.outputs.version_name }}" | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+'; then echo "ERROR: Version must have [0-9].[0-9].[0-9] format!"; exit 1 ; fi + + - name: Install PHP dependencies + run: composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader + + - name: Composer unset version + run: composer config version --unset + + - name: Update composer.json + run: >- + php -r ' + $f = __DIR__ . "/composer.json"; + $data = json_decode(file_get_contents($f), true); + foreach ($data as $k => $v) { + if (preg_match("~^(.+)-release$~", $k, $matches)) { + $data[$matches[1]] = $data[$k]; unset($data[$k]); + } + } + $str = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n"; + echo $str; + file_put_contents($f, $str); + ' + + - name: Composer validate config + run: composer validate --strict --no-check-lock && composer normalize --dry-run --no-check-lock + + - name: Update version in src/App.php + run: | + sed -i "s|public \$version.*|public \$version = '${{ steps.target.outputs.version_name }}';|" src/App.php + + - name: Install JS dependencies + run: | + npm install --loglevel=error -g pug-cli less less-plugin-clean-css uglify-js + (cd js && npm ci --loglevel=error) + + - name: Compile JS and CSS files for CDN + run: | + (cd js && npm run build) + sed -i "s~'https://raw.githack.com/atk4/ui/develop/public.*~'/public',~" src/App.php + + lessc public/agileui.less public/agileui.css --clean-css="--s1 --advanced" --source-map + echo '!/agileui.css.map' >> public/.gitignore + + - name: Commit + run: | + git config --global user.name "$(git show -s --format='%an')" + git config --global user.email "$(git show -s --format='%ae')" + git add -A && git diff --staged && git commit -m "Build Release \"${{ steps.target.outputs.version_name }}\"" + + - name: Push + uses: ad-m/github-push-action@master + with: + branch: ${{ github.ref }}.gen + force: true + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/bundler.yml b/.github/workflows/bundler.yml deleted file mode 100644 index bce1daa7c9..0000000000 --- a/.github/workflows/bundler.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Bundler - -on: create - -jobs: - autocommit: - name: Update to stable dependencies - if: startsWith(github.ref, 'refs/heads/release/') - runs-on: ubuntu-latest - container: - image: atk4/image:latest - steps: - - uses: actions/checkout@master - - name: Update CDN destination - shell: bash - run: | - v=$(echo ${{ github.ref }} | cut -d / -f 4) - echo "::set-env name=version::$v" - - git branch - #sed -i "s|'https://raw.githack.com/atk4/ui/develop/public.*|'https://cdn.jsdelivr.net/gh/atk4/ui@$v/public',|" src/App.php - # it was develop, it can stay develop for DEVELOP branch, so we see changes to JS right away. - - # Set next version for develop branch - a=( ${v//./ } ) - nv=${a[0]}"."$(( ${a[1]} +1 ))".0-BETA" - sed -i "s|public \$version.*|public \$version = '$nv';|" src/App.php - git config --global user.email "bundler@agiletoolkit.org" - git config --global user.name "Release Bundler" - git commit -am "Update versions for develop" - - - uses: ad-m/github-push-action@master - with: - branch: feature/${{ env.version }}-version-update - force: true # in case of repeat run - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: pull-request - uses: romaninsh/pull-request@master - with: - source_branch: feature/${{ env.version }}-version-update - destination_branch: develop - pr_title: "Update to next version after release of @${{ env.version }}" - pr_body: | - Compiled JS files from last release are here: - - https://cdn.jsdelivr.net/gh/atk4/ui@${{ env.version }}/public/ - - pr_reviewer: "romaninsh" - pr_assignee: "romaninsh" - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Update to stable dependencies - run: | - # replaces X keys with X-release keys - jq '. as $in | reduce (keys_unsorted[] | select(endswith("-release")|not)) as $k ({}; . + {($k) : (($k + "-release") as $kr | $in | if has($kr) then .[$kr] else .[$k] end) } )' < composer.json > tmp && mv tmp composer.json - composer config version --unset - - - name: Compile JS files for CDN - shell: bash - run: | - - # Update version for the release branch - v=$(echo ${{ github.ref }} | cut -d / -f 4) - sed -i "s|public \$version.*|public \$version = '$v.0';|" src/App.php - npm install -g less-plugin-clean-css - (cd js; npm ci; npm run build; cd ..) - lessc public/agileui.less public/agileui.css --clean-css="--s1 --advanced" --source-map - echo '!agileui.css.map' >> public/.gitignore - git add public - git config --global user.email "bundler@agiletoolkit.org" - git config --global user.name "Release Bundler" - git commit -am "Releasing $v.0" - echo "If everything is good and CI/CD pass - please manually create tag $v.0 on this commit ^^" - - - uses: ad-m/github-push-action@master - with: - branch: ${{ github.ref }} - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 7e3636440c..2ee441e962 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -184,7 +184,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['latest'] + php: ['latest-npm'] type: ['Chrome', 'Firefox', 'Chrome Lowest', 'Chrome Slow'] env: LOG_COVERAGE: '' @@ -220,7 +220,6 @@ jobs: - name: Install JS dependencies (only for Slow) if: matrix.type == 'Chrome Slow' run: | - apk add npm npm install --loglevel=error -g pug-cli less less-plugin-clean-css uglify-js (cd js && npm ci --loglevel=error) diff --git a/composer.json b/composer.json index a0c3f82156..0668414c8d 100644 --- a/composer.json +++ b/composer.json @@ -1,93 +1,95 @@ { - "name": "atk4/ui", - "type": "library", - "description": "Agile UI - Web Component Framework written in PHP", - "keywords": [ - "framework", - "ui", - "web", - "form", - "component", - "widget", - "render", - "gadget", - "button", - "grid", - "crud" - ], - "homepage": "https://github.com/atk4/ui", - "license": "MIT", - "authors": [ - { - "name": "Romans Malinovskis", - "email": "romans@agiletoolkit.org", - "homepage": "https://nearly.guru/" + "name": "atk4/ui", + "type": "library", + "description": "Agile UI - Web Component Framework written in PHP", + "keywords": [ + "framework", + "ui", + "web", + "form", + "component", + "widget", + "render", + "gadget", + "button", + "grid", + "crud" + ], + "homepage": "https://github.com/atk4/ui", + "version": "dev-develop", + "license": "MIT", + "authors": [ + { + "name": "Romans Malinovskis", + "email": "romans@agiletoolkit.org", + "homepage": "https://nearly.guru/" + }, + { + "name": "Alain Belair", + "homepage": "https://agiletoolkit.org/" + }, + { + "name": "Imants Horsts", + "homepage": "https://darkside.lv/" + }, + { + "name": "Francesco Danti", + "homepage": "https://oracoltech.com/" + }, + { + "name": "Michael Voříšek", + "homepage": "https://mvorisek.cz/" + }, + { + "name": "Philipp Grashoff" + }, + { + "name": "Alex Cicovic", + "homepage": "https://alexcicovic.com/" + }, + { + "name": "Georgi Hristov", + "homepage": "https://xsystems.io/" + } + ], + "require": { + "php": ">=7.3.0", + "atk4/data": "dev-develop" }, - { - "name": "Alain Belair", - "homepage": "https://agiletoolkit.org/" + "require-release": { + "php": ">=7.3.0", + "atk4/data": "~2.4.0" }, - { - "name": "Imants Horsts", - "homepage": "https://darkside.lv/" + "require-dev": { + "behat/behat": "^3.8", + "behat/mink": "^1.8", + "behat/mink-extension": "^2.3.1", + "behat/mink-selenium2-driver": "^1.4", + "ergebnis/composer-normalize": "^2.13", + "friendsofphp/php-cs-fixer": "^2.17", + "fzaninotto/faker": "^1.6", + "guzzlehttp/guzzle": "^6.3", + "instaclick/php-webdriver": "^1.4.7", + "johnkary/phpunit-speedtrap": "^3.2", + "phpstan/phpstan": "^0.12.82", + "phpunit/phpcov": "*", + "phpunit/phpunit": ">=9.3", + "symfony/process": "^4.4 || ^5.0" }, - { - "name": "Francesco Danti", - "homepage": "https://oracoltech.com/" + "config": { + "sort-packages": true }, - { - "name": "Michael Voříšek", - "homepage": "https://mvorisek.cz/" + "autoload": { + "psr-4": { + "Atk4\\Ui\\": "src/" + } }, - { - "name": "Philipp Grashoff" + "autoload-dev": { + "psr-4": { + "Atk4\\Ui\\Tests\\": "tests/", + "Atk4\\Ui\\Behat\\": "tests-behat/bootstrap/" + } }, - { - "name": "Alex Cicovic", - "homepage": "https://alexcicovic.com/" - }, - { - "name": "Georgi Hristov", - "homepage": "https://xsystems.io/" - } - ], - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "sort-packages": true - }, - "require": { - "php": ">=7.3.0", - "atk4/data": "dev-develop" - }, - "require-release": { - "php": ">=7.3.0", - "atk4/data": "~2.3.0" - }, - "require-dev": { - "behat/behat": "^3.8", - "behat/mink": "^1.8", - "behat/mink-extension": "^2.3.1", - "behat/mink-selenium2-driver": "^1.4", - "friendsofphp/php-cs-fixer": "^2.17", - "fzaninotto/faker": "^1.6", - "guzzlehttp/guzzle": "^6.3", - "instaclick/php-webdriver": "^1.4.7", - "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.82", - "phpunit/phpcov": "*", - "phpunit/phpunit": ">=9.3", - "symfony/process": "^4.4 || ^5.0" - }, - "autoload": { - "psr-4": { - "Atk4\\Ui\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Atk4\\Ui\\Tests\\": "tests/", - "Atk4\\Ui\\Behat\\": "tests-behat/bootstrap/" - } - } + "minimum-stability": "dev", + "prefer-stable": true }