From 26f22b2f57c8766043aea9b0785232726f34c34c Mon Sep 17 00:00:00 2001 From: Halil Beycan <50718965+BeycanDeveloper@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:40:29 +0800 Subject: [PATCH] added workflows --- .gitattributes | 1 + .github/workflows/create-auto-release.yaml | 38 +++++++++++++ .github/workflows/phpcs.yaml | 34 +++++++++++ .../workflows/publish-to-wordpres.org.yaml | 57 +++++++++++++++++++ dokan-cryptopay-withdrawal.php | 2 +- 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/create-auto-release.yaml create mode 100644 .github/workflows/phpcs.yaml create mode 100644 .github/workflows/publish-to-wordpres.org.yaml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/.github/workflows/create-auto-release.yaml b/.github/workflows/create-auto-release.yaml new file mode 100644 index 0000000..f25343f --- /dev/null +++ b/.github/workflows/create-auto-release.yaml @@ -0,0 +1,38 @@ +name: Create auto release + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + auto_release: + name: Auto release + permissions: write-all + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@master + + - name: Check if release already exists + run: | + existing_release=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} 2>&1) + if [[ $existing_release == *"Not Found"* ]]; then + echo "RELEASE_EXISTS=false" >> $GITHUB_ENV + else + echo "RELEASE_EXISTS=true" >> $GITHUB_ENV + fi + + - name: Create Release + id: create_release + if: ${{ env.RELEASE_EXISTS == 'false' }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: Version ${{ github.ref_name }} + body: Version ${{ github.ref_name }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/phpcs.yaml b/.github/workflows/phpcs.yaml new file mode 100644 index 0000000..4e3c48e --- /dev/null +++ b/.github/workflows/phpcs.yaml @@ -0,0 +1,34 @@ +name: PHPCS Check + +on: + push: + branches: + - master + +jobs: + phpcs: + name: PHPCS Check + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Install PHPCS + run: | + composer config --global --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer require --dev squizlabs/php_codesniffer=* slevomat/coding-standard + + - name: Run PHPCS + run: | + composer phpcs --standard=phpcs.xml . + exit_status=$? + if [ $exit_status -ne 0 ]; then + echo "PHPCS check failed. Please fix the issues before merging." + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/publish-to-wordpres.org.yaml b/.github/workflows/publish-to-wordpres.org.yaml new file mode 100644 index 0000000..f07ca79 --- /dev/null +++ b/.github/workflows/publish-to-wordpres.org.yaml @@ -0,0 +1,57 @@ +name: Publish to WordPress.org + +on: + workflow_run: + workflows: + - Create auto release + types: + - completed + +env: + PLUGIN_SLUG: cryptocurrency-payments-for-paid-memberships-pro + +jobs: + deploy_to_wp_org: + permissions: write-all + name: WordPress.org Plugin Deploy + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + + - name: Get upload url & and release version + id: get_release_info + run: | + latest_release=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/releases/latest") + latest_release_id=$(echo "$latest_release" | jq -r '.id') + latest_release_version=$(echo "$latest_release" | jq -r '.tag_name') + + upload_url=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + "https://api.github.com/repos/${{ github.repository }}/releases/${latest_release_id}" | jq -r '.upload_url') + + echo "UPLOAD_URL=$upload_url" >> $GITHUB_ENV + echo "RELEASE_ID=$latest_release_id" >> $GITHUB_ENV + echo "RELEASE_VERSION=$latest_release_version" >> $GITHUB_ENV + - name: WordPress Plugin Deploy + id: deploy + uses: 10up/action-wordpress-plugin-deploy@stable + with: + generate-zip: true + env: + SVN_PASSWORD: ${{ secrets.WORDPRESS_ORG_PASSWORD }} + SVN_USERNAME: ${{ secrets.WORDPRESS_ORG_USERNAME }} + SLUG: ${{ env.PLUGIN_SLUG }} + VERSION: ${{ env.RELEASE_VERSION }} + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.UPLOAD_URL }} + asset_path: ${{ steps.deploy.outputs.zip-path }} + asset_name: ${{ env.PLUGIN_SLUG }}.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/dokan-cryptopay-withdrawal.php b/dokan-cryptopay-withdrawal.php index bb966d6..e760570 100644 --- a/dokan-cryptopay-withdrawal.php +++ b/dokan-cryptopay-withdrawal.php @@ -9,7 +9,7 @@ /** * Plugin Name: Dokan - CryptoPay Withdrawal * Version: 1.0.1 - * Plugin URI: https://beycanpress.com/cryptopay + * Plugin URI: https://beycanpress.com/cryptopay/ * Description: Add custom cryptocurrency withdrawal method to Dokan plugin * Author: BeycanPress LLC * Author URI: https://beycanpress.com