Skip to content

Commit 141ebdc

Browse files
committed
feat: update release workflow
1 parent 71763aa commit 141ebdc

5 files changed

Lines changed: 264 additions & 183 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ assets/drone
113113
assets/monster
114114

115115
docker/
116+
.github

.github/workflows/release.yml

Lines changed: 231 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,238 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*.*.*"
4+
push:
5+
tags:
6+
- "v*.*.*"
77

88
permissions:
9-
contents: write
9+
contents: write
1010

1111
jobs:
12-
validate-tag:
13-
name: Validate Tag
14-
runs-on: ubuntu-latest
15-
outputs:
16-
version: ${{ steps.parse.outputs.version }}
17-
steps:
18-
- name: Parse version from tag
19-
id: parse
20-
run: |
21-
TAG="${GITHUB_REF#refs/tags/}"
22-
# Validate semver format: vMAJOR.MINOR.PATCH with optional pre-release
23-
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
24-
echo "Error: Tag '$TAG' does not follow semantic versioning (vX.Y.Z)"
25-
exit 1
26-
fi
27-
VERSION="${TAG#v}"
28-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29-
echo "Valid semver tag: $TAG (version: $VERSION)"
30-
31-
build-release:
32-
name: Build (${{ matrix.name }})
33-
needs: validate-tag
34-
runs-on: ${{ matrix.os }}
35-
strategy:
36-
fail-fast: false
37-
matrix:
38-
os: [ubuntu-latest, windows-latest]
39-
include:
40-
- name: Linux
41-
os: ubuntu-latest
42-
artifact-name: game-linux
43-
generator: Ninja
44-
- name: Windows
45-
os: windows-latest
46-
artifact-name: game-windows
47-
generator: "Visual Studio 17 2022"
48-
49-
steps:
50-
- name: Checkout repository
51-
uses: actions/checkout@v6
52-
with:
53-
submodules: recursive
54-
fetch-depth: 1
55-
56-
- name: Install dependencies (Linux)
57-
if: runner.os == 'Linux'
58-
run: |
59-
sudo apt-get update
60-
sudo apt-get install -y \
61-
cmake ninja-build \
62-
libgl1-mesa-dev \
63-
libx11-dev libxrandr-dev libxi-dev \
64-
libxinerama-dev libxcursor-dev \
65-
libpipewire-0.3-dev pkg-config
66-
67-
- name: Configure (Release)
68-
run: >
69-
cmake -S . -B build
70-
-G "${{ matrix.generator }}"
71-
-DCMAKE_BUILD_TYPE=Release
72-
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
73-
-DCMAKE_INSTALL_PREFIX=install
74-
shell: bash
75-
76-
- name: Build
77-
run: cmake --build build --config Release -j 4
78-
shell: bash
79-
80-
- name: Install
81-
run: cmake --install build --config Release
82-
shell: bash
83-
84-
- name: Package artifact
85-
run: |
86-
cd install
87-
tar -czf ../${{ matrix.artifact-name }}-${{ needs.validate-tag.outputs.version }}.tar.gz .
88-
shell: bash
89-
90-
- name: Upload artifact
91-
uses: actions/upload-artifact@v6
92-
with:
93-
name: ${{ matrix.artifact-name }}
94-
path: ${{ matrix.artifact-name }}-${{ needs.validate-tag.outputs.version }}.tar.gz
95-
retention-days: 90
96-
97-
create-release:
98-
name: Create GitHub Release
99-
needs: [validate-tag, build-release]
100-
runs-on: ubuntu-latest
101-
102-
steps:
103-
- name: Checkout repository
104-
uses: actions/checkout@v6
105-
with:
106-
fetch-depth: 0
107-
108-
- name: Download all artifacts
109-
uses: actions/download-artifact@v8
110-
with:
111-
path: release-assets
112-
merge-multiple: true
113-
114-
- name: Generate changelog from commits
115-
id: changelog
116-
run: |
117-
VERSION="v${{ needs.validate-tag.outputs.version }}"
118-
119-
# Find previous tag
120-
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | sed -n '2p')
121-
122-
if [ -n "$PREV_TAG" ]; then
123-
RANGE="${PREV_TAG}..${VERSION}"
124-
echo "Generating changelog for $RANGE"
125-
else
126-
RANGE="${VERSION}"
127-
echo "No previous tag found, listing all commits up to ${VERSION}"
128-
fi
129-
130-
{
131-
echo "changelog<<EOF"
132-
echo "## What's Changed"
133-
echo ""
134-
135-
# Group commits by type
136-
for type_label in "feat:Features" "fix:Bug Fixes" "refactor:Refactors" "perf:Performance" "docs:Documentation" "chore:Chores"; do
137-
type="${type_label%%:*}"
138-
label="${type_label#*:}"
139-
140-
COMMITS=$(git log "$RANGE" --oneline --grep="^${type}" 2>/dev/null || true)
141-
if [ -n "$COMMITS" ]; then
142-
echo "### $label"
143-
echo "$COMMITS" | while read -r line; do
144-
echo "- $line"
145-
done
146-
echo ""
147-
fi
148-
done
149-
150-
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG:-main}...${VERSION}"
151-
echo "EOF"
152-
} >> "$GITHUB_OUTPUT"
153-
154-
- name: Create GitHub Release
155-
uses: softprops/action-gh-release@v2
156-
with:
157-
tag_name: v${{ needs.validate-tag.outputs.version }}
158-
name: Release v${{ needs.validate-tag.outputs.version }}
159-
body: ${{ steps.changelog.outputs.changelog }}
160-
draft: false
161-
prerelease: ${{ contains(needs.validate-tag.outputs.version, '-') }}
162-
files: release-assets/*
12+
validate-tag:
13+
name: Validate Tag
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version: ${{ steps.parse.outputs.version }}
17+
steps:
18+
- name: Parse version from tag
19+
id: parse
20+
run: |
21+
TAG="${GITHUB_REF#refs/tags/}"
22+
# Validate semver format: vMAJOR.MINOR.PATCH with optional pre-release
23+
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
24+
echo "Error: Tag '$TAG' does not follow semantic versioning (vX.Y.Z)"
25+
exit 1
26+
fi
27+
VERSION="${TAG#v}"
28+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+
echo "Valid semver tag: $TAG (version: $VERSION)"
30+
31+
build-release:
32+
name: Build (${{ matrix.name }})
33+
needs: validate-tag
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os: [ubuntu-latest, windows-latest]
39+
include:
40+
- name: Linux
41+
os: ubuntu-latest
42+
artifact-name: game-linux
43+
generator: Ninja
44+
- name: Windows
45+
os: windows-latest
46+
artifact-name: game-windows
47+
generator: "Visual Studio 17 2022"
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v6
52+
with:
53+
submodules: recursive
54+
fetch-depth: 1
55+
56+
- name: Install dependencies (Linux)
57+
if: runner.os == 'Linux'
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y \
61+
cmake ninja-build \
62+
libgl1-mesa-dev \
63+
libx11-dev libxrandr-dev libxi-dev \
64+
libxinerama-dev libxcursor-dev \
65+
libpipewire-0.3-dev pkg-config
66+
67+
- name: ccache
68+
uses: hendrikmuhs/ccache-action@v1.2
69+
70+
- name: Cache build directory
71+
uses: actions/cache@v5
72+
with:
73+
path: build
74+
key: build-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt', 'src/**') }}
75+
restore-keys: |
76+
build-${{ matrix.os }}-
77+
78+
- name: Configure (Release)
79+
run: >
80+
cmake -S . -B build
81+
-G "${{ matrix.generator }}"
82+
-DCMAKE_BUILD_TYPE=Release
83+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
84+
-DCMAKE_INSTALL_PREFIX=install
85+
shell: bash
86+
87+
- name: Build
88+
run: cmake --build build --config Release -j 4
89+
shell: bash
90+
91+
- name: Install
92+
run: cmake --install build --config Release
93+
shell: bash
94+
95+
- name: Package artifact
96+
run: |
97+
cd install
98+
mv bin/ArenaRush ../
99+
tar -czf ../${{ matrix.artifact-name }}-${{ needs.validate-tag.outputs.version }}.tar.gz .
100+
shell: bash
101+
102+
- name: Upload artifact
103+
uses: actions/upload-artifact@v6
104+
with:
105+
name: ${{ matrix.artifact-name }}
106+
path: ${{ matrix.artifact-name }}-${{ needs.validate-tag.outputs.version }}.tar.gz
107+
retention-days: 90
108+
109+
build-rpm:
110+
name: Build RPM (Fedora)
111+
needs: validate-tag
112+
runs-on: ubuntu-latest
113+
114+
steps:
115+
- name: Checkout repository
116+
uses: actions/checkout@v6
117+
with:
118+
submodules: recursive
119+
fetch-depth: 1
120+
121+
- name: Build RPM in Docker
122+
run: |
123+
docker build -f docker/Dockerfile.fedora -t arena-rush-rpm .
124+
125+
- name: Extract RPM from container
126+
run: |
127+
CONTAINER_ID=$(docker create arena-rush-rpm)
128+
docker cp "$CONTAINER_ID:/app/rpm-out" ./rpm-out
129+
docker rm "$CONTAINER_ID"
130+
for f in rpm-out/*.rpm; do
131+
echo "Found package: $f"
132+
done
133+
134+
- name: Upload RPM artifact
135+
uses: actions/upload-artifact@v6
136+
with:
137+
name: game-rpm
138+
path: rpm-out/*.rpm
139+
retention-days: 90
140+
141+
build-pacman:
142+
name: Build Pacman Package (Arch)
143+
needs: validate-tag
144+
runs-on: ubuntu-latest
145+
146+
steps:
147+
- name: Checkout repository
148+
uses: actions/checkout@v6
149+
with:
150+
submodules: recursive
151+
fetch-depth: 1
152+
153+
- name: Build Pacman package in Docker
154+
run: |
155+
docker build -f docker/Dockerfile.arch -t arena-rush-pacman .
156+
157+
- name: Extract package from container
158+
run: |
159+
CONTAINER_ID=$(docker create arena-rush-pacman)
160+
docker cp "$CONTAINER_ID:/app/pkg-out" ./pacman-out
161+
docker rm "$CONTAINER_ID"
162+
for f in pacman-out/*.pkg.tar.zst; do
163+
echo "Found package: $f"
164+
done
165+
166+
- name: Upload Pacman artifact
167+
uses: actions/upload-artifact@v6
168+
with:
169+
name: game-pacman
170+
path: pacman-out/*.pkg.tar.zst
171+
retention-days: 90
172+
173+
create-release:
174+
name: Create GitHub Release
175+
needs: [validate-tag, build-release, build-rpm, build-pacman]
176+
runs-on: ubuntu-latest
177+
178+
steps:
179+
- name: Checkout repository
180+
uses: actions/checkout@v6
181+
with:
182+
fetch-depth: 0
183+
184+
- name: Download all artifacts
185+
uses: actions/download-artifact@v8
186+
with:
187+
path: release-assets
188+
merge-multiple: true
189+
190+
- name: Generate changelog from commits
191+
id: changelog
192+
run: |
193+
VERSION="v${{ needs.validate-tag.outputs.version }}"
194+
195+
# Find previous tag
196+
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | sed -n '2p')
197+
198+
if [ -n "$PREV_TAG" ]; then
199+
RANGE="${PREV_TAG}..${VERSION}"
200+
echo "Generating changelog for $RANGE"
201+
else
202+
RANGE="${VERSION}"
203+
echo "No previous tag found, listing all commits up to ${VERSION}"
204+
fi
205+
206+
{
207+
echo "changelog<<EOF"
208+
echo "## What's Changed"
209+
echo ""
210+
211+
# Group commits by type
212+
for type_label in "feat:Features" "fix:Bug Fixes" "refactor:Refactors" "perf:Performance" "docs:Documentation" "chore:Chores"; do
213+
type="${type_label%%:*}"
214+
label="${type_label#*:}"
215+
216+
COMMITS=$(git log "$RANGE" --oneline --grep="^${type}" 2>/dev/null || true)
217+
if [ -n "$COMMITS" ]; then
218+
echo "### $label"
219+
echo "$COMMITS" | while read -r line; do
220+
echo "- $line"
221+
done
222+
echo ""
223+
fi
224+
done
225+
226+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG:-main}...${VERSION}"
227+
echo "EOF"
228+
} >> "$GITHUB_OUTPUT"
229+
230+
- name: Create GitHub Release
231+
uses: softprops/action-gh-release@v2
232+
with:
233+
tag_name: v${{ needs.validate-tag.outputs.version }}
234+
name: Release v${{ needs.validate-tag.outputs.version }}
235+
body: ${{ steps.changelog.outputs.changelog }}
236+
draft: false
237+
prerelease: ${{ contains(needs.validate-tag.outputs.version, '-') }}
238+
files: release-assets/*

0 commit comments

Comments
 (0)