diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e5c539f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,90 +0,0 @@ -version: 2.1 - -orbs: - php: circleci/php@1 - -executors: - default: - docker: - - image: 'cibuilds/github:latest' - -jobs: - lint-wp-org: - parameters: - zip: - type: string - description: path to plugin zip file - executor: - name: php/default - tag: '7.2' - steps: - - run: unzip << parameters.zip >> -d /tmp/plugin-source-code - - run: find /tmp/plugin-source-code -name "*.php" -print0 | xargs -n 1 -0 php -l - publish-to-github-releases: - parameters: - github_token: - type: string - description: GitHub personal access token. For a private repository you need `repo` scope and for a public repository you need `public_repo` scope - default: ${GITHUB_TOKEN} - artifact_dir: - type: string - description: directory path of the artifacts to be uploaded - default: . - executor: - type: executor - default: default - executor: << parameters.executor >> - steps: - - run: ghr -t << parameters.github_token >> -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -soft ${CIRCLE_TAG} << parameters.artifact_dir >> - -workflows: - test: - jobs: - - php/test: - name: style-check - test-command: style:check - - # TODO: Extract orbs - # TODO: Commit wo.org svn - build_release: - jobs: - - php/test: - name: build - # Build with lowest support PHP version - # wp.org svn pre-commit hook rejects PHP 7.3+ syntax - version: '7.2' - test-command: release:build - post-steps: - - store_artifacts: - path: release - - persist_to_workspace: - root: ~/project - paths: - - release/*.zip - filters: - tags: - only: /.*/ - - lint-wp-org: - name: lint-wp-org - requires: - - build - zip: release/gf-sagepay.zip - pre-steps: - - attach_workspace: - at: ~/project - filters: - tags: - only: /.*/ - - publish-to-github-releases: - requires: - - build - - lint-wp-org - artifact_dir: release - pre-steps: - - attach_workspace: - at: ~/project - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..864f1be --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +# yamllint disable-line rule:document-start +name: release + +# yamllint disable-line rule:truthy +on: + push: + tags: + - "*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP 8.1 + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build release + run: composer run-script release:build + + - uses: actions/upload-artifact@v4 + with: + name: gf-sagepay + path: release/*.zip + + lint-wp-org: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/download-artifact@v4 + with: + name: gf-sagepay + - run: unzip gf-sagepay.zip -d /tmp/plugin-source-code + - run: find /tmp/plugin-source-code -name "*.php" -print0 | xargs -n 1 -0 php -l + + publish-to-github-releases: + runs-on: ubuntu-latest + needs: lint-wp-org + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v4 + with: + name: gf-sagepay + - name: Create release + run: gh release create "${GITHUB_REF/refs\/tags\//}" gf-sagepay.zip --generate-notes + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..52f4807 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +# yamllint disable-line rule:document-start +name: test + +# yamllint disable-line rule:truthy +on: + push: + branches: + - "*" + +jobs: + php: + name: php-${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + matrix: + php: [8.1] + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> "${GITHUB_OUTPUT}" + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - run: composer run-script style:check