|
name: "Create patch helper files" |
|
|
|
on: |
|
workflow_dispatch: |
|
inputs: |
|
defaultBranch: |
|
description: 'Select the branch that is used as a base (old version)' |
|
required: true |
|
default: 'main' |
|
phpVersion: |
|
description: 'Select the PHP version to use' |
|
required: true |
|
default: '8.2' |
|
|
|
jobs: |
|
create-patch-helper-files: |
|
runs-on: ubuntu-latest |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
with: |
|
ref: 'feature/upgrade-2.4.7' #${{ github.event.workflow_run.head_branch }} |
|
path: 'new-version' |
|
|
|
- uses: actions/checkout@v4 |
|
with: |
|
ref: ${{ github.event.inputs.defaultBranch }} |
|
path: 'old-version' |
|
|
|
- uses: actions/checkout@v4 |
|
with: |
|
repository: 'AmpersandHQ/ampersand-magento2-upgrade-patch-helper' |
|
path: 'ampersand-patch-helper' |
|
|
|
- name: Setup PHP |
|
uses: shivammathur/setup-php@v2 |
|
with: |
|
php-version: ${{ github.event.inputs.phpVersion }}' |
|
|
|
- name: Install Composer dependencies for old version |
|
run: | |
|
cd old-version |
|
composer install --prefer-dist |
|
|
|
- name: Install Composer dependencies for new version |
|
run: | |
|
cd new-version |
|
composer install --prefer-dist |
|
|
|
- name: Install Composer dependencies for patch helper |
|
run: | |
|
composer install --prefer-dist --working-dir=ampersand-patch-helper |
|
|
|
- name: Create vendor.patch |
|
continue-on-error: true |
|
run: | |
|
mv old-version/vendor new-version/vendor_orig |
|
cd new-version |
|
diff -urN vendor_orig vendor > vendor.patch |
|
|
|
- name: Create patch helper files |
|
run: | |
|
php ampersand-patch-helper/bin/patch-helper.php analyse new-version | tee patch-helper-output.txt |
|
|
|
- name: Create classmap |
|
run: | |
|
cd new-version |
|
composer dump --classmap-authoritative |
|
php -r "\$classmap=require_once('vendor/composer/autoload_classmap.php'); echo json_encode(\$classmap);" > classmap.json |
|
sed -i "s|${GITHUB_WORKSPACE//\//\\\\\\/}\\\\/new-version|.|g" classmap.json |
|
|
|
- name: Prepare archive |
|
run: | |
|
mkdir archive |
|
mv new-version/vendor_files_to_check.patch archive/vendor_files_to_check.patch |
|
mv patch-helper-output.txt archive/patch-helper-output.txt |
|
mv new-version/vendor archive/vendor |
|
mv new-version/vendor_orig archive/vendor_orig |
|
tar -czf archive/vendor.tar.gz -C archive vendor |
|
tar -czf archive/vendor_orig.tar.gz -C archive vendor_orig |
|
rm -rf archive/vendor archive/vendor_orig |
|
mv new-version/vendor.patch archive/vendor.patch |
|
mv new-version/classmap.json archive/classmap.json |
|
|
|
- name: Archive files |
|
uses: actions/upload-artifact@v3 |
|
with: |
|
name: patch-helper-files |
|
path: | |
|
archive/vendor_files_to_check.patch |
|
archive/patch-helper-output.txt |
|
archive/vendor.tar.gz |
|
archive/vendor_orig.tar.gz |
|
archive/vendor.patch |
|
archive/classmap.json |