-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (93 loc) · 3.57 KB
/
release.yml
File metadata and controls
106 lines (93 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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]+(-[a-zA-Z0-9.]+)?$'; then
echo "::error::Invalid version '${{ github.event.inputs.version }}'. Expected format: 1.2.3 or 1.2.3-alpha1 (optional v prefix)"
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