diff --git a/.editorconfig b/.editorconfig index 402bd2f..67a7860 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,5 +8,5 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.yml] -indent_size = 2 +[Makefile] +indent_style = tab diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b088550..a434890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,27 +3,34 @@ name: CI on: [push] jobs: - build: - name: Build - runs-on: ubuntu-latest - - steps: - - - name: Checkout - uses: actions/checkout@v1 - - - name: Build - id: build - uses: gocom/action-textpattern-package-plugin@master - - - name: Upload Compressed Plugin Installer Artifact - uses: actions/upload-artifact@master - with: - name: ${{ steps.build.outputs.name }}_sha${{ github.sha }}_zip.txt - path: ${{ github.workspace }}/${{ steps.build.outputs.compressed }} - - - name: Upload Uncompressed Plugin Installer Artifact - uses: actions/upload-artifact@master - with: - name: ${{ steps.build.outputs.name }}_sha${{ github.sha }}.txt - path: ${{ github.workspace }}/${{ steps.build.outputs.uncompressed }} + build: + name: Build + runs-on: ubuntu-latest + env: + COMPOSER_HOME: ./.composer + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup + run: mkdir -p "$COMPOSER_HOME" + + - name: Lint + run: make lint + + - name: Build + id: build + uses: gocom/action-textpattern-package-plugin@master + + - name: Upload Compressed Plugin Installer Artifact + uses: actions/upload-artifact@master + with: + name: ${{ steps.build.outputs.name }}_sha${{ github.sha }}_zip.txt + path: ${{ github.workspace }}/${{ steps.build.outputs.compressed }} + + - name: Upload Uncompressed Plugin Installer Artifact + uses: actions/upload-artifact@master + with: + name: ${{ steps.build.outputs.name }}_sha${{ github.sha }}.txt + path: ${{ github.workspace }}/${{ steps.build.outputs.uncompressed }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fcdf975..26340a1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,51 +1,60 @@ name: Release on: - push: - tags: - - '*.*.*' + push: + tags: + - '*.*.*' jobs: - build: - name: Create Release - runs-on: ubuntu-latest - - steps: - - - name: Checkout - uses: actions/checkout@v1 - - - name: Build - id: build - uses: gocom/action-textpattern-package-plugin@master - - - name: Create Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload Compressed Plugin Installer - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/${{ steps.build.outputs.compressed }} - asset_name: ${{ steps.build.outputs.name }}_v${{ steps.build.outputs.version }}_zip.txt - asset_content_type: text/plain - - - name: Upload Uncompressed Plugin Installer - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/${{ steps.build.outputs.uncompressed }} - asset_name: ${{ steps.build.outputs.name }}_v${{ steps.build.outputs.version }}.txt - asset_content_type: text/plain + build: + name: Create Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build + id: build + uses: gocom/action-textpattern-package-plugin@master + + - name: Changelog + id: changelog + run: | + contents="$(sed -e '1,/h2. Changelog/d' README.textile | sed -e '1,/h3./d' -e '/h3./,$d')" + contents="${contents//'%'/'%25'}" + contents="${contents//$'\n'/'%0A'}" + contents="${contents//$'\r'/'%0D'}" + echo "::set-output name=contents::$contents" + + - name: Create Release + id: create_release + uses: actions/create-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: ${{ steps.changelog.outputs.contents }} + draft: false + prerelease: false + + - name: Upload Compressed Plugin Installer + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.workspace }}/${{ steps.build.outputs.compressed }} + asset_name: ${{ steps.build.outputs.name }}_v${{ steps.build.outputs.version }}_zip.txt + asset_content_type: text/plain + + - name: Upload Uncompressed Plugin Installer + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.workspace }}/${{ steps.build.outputs.uncompressed }} + asset_name: ${{ steps.build.outputs.name }}_v${{ steps.build.outputs.version }}.txt + asset_content_type: text/plain diff --git a/.gitignore b/.gitignore index 9f28dba..27ba28b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ !.editorconfig !.github !.gitignore -/composer.lock -/vendor +/dist/ +/vendor/ +composer.lock diff --git a/CONTRIBUTING.textile b/CONTRIBUTING.textile index 2763c94..e42aa22 100644 --- a/CONTRIBUTING.textile +++ b/CONTRIBUTING.textile @@ -4,7 +4,7 @@ Please take a quick look at this document before to make contribution process ea h2. License -"GNU General Public License, version 2":https://github.com/gocom/rah_flat/blob/master/LICENSE. By contributing code, you agree to license your additions under the GPLv2 license. +"GNU General Public License, version 2":https://github.com/gocom/rah_flat/blob/master/LICENSE. h2. Configure git @@ -15,22 +15,18 @@ $ git config --global user.email john.doe@example.com Make sure to use an email address that is linked to your GitHub account. It can be a throwaway address or you can use GitHub's email protection features. We don't want your emails, but this is to make sure we know who did what. All commits nicely link to their author, instead of them coming from foobar@invalid.tld. -h2. Dependencies +h2. Development -Dependencies are managed using "Composer":https://getcomposer.org. After you have cloned the repository, run composer install: +For list of available commands, run: -bc. $ composer install - -And update before testing and committing: - -bc. $ composer update +bc. $ make help h2. Coding standard The project follows the "PSR-0":https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md and "PSR-2":https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide-meta.md standards with PHP 5.2 style namespacing. You can use PHP_CodeSniffer to make sure your additions follow them too: -bc. $ composer cs +bc. $ make lint h2. Versioning -"Semantic Versioning":https://semver.org/ and major.minor.path format. +"Semantic Versioning":https://semver.org/. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..731f8c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +.PHONY: all clean compile help lint lint-fix + +PHP = docker-compose run --rm php + +all: lint + +vendor: + $(PHP) composer --ignore-platform-req=ext-memcached install + +clean: + $(PHP) rm -rf vendor composer.lock + +lint: vendor + $(PHP) composer lint + +lint-fix: vendor + $(PHP) composer lint-fix + +compile: vendor + $(PHP) composer compile + +help: + @echo "Manage project" + @echo "" + @echo "Usage:" + @echo " $$ make [command]" + @echo "" + @echo "Commands:" + @echo "" + @echo " $$ make lint" + @echo " Lint code style" + @echo "" + @echo " $$ make lint-fix" + @echo " Lint and fix code style" + @echo "" + @echo " $$ make compile" + @echo " Compiles the plugin" + @echo "" + @echo " $$ make clean" + @echo " Delete installed dependencies" + @echo "" + @echo " $$ make vendor" + @echo " Install dependencies" + @echo "" diff --git a/README.textile b/README.textile index 235c295..f39e4d4 100644 --- a/README.textile +++ b/README.textile @@ -1,6 +1,6 @@ h1. rah_flat -"Download":https://github.com/gocom/rah_flat/releases | "Packagist":https://packagist.org/packages/rah/rah_flat | "Donate":https://rahforum.biz/donate/rah_flat +"Download":https://github.com/gocom/rah_flat/releases | "Packagist":https://packagist.org/packages/rah/rah_flat | "Issues":https://github.com/gocom/rah_flat/issues This "Textpattern CMS":https://textpattern.com plugin imports flat "frontend themes":https://docs.textpattern.com/themes/front-end-themes automatically to the database while the site is set in debugging or testing mode. diff --git a/composer.json b/composer.json index 457c9cc..dbdcb81 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "authors": [ { "name": "Jukka Svahn", - "homepage": "https://rahforum.biz", + "homepage": "https://github.com/gocom", "role": "Developer" } ], @@ -22,9 +22,17 @@ "textpattern/installer": "*" }, "require-dev": { + "rah/mtxpc": "^0.9.0", "squizlabs/php_codesniffer": "3.*" }, "scripts": { - "cs": "./vendor/bin/phpcs" + "lint": "./vendor/bin/phpcs", + "lint-fix": "./vendor/bin/phpcbf", + "compile": "mtxpc --outdir=dist/ -c . && mtxpc --outdir=dist/ ." + }, + "config": { + "allow-plugins": { + "textpattern/installer": true + } } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..24c73a7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.2' + +services: + php: + image: composer:2.3 + volumes: + - .:/app + - ${COMPOSER_HOME:-$HOME/.composer}:/tmp + networks: + - app + +networks: + app: + driver: bridge