This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release Zip | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "7.4" | |
coverage: none | |
- name: Install dependencies | |
run: composer install --no-dev --no-scripts --no-progress | |
- name: Install PHP-Scoper | |
run: | | |
composer global require humbug/php-scoper | |
echo "${HOME}/.composer/vendor/bin" >> $GITHUB_PATH | |
- name: Create scoper config | |
run: | | |
cat > scoper.inc.php <<EOF | |
<?php | |
return [ | |
'prefix' => 'MollieVendor', | |
'finders' => [], | |
'exclude-namespaces' => ['Mollie\\Api'], | |
'exclude-files' => [], | |
]; | |
EOF | |
- name: Scope dependencies | |
run: php-scoper add-prefix --output-dir=./build/scoped | |
- name: Setup autoloader | |
run: | | |
cd build/scoped | |
composer dump-autoload --classmap-authoritative | |
php examples/initialize.php | |
# Swap autoloader files to handle both scoped and non-scoped classes | |
mv vendor/autoload.php vendor/composer-autoload.php | |
sed -i.bak 's/autoload.php/composer-autoload.php/g' vendor/scoper-autoload.php | |
mv vendor/scoper-autoload.php vendor/autoload.php | |
rm vendor/*.bak | |
- name: Create release zip | |
run: | | |
cd build/scoped | |
zip -r ../../mollie-api-php-test.zip . | |
cd ../.. | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mollie-api-php-test | |
path: mollie-api-php-test.zip | |
# This step only runs on actual release | |
- name: Upload to release | |
if: github.event_name == 'release' | |
uses: JasonEtco/upload-to-release@master | |
with: | |
args: build/mollie-api-php.zip application/zip | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |