Merge pull request #13 from wUFr/dependabot/npm_and_yarn/semantic-rel… #50
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: Test and Publish | |
on: | |
push: | |
branches: | |
- release | |
- release-candidate | |
pull_request: | |
branches: | |
- release | |
- release-candidate | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.0' # You can specify the PHP version you need | |
- name: Install Composer | |
run: | | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
php composer-setup.php --install-dir=/usr/local/bin --filename=composer | |
php -r "unlink('composer-setup.php');" | |
- name: Install dependencies | |
run: composer install | |
- name: Regenerate autoload files | |
run: composer dump-autoload | |
- name: Run tests | |
run: ./vendor/bin/phpunit --configuration phpunit.xml | |
publish: | |
runs-on: ubuntu-latest | |
needs: tests | |
if: github.ref == 'refs/heads/release' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Run semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release | |
- name: Update Packagist | |
run: | | |
curl -XPOST -H 'content-type:application/json' \ | |
'https://packagist.org/api/update-package?username=wUFr&apiToken=${{ secrets.PACKAGIST_API_TOKEN }}' \ | |
-d '{"repository":{"url":"https://packagist.org/packages/wufr/php-language-localizer"}}' |