Release #7
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: Release | |
| on: | |
| repository_dispatch: | |
| types: [openapi-updated] | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'patch | minor | major' | |
| required: false | |
| default: 'patch' | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: wp-release | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.1' | |
| tools: composer | |
| coverage: none | |
| - run: composer install --no-dev --optimize-autoloader --prefer-dist | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| - run: npm ci | |
| - name: Regenerate from live OpenAPI | |
| run: npm run generate | |
| - name: Check if spec changed | |
| id: diff | |
| run: | | |
| if git diff --quiet specs/openapi.json src/Generated blocks/generated; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Lint | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: vendor/bin/phpcs --standard=phpcs.xml.dist | |
| - name: Static analysis | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: vendor/bin/phpstan analyze --no-progress --memory-limit=1G | |
| - name: Build blocks | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: npm run build:all | |
| - name: Bump version | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| id: bump | |
| run: | | |
| BUMP="${{ github.event.inputs.version_bump || 'patch' }}" | |
| npm version "$BUMP" --no-git-tag-version | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| sed -i "s/^\(\s*\*\s*Version:\s*\).*/\1$VERSION/" roxyapi.php | |
| sed -i "s/const ROXYAPI_VERSION\s*=\s*'[^']*';/const ROXYAPI_VERSION = '$VERSION';/" roxyapi.php | |
| sed -i "s/^Stable tag:.*$/Stable tag: $VERSION/" readme.txt | |
| - name: Commit, tag, push | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| VERSION="${{ steps.bump.outputs.version }}" | |
| git add . | |
| git commit -m "release: v$VERSION" | |
| git tag "v$VERSION" | |
| git push --follow-tags | |
| - name: Deploy to WordPress.org | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| id: deploy | |
| uses: 10up/action-wordpress-plugin-deploy@stable | |
| with: | |
| generate-zip: true | |
| env: | |
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | |
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | |
| SLUG: roxyapi | |
| - name: Attach zip to GitHub release | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.bump.outputs.version }} | |
| files: ${{ steps.deploy.outputs.zip-path }} | |
| generate_release_notes: true | |
| - name: No changes | |
| if: steps.diff.outputs.changed == 'false' && github.event_name != 'workflow_dispatch' | |
| run: echo "OpenAPI spec unchanged. Nothing to release." |