Build and Release #6
This file contains hidden or 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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build Plugin | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '7.4' | |
| coverage: none | |
| - name: Install Composer dependencies | |
| run: composer install --no-dev --optimize-autoloader --no-interaction | |
| - name: Install npm dependencies | |
| run: npm ci | |
| - name: Build assets | |
| run: npm run build | |
| - name: Create plugin directory for zip | |
| run: | | |
| mkdir -p /tmp/dubinc | |
| - name: Copy plugin files | |
| run: | | |
| rsync -rc . /tmp/dubinc/ \ | |
| --exclude=.git \ | |
| --exclude=.github \ | |
| --exclude=node_modules \ | |
| --exclude=assets/js \ | |
| --exclude=assets/css \ | |
| --exclude=.gitignore \ | |
| --exclude=.gitattributes \ | |
| --exclude=.editorconfig \ | |
| --exclude=.eslintrc.json \ | |
| --exclude=.eslintignore \ | |
| --exclude=.lintstagedrc.json \ | |
| --exclude=.distignore \ | |
| --exclude=ruleset.xml \ | |
| --exclude=package.json \ | |
| --exclude=package-lock.json \ | |
| --exclude=composer.lock \ | |
| --exclude=README.md \ | |
| --exclude=.DS_Store \ | |
| --exclude=Thumbs.db | |
| - name: Create zip file with proper structure | |
| run: | | |
| cd /tmp | |
| zip -r $GITHUB_WORKSPACE/dubinc.zip dubinc | |
| - name: Verify zip structure | |
| run: | | |
| echo "Zip contents:" | |
| unzip -l dubinc.zip | head -20 | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| if: startsWith(github.ref, 'refs/tags/') | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: dubinc.zip | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dubinc | |
| path: /tmp/dubinc | |
| retention-days: 30 |