Release #1
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version number (e.g. 1.3.0)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| models: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate version input | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| VERSION="${VERSION#v}" | |
| if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "::error::Invalid version '${{ github.event.inputs.version }}'. Expected format: 1.2.3 (or v1.2.3)" | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| - name: Stamp version in plugin header | |
| run: | | |
| sed -i "s/^ \* Version:.*/ * Version: ${{ env.VERSION }}/" freespoke-search.php | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| PREV_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName // empty' 2>/dev/null || echo "") | |
| if [ -n "$PREV_TAG" ]; then | |
| DIFF=$(git diff "$PREV_TAG"..HEAD --stat && echo "---" && git diff "$PREV_TAG"..HEAD -- '*.php' '*.js' | head -c 8000) | |
| else | |
| DIFF="Initial release — no previous tag" | |
| fi | |
| NOTES=$(curl -s https://models.github.ai/inference/chat/completions \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -n --arg diff "$DIFF" '{ | |
| model: "openai/gpt-4.1-mini", | |
| messages: [{ | |
| role: "user", | |
| content: ("Write a concise, user-facing changelog in markdown for a WordPress plugin release. Summarize what changed based on this diff. No preamble, just bullet points:\n\n" + $diff) | |
| }] | |
| }')" | jq -r '.choices[0].message.content // "Release v${{ env.VERSION }}"') | |
| printf '%s\n' "$NOTES" > changelog.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create plugin zip | |
| run: | | |
| zip -r freespoke-search.zip . -x '.git/**' '.github/**' 'tests/**' 'phpunit.xml' 'composer.json' 'composer.lock' 'changelog.md' | |
| - name: Create GitHub release | |
| run: | | |
| gh release create "v${{ env.VERSION }}" \ | |
| freespoke-search.zip \ | |
| --title "v${{ env.VERSION }}" \ | |
| --notes-file changelog.md | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate update.json for GitHub Pages | |
| run: | | |
| mkdir -p _pages | |
| cat > _pages/update.json <<EOF | |
| { | |
| "version": "${{ env.VERSION }}", | |
| "download_url": "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/freespoke-search.zip", | |
| "requires": "6.0", | |
| "requires_php": "8.1", | |
| "tested": "6.7", | |
| "homepage": "https://freespoke.com/widgets", | |
| "description": "Embed the Freespoke Search Widget and automatically publish your content to Freespoke's search index." | |
| } | |
| EOF | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _pages | |
| deploy-pages: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |