-
Notifications
You must be signed in to change notification settings - Fork 6
261 lines (230 loc) · 9.54 KB
/
Copy pathrelease.yml
File metadata and controls
261 lines (230 loc) · 9.54 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Release
on:
push:
branches: [master]
paths:
- 'CMakeLists.txt'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 0.9.0). Leave empty to read from CMakeLists.txt.'
required: false
type: string
default: ''
permissions:
contents: write
jobs:
# ── Version gate ───────────────────────────────────────────────
version-check:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- name: '🧰 Checkout'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: '🔍 Check version bump and changelog'
id: check
run: |
MANUAL_VERSION="${{ inputs.version }}"
EVENT_NAME="${{ github.event_name }}"
# Extract version from HEAD CMakeLists.txt
NEW_VERSION=$(grep -oP 'project\(AeonGUI VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
if [[ -z "$NEW_VERSION" ]]; then
echo "::error::Could not parse version from CMakeLists.txt"
exit 1
fi
if [[ -n "$MANUAL_VERSION" ]]; then
# Manual dispatch with explicit version
NEW_VERSION="$MANUAL_VERSION"
echo "Manual dispatch with version: $NEW_VERSION"
elif [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
# Manual dispatch without version: use CMakeLists.txt version,
# skip commit comparison—tag existence check below is sufficient
echo "Manual dispatch using CMakeLists.txt version: $NEW_VERSION"
else
# Push trigger: compare HEAD vs previous commit
BEFORE="${{ github.event.before }}"
OLD_VERSION=$(git show "${BEFORE}:CMakeLists.txt" 2>/dev/null \
| grep -oP 'project\(AeonGUI VERSION \K[0-9]+\.[0-9]+\.[0-9]+' || echo "0.0.0")
echo "Previous commit version: $OLD_VERSION"
echo "Current commit version: $NEW_VERSION"
# If version unchanged in this push, skip silently
if [[ "$NEW_VERSION" == "$OLD_VERSION" ]]; then
echo "Version unchanged ($NEW_VERSION), skipping release"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
# Fail if the new version is lower than the previous
HIGHER=$(printf '%s\n%s' "$OLD_VERSION" "$NEW_VERSION" | sort -V | tail -1)
if [[ "$HIGHER" == "$OLD_VERSION" ]]; then
echo "::error::Version $NEW_VERSION is lower than previous $OLD_VERSION"
exit 1
fi
# Fail if CHANGELOG.md was not modified in this push
if ! git diff --name-only "${BEFORE}" "${{ github.sha }}" | grep -q '^CHANGELOG.md$'; then
echo "::error::Version bumped to $NEW_VERSION but CHANGELOG.md was not updated"
exit 1
fi
fi
# Also verify against the latest release tag (catches manual dispatch regressions)
LATEST_TAG=$(git tag -l 'v*' --sort=-version:refname | head -n1 || true)
if [[ -n "$LATEST_TAG" ]]; then
TAG_VERSION="${LATEST_TAG#v}"
if [[ "$NEW_VERSION" == "$TAG_VERSION" && "$EVENT_NAME" != "workflow_dispatch" ]]; then
echo "Version $NEW_VERSION already released as $LATEST_TAG, skipping"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
HIGHER=$(printf '%s\n%s' "$TAG_VERSION" "$NEW_VERSION" | sort -V | tail -1)
if [[ "$HIGHER" == "$TAG_VERSION" && "$NEW_VERSION" != "$TAG_VERSION" ]]; then
echo "::error::Version $NEW_VERSION is lower than existing release $TAG_VERSION"
exit 1
fi
fi
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
# ── Create tag and GitHub release ──────────────────────────────
create-release:
needs: version-check
if: needs.version-check.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: '🧰 Checkout'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: '🏷️ Create tag'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG="v${{ needs.version-check.outputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
else
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
fi
- name: '📦 Create GitHub Release'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version-check.outputs.version }}
name: AeonGUI v${{ needs.version-check.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
# ── Arch package + all build scripts (Ubuntu) ──────────────────
arch-and-scripts:
needs: [version-check, create-release]
if: needs.version-check.outputs.should_release == 'true'
runs-on: ubuntu-latest
container: archlinux:base-devel
steps:
- name: '🧰 Checkout'
uses: actions/checkout@v6
with:
ref: v${{ needs.version-check.outputs.version }}
- name: '📦 Install dependencies'
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm cmake make gcc flex bison pkgconf \
cairo pango fontconfig freetype2 harfbuzz libxml2 zlib libpng libjpeg-turbo \
mesa libx11 python \
git curl
# ── Generate all packaging scripts (no build deps needed) ──
- name: '📝 Generate packaging scripts'
run: cmake -B scripts-build -DBUILD_SCRIPTS_ONLY=ON
# ── Arch binary package ──
- name: '🛠️ Prepare Arch PKGBUILD'
run: cp scripts-build/PKGBUILD-arch PKGBUILD
- name: '📦 Build Arch package'
run: |
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
chown -R builder: .
su builder -c "makepkg -s --noconfirm --skippgpcheck"
# ── Package build scripts ──
- name: '📦 Package Arch PKGBUILD'
run: tar -czf PKGBUILD-arch-${{ needs.version-check.outputs.version }}.tar.gz PKGBUILD
- name: '📦 Package MSYS2 PKGBUILD'
run: |
cp scripts-build/PKGBUILD-msys2 PKGBUILD-msys2
tar -czf PKGBUILD-msys2-${{ needs.version-check.outputs.version }}.tar.gz PKGBUILD-msys2
# ── Homebrew formula with sha256 ──
- name: '🔑 Compute source tarball sha256'
id: hashes
run: |
curl -sL "https://github.com/AeonGames/AeonGUI/archive/v${{ needs.version-check.outputs.version }}.tar.gz" -o source.tar.gz
echo "sha256=$(sha256sum source.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: '📦 Package Homebrew formula'
run: |
sed -i 's/sha256 ""/sha256 "${{ steps.hashes.outputs.sha256 }}"/' scripts-build/aeongui.rb
tar -czf aeongui-brew-${{ needs.version-check.outputs.version }}.tar.gz -C scripts-build aeongui.rb
# ── vcpkg port ──
- name: '📦 Create vcpkg port archive'
run: |
tar -czf "aeongui-vcpkg-port-${{ needs.version-check.outputs.version }}.tar.gz" -C scripts-build/vcpkg-port .
# ── Upload everything ──
- name: '📤 Upload release assets'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version-check.outputs.version }}
files: |
*.pkg.tar.zst
PKGBUILD-arch-${{ needs.version-check.outputs.version }}.tar.gz
PKGBUILD-msys2-${{ needs.version-check.outputs.version }}.tar.gz
aeongui-brew-${{ needs.version-check.outputs.version }}.tar.gz
aeongui-vcpkg-port-${{ needs.version-check.outputs.version }}.tar.gz
# ── MSYS2 packages (mingw64, ucrt64, clang64 — Cairo) ─────────
msys2-package:
needs: [version-check, create-release]
if: needs.version-check.outputs.should_release == 'true'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sys: [mingw64, ucrt64, clang64]
include:
- { sys: mingw64, icon: '🟦' }
- { sys: ucrt64, icon: '🟨' }
- { sys: clang64, icon: '🟧' }
name: 📦${{ matrix.icon }} MSYS2 ${{ matrix.sys }}
defaults:
run:
shell: msys2 {0}
steps:
- name: '🧰 Checkout'
uses: actions/checkout@v6
with:
ref: v${{ needs.version-check.outputs.version }}
- name: '${{ matrix.icon }} Setup MSYS2'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
git
make
flex
bison
pacboy: >-
toolchain:p
cmake:p
make:p
- name: '🛠️ Configure to generate PKGBUILD'
run: |
cmake -G "MSYS Makefiles" -B build -DBUILD_SCRIPTS_ONLY=ON
cp build/PKGBUILD-msys2 PKGBUILD
- name: '📦 Build package'
env:
MINGW_ARCH: ${{ matrix.sys }}
run: makepkg-mingw -s --noconfirm --skippgpcheck
- name: '📤 Upload MSYS2 package'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version-check.outputs.version }}
files: '*.pkg.tar.zst'