Skip to content

Commit 24aca97

Browse files
committed
Add a manual release workflow [skip deploy]
Signed-off-by: Eatham532 <78714349+Eatham532@users.noreply.github.com>
1 parent 942929b commit 24aca97

1 file changed

Lines changed: 225 additions & 0 deletions

File tree

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: Manual Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- none
16+
skip_indexnow:
17+
description: 'Skip IndexNow notification'
18+
required: false
19+
default: false
20+
type: boolean
21+
custom_version:
22+
description: 'Custom version (if bump=none)'
23+
required: false
24+
type: string
25+
26+
# Cancel in-progress runs when new release is triggered
27+
concurrency:
28+
group: manual-release
29+
cancel-in-progress: false
30+
31+
permissions:
32+
contents: write
33+
34+
jobs:
35+
manual-release:
36+
name: πŸ“¦ Manual Release
37+
runs-on: ubuntu-latest
38+
container:
39+
image: python:3.13
40+
41+
steps:
42+
- name: πŸ“₯ Checkout repository
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0 # Full history for release notes
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: πŸ” Mark repository safe for git
49+
shell: bash
50+
run: |
51+
# Allow git operations inside the runner workspace
52+
git config --global --add safe.directory "${{ github.workspace }}"
53+
git config --global --add safe.directory "$(pwd)"
54+
echo "βœ… Git safe directories configured"
55+
56+
- name: πŸ‘€ Configure git user
57+
shell: bash
58+
run: |
59+
git config --global user.email "78714349+Eatham532@users.noreply.github.com"
60+
git config --global user.name "Eatham532"
61+
echo "βœ… Git user configured as Eatham532"
62+
63+
- name: πŸ”§ Setup Python environment
64+
shell: bash
65+
run: |
66+
set -euo pipefail
67+
python --version
68+
python -m pip install --upgrade pip setuptools wheel build
69+
70+
- name: πŸ“¦ Install dependencies
71+
shell: bash
72+
run: |
73+
set -euo pipefail
74+
python -m pip install -e . || python -m pip install .
75+
76+
- name: πŸ› οΈ Install zip utility
77+
shell: bash
78+
run: |
79+
apt-get update && apt-get install -y zip
80+
81+
- name: πŸ“Š Get current version
82+
id: get_version
83+
shell: bash
84+
run: |
85+
current_version=$(python scripts/bump_version.py show)
86+
echo "current_version=${current_version}" >> $GITHUB_OUTPUT
87+
echo "πŸ“Œ Current version: ${current_version}"
88+
89+
- name: πŸ”Ό Bump version
90+
id: bump_version
91+
shell: bash
92+
run: |
93+
bump_type="${{ github.event.inputs.version_bump }}"
94+
if [ "$bump_type" = "none" ]; then
95+
if [ -n "${{ github.event.inputs.custom_version }}" ]; then
96+
new_version="${{ github.event.inputs.custom_version }}"
97+
echo "πŸ“ Using custom version: ${new_version}"
98+
else
99+
new_version="${{ steps.get_version.outputs.current_version }}"
100+
echo "πŸ“Œ Using current version: ${new_version}"
101+
fi
102+
else
103+
# Bump the version
104+
version_change=$(python scripts/bump_version.py "$bump_type")
105+
new_version=$(echo "$version_change" | cut -d' ' -f3)
106+
echo "βœ… Version bumped: ${version_change}"
107+
fi
108+
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
109+
110+
- name: πŸ’Ύ Update version in pyproject.toml
111+
if: github.event.inputs.version_bump != 'none'
112+
shell: bash
113+
run: |
114+
python scripts/bump_version.py "${{ github.event.inputs.version_bump }}"
115+
116+
- name: πŸ“¦ Build site
117+
env:
118+
KROKI_SERVER_URL: http://kroki:8000
119+
shell: bash
120+
run: |
121+
set -euo pipefail
122+
if ! command -v mkdocs >/dev/null 2>&1; then
123+
echo "❌ ERROR: mkdocs not found on PATH"
124+
exit 1
125+
fi
126+
echo "πŸ“¦ Building site..."
127+
mkdocs build --clean
128+
echo "βœ… Build complete!"
129+
130+
- name: πŸ“¦ Create site archive
131+
shell: bash
132+
run: |
133+
cd site
134+
zip -r ../site-build.zip .
135+
cd ..
136+
echo "βœ… Site archive created"
137+
138+
- name: πŸ’Ύ Commit version bump
139+
if: github.event.inputs.version_bump != 'none'
140+
shell: bash
141+
run: |
142+
git add pyproject.toml
143+
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip deploy]"
144+
git push origin main
145+
echo "βœ… Version committed and pushed"
146+
147+
- name: πŸ“ Generate release notes
148+
id: release_notes
149+
shell: bash
150+
run: |
151+
# Get the previous tag (if exists)
152+
previous_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
153+
154+
if [ -z "$previous_tag" ]; then
155+
echo "πŸ“ First release - including all commits"
156+
commit_range="HEAD"
157+
else
158+
echo "πŸ“ Generating release notes since ${previous_tag}"
159+
commit_range="${previous_tag}..HEAD"
160+
fi
161+
162+
# Generate commit log
163+
echo "## πŸ“‹ Changes" > release_notes.md
164+
echo "" >> release_notes.md
165+
git log ${commit_range} --pretty=format:"- %s (%h)" --no-merges | grep -v "\[skip deploy\]" >> release_notes.md || true
166+
echo "" >> release_notes.md
167+
168+
# Get contributors since last tag
169+
if [ -n "$previous_tag" ]; then
170+
contributors=$(git log ${commit_range} --format='%an' | sort -u | grep -v "github-actions\[bot\]" || true)
171+
if [ -n "$contributors" ]; then
172+
echo "" >> release_notes.md
173+
echo "## πŸ‘₯ Contributors" >> release_notes.md
174+
echo "" >> release_notes.md
175+
echo "$contributors" | while read contributor; do
176+
echo "- $contributor" >> release_notes.md
177+
done
178+
fi
179+
fi
180+
181+
echo "βœ… Release notes generated"
182+
183+
- name: 🏷️ Create Release
184+
uses: softprops/action-gh-release@v1
185+
with:
186+
tag_name: v${{ steps.bump_version.outputs.new_version }}
187+
name: Release v${{ steps.bump_version.outputs.new_version }}
188+
body_path: release_notes.md
189+
files: |
190+
site-build.zip
191+
draft: false
192+
prerelease: false
193+
env:
194+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
195+
196+
notify-indexnow-manual:
197+
name: πŸ”” Notify Search Engines (Manual)
198+
runs-on: ubuntu-latest
199+
needs: manual-release
200+
if: success() && github.event.inputs.skip_indexnow != 'true'
201+
202+
steps:
203+
- name: πŸ“₯ Checkout repository
204+
uses: actions/checkout@v4
205+
with:
206+
fetch-depth: 0
207+
token: ${{ secrets.GITHUB_TOKEN }}
208+
209+
- name: πŸ”§ Setup Python
210+
uses: actions/setup-python@v5
211+
with:
212+
python-version: '3.13'
213+
214+
- name: πŸ“¦ Install requests library
215+
shell: bash
216+
run: |
217+
python -m pip install --upgrade pip
218+
python -m pip install requests
219+
220+
- name: πŸ”” Notify IndexNow of changes
221+
shell: bash
222+
run: |
223+
echo "πŸ”” Notifying search engines of changes..."
224+
python scripts/indexnow_notify.py
225+
continue-on-error: true

0 commit comments

Comments
Β (0)