-
Notifications
You must be signed in to change notification settings - Fork 46
120 lines (107 loc) · 4.38 KB
/
release-engine.yml
File metadata and controls
120 lines (107 loc) · 4.38 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Release Patch Engine
on:
workflow_dispatch:
inputs:
version:
description: 'Engine version to release (must match VERSION file, e.g., 3.0.0)'
required: true
type: string
jobs:
release:
name: Release Engine v${{ github.event.inputs.version }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Render GitHub Pages index
run: |
python3 scripts/core/render_pages_index.py --output /tmp/index.html
- name: Validate version
run: |
FILE_VERSION=$(tr -d '[:space:]' < VERSION)
INPUT_VERSION="${{ github.event.inputs.version }}"
if [ "$FILE_VERSION" != "$INPUT_VERSION" ]; then
echo "❌ VERSION file ($FILE_VERSION) does not match input ($INPUT_VERSION)"
echo "Update the VERSION file first, then run this workflow."
exit 1
fi
echo "✅ Version validated: v${INPUT_VERSION}"
- name: Check tag doesn't already exist
run: |
if git rev-parse "v${{ github.event.inputs.version }}" >/dev/null 2>&1; then
echo "❌ Tag v${{ github.event.inputs.version }} already exists"
exit 1
fi
- name: Generate changelog excerpt
id: changelog
run: |
VERSION="${{ github.event.inputs.version }}"
# Extract the section for this version from CHANGELOG.md
EXCERPT=$(awk "/^## \[${VERSION}\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md)
if [ -z "$EXCERPT" ]; then
EXCERPT="No changelog entry found for v${VERSION}. Please update CHANGELOG.md."
fi
# Output using heredoc delimiter
echo "body<<CHANGELOG_EOF" >> $GITHUB_OUTPUT
echo "$EXCERPT" >> $GITHUB_OUTPUT
echo "CHANGELOG_EOF" >> $GITHUB_OUTPUT
- name: Create engine release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }}
name: "Patch Engine v${{ github.event.inputs.version }}"
body: |
# Patch Engine v${{ github.event.inputs.version }}
${{ steps.changelog.outputs.body }}
---
**Full Changelog:** [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md)
make_latest: true
generate_release_notes: false
- name: Setup gh-pages
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if git fetch origin gh-pages; then
git clone --branch gh-pages --depth 1 https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
else
echo "gh-pages branch not found, initializing..."
mkdir -p gh-pages
cd gh-pages
git init
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git checkout -b gh-pages
touch .gitkeep
git add .gitkeep
git commit -m "Initialize gh-pages"
cd ..
fi
- name: Update latest stable JSON
run: |
mkdir -p gh-pages/builds
cat > gh-pages/builds/latest.json <<EOF
{
"engine_version": "${{ github.event.inputs.version }}",
"release_url": "https://github.com/${{ github.repository }}/releases/tag/v${{ github.event.inputs.version }}",
"release_date": "$(date -u +%Y-%m-%d)",
"supported_android": ["13", "14", "15", "16"]
}
EOF
- name: Commit and push latest.json
run: |
cd gh-pages
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
cp /tmp/index.html index.html
git add builds/latest.json
git add index.html
if git diff --cached --quiet; then
echo "No latest.json changes to commit"
else
git commit -m "Update latest stable to v${{ github.event.inputs.version }}"
git push origin gh-pages
fi