From b11632155008f461df38eb10d1d30150a7e7cbef Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 22 May 2024 13:22:23 +0200 Subject: [PATCH] [ECP-8954] Automate the Shopware Marketplace zip file creation as release asset (#500) * Added new workflow file and script for creating zip * Fixed syntax in yml file * Update the path to prepare script in yml file * Add a testing script with e2e file * Update the file path syntax * Update working directory path * Try something new * Try something new with the zip path * hopefully this fixed the path * hopefully this fixed the path - 2 * hopefully this fixed the path - 3 * hopefully this fixed the path - 4 * hopefully this fixed the path - 5 * last trial of the day * move zip file inside pwd * Finish up * Remove copy * Update comments * Add upload asset into workflow * try to use the upload artifact action for uploading release asset * path var update * Action update * add tag * always * try latest action * try another one * update input variable * try CLI * fix syntax * fix syntax * add token * remove @ * find the file * trying to user form data. * setting the content type and using the upload url. * oops.. upload_url instead of release id * fight the zip corruption * fight the zip corruption -1 * Update checkout version in mail.yml to get rid of deprecation warnings * remove usage of set-output * Test and revert * revert url var too * test env vars * change syntax * again * change mime type * raw field instead of field * back to the basics.. * added ls again to check (and data key) * try something new * try upload with cli command using tag-name * Clean up and try upload with cli command using tag-name - 2 * Go back to old method * See if Readme file gets corrupted too on upload * syntax fix * rearrange commented code * syntax fix again * Check for readme * Correct file type * Now try the same method for the zip * Oops! forgot to compile the zip * Since it finally works - optimize code * Finalise * Update trigger to 'release' * Remove the push trigger * Apply suggestions from review * Remove missed commented code * Create a zip file for test and use the ref name instead of 'latest' for getting release information * Remove 'workflow_dispatch' trigger and get a zip file with 'push' trigger * Remove 'push' trigger and add back the usage of ref name * test the trigger type 'edited' for release * test the trigger type 'published' for release * [ECP-8954] Use tag name directly --------- Co-authored-by: sushmita --- .github/workflows/main.yml | 2 +- .../scripts/prepare-release-asset.sh | 31 +++++++++++++++++++ .github/workflows/upload-release-asset.yml | 22 +++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 .github/workflows/scripts/prepare-release-asset.sh create mode 100644 .github/workflows/upload-release-asset.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa244284c..f22e6c469 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: php-version: ${{ matrix.php-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Validate composer.json and composer.lock run: composer validate diff --git a/.github/workflows/scripts/prepare-release-asset.sh b/.github/workflows/scripts/prepare-release-asset.sh new file mode 100755 index 000000000..fa3c64422 --- /dev/null +++ b/.github/workflows/scripts/prepare-release-asset.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Create a copy of the plugin directory +cd .. +cp -r adyen-shopware6 AdyenPaymentShopware6 + +# Remove Shopware dependencies +composer remove shopware/core --working-dir=./AdyenPaymentShopware6 +composer remove shopware/storefront --working-dir=./AdyenPaymentShopware6 + +# Remove composer.lock again and vendor directory +rm AdyenPaymentShopware6/composer.lock +rm -rf AdyenPaymentShopware6/vendor + +# Install dependencies +composer install --no-dev --working-dir=./AdyenPaymentShopware6 + +# Copy original the composer.json file +cp adyen-shopware6/composer.json AdyenPaymentShopware6/. + +# Zip the plugin directory +zip -r AdyenPaymentShopware6.zip AdyenPaymentShopware6/ ; + +# Move the zip file to plugin folder +mv AdyenPaymentShopware6.zip adyen-shopware6 + +# Cleanup the zip installation +zip -d AdyenPaymentShopware6.zip __MACOSX/\* ; zip -d AdyenPaymentShopware6.zip *.git* + +# Go back to workflow's root directory +cd adyen-shopware6 diff --git a/.github/workflows/upload-release-asset.yml b/.github/workflows/upload-release-asset.yml new file mode 100644 index 000000000..22c451449 --- /dev/null +++ b/.github/workflows/upload-release-asset.yml @@ -0,0 +1,22 @@ +on: + release: + types: [published] + +name: Upload Shopware 6 Marketplace asset + +jobs: + run: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Prepare release artifact + run: .github/workflows/scripts/prepare-release-asset.sh + + - name: Upload asset + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref_name }} AdyenPaymentShopware6.zip --clobber