Skip to content

Commit ed9f5f5

Browse files
authored
Merge pull request #226 from SQFvm/ci-workflow
Update CI workflow and update actions versions
2 parents ea66b8a + babc486 commit ed9f5f5

1 file changed

Lines changed: 83 additions & 68 deletions

File tree

.github/workflows/ci.yml

Lines changed: 83 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,37 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
workflow_dispatch:
48

59
jobs:
6-
linux_x64_gcc:
7-
name: Linux x64 (GCC)
10+
linux:
11+
name: Linux x64 (${{ matrix.compiler.name }})
812
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
compiler:
17+
- { name: GCC, cc: gcc, cxx: g++, artifact: sqfvm_linux_x64_gcc, cxxflags: "-Wno-changes-meaning" }
18+
- { name: Clang, cc: clang, cxx: clang++, artifact: sqfvm_linux_x64_clang, cxxflags: "" }
919
steps:
10-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
1121

12-
- name: Build Linux x64
13-
run: mkdir build && cd build && cmake .. && cmake --build . --parallel 2
14-
env:
15-
CC: gcc-9
16-
CXX: g++-9
17-
18-
- name: Upload Linux x64 binaries
19-
uses: actions/upload-artifact@v2
20-
with:
21-
name: sqfvm_linux_x64_gcc
22-
path: build/sqfvm*
23-
24-
- name: Run SQF-VM Tests
25-
working-directory: build
26-
run: ctest --output-on-failure
27-
28-
- name: Run CBA A3 Tests
29-
run: PATH=build:$PATH python tests/cba/cba_a3.py
30-
31-
linux_x64_clang:
32-
name: Linux x64 (Clang)
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v2
36-
37-
- name: Build Linux x64
38-
run: mkdir build && cd build && cmake .. && cmake --build . --parallel 2
22+
- name: Build
23+
run: |
24+
cmake -B build
25+
cmake --build build --parallel $(nproc)
3926
env:
40-
CC: clang
41-
CXX: clang++
27+
CC: ${{ matrix.compiler.cc }}
28+
CXX: ${{ matrix.compiler.cxx }}
29+
CXXFLAGS: ${{ matrix.compiler.cxxflags }}
4230

43-
- name: Upload Linux x64 binaries
44-
uses: actions/upload-artifact@v2
31+
- name: Upload binaries
32+
uses: actions/upload-artifact@v4
4533
with:
46-
name: sqfvm_linux_x64_clang
34+
name: ${{ matrix.compiler.artifact }}
4735
path: build/sqfvm*
4836

4937
- name: Run SQF-VM Tests
@@ -57,13 +45,15 @@ jobs:
5745
name: macOS
5846
runs-on: macos-latest
5947
steps:
60-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
6149

62-
- name: Build macOS
63-
run: mkdir build && cd build && cmake .. && cmake --build . --parallel 2
64-
65-
- name: Upload macOS binaries
66-
uses: actions/upload-artifact@v2
50+
- name: Build
51+
run: |
52+
cmake -B build
53+
cmake --build build --parallel $(sysctl -n hw.ncpu)
54+
55+
- name: Upload binaries
56+
uses: actions/upload-artifact@v4
6757
with:
6858
name: sqfvm_macos
6959
path: build/sqfvm*
@@ -75,19 +65,27 @@ jobs:
7565
- name: Run CBA A3 Tests
7666
run: PATH=build:$PATH python tests/cba/cba_a3.py
7767

78-
windows_win32:
79-
name: Windows Win32
68+
windows:
69+
name: Windows ${{ matrix.arch }}
8070
runs-on: windows-latest
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
include:
75+
- { arch: Win32, cmake_arch: Win32, artifact: sqfvm_windows_win32 }
76+
- { arch: x64, cmake_arch: x64, artifact: sqfvm_windows_x64 }
8177
steps:
82-
- uses: actions/checkout@v2
78+
- uses: actions/checkout@v4
8379

84-
- name: Build Windows Win32
85-
run: mkdir build && cd build && cmake -A Win32 .. && cmake --build . --config Release
80+
- name: Build
81+
run: |
82+
cmake -B build -A ${{ matrix.cmake_arch }}
83+
cmake --build build --config Release --parallel $env:NUMBER_OF_PROCESSORS
8684
87-
- name: Upload Windows Win32 binaries
88-
uses: actions/upload-artifact@v2
85+
- name: Upload binaries
86+
uses: actions/upload-artifact@v4
8987
with:
90-
name: sqfvm_windows_win32
88+
name: ${{ matrix.artifact }}
9189
path: build/Release/*.exe
9290

9391
- name: Run SQF-VM Tests
@@ -99,26 +97,43 @@ jobs:
9997
$env:Path += ";build/Release/"
10098
python tests/cba/cba_a3.py
10199
102-
windows_x64:
103-
name: Windows x64
104-
runs-on: windows-latest
100+
# ── Release ────────────────────────────────────────────────────────
101+
# Only runs on push-to-master (not PRs, not workflow_dispatch).
102+
# Waits for every CI job to pass before publishing.
103+
release:
104+
name: Publish Release
105+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
106+
needs: [linux, macos, windows]
107+
runs-on: ubuntu-latest
108+
permissions:
109+
contents: write # required to create releases & tags
105110
steps:
106-
- uses: actions/checkout@v2
111+
- uses: actions/checkout@v4
107112

108-
- name: Build Windows x64
109-
run: mkdir build && cd build && cmake -A x64 .. && cmake --build . --config Release
110-
111-
- name: Upload Windows x64 binaries
112-
uses: actions/upload-artifact@v2
113+
- name: Download all artifacts
114+
uses: actions/download-artifact@v4
113115
with:
114-
name: sqfvm_windows_x64
115-
path: build/Release/*.exe
116-
117-
- name: Run SQF-VM Tests
118-
working-directory: build
119-
run: ctest --output-on-failure -C Release
116+
path: artifacts/
120117

121-
- name: Run CBA A3 Tests
118+
- name: Package artifacts
122119
run: |
123-
$env:Path += ";build/Release/"
124-
python tests/cba/cba_a3.py
120+
cd artifacts
121+
for dir in */; do
122+
name="${dir%/}"
123+
zip -r "../${name}.zip" "$dir"
124+
done
125+
126+
- name: Generate release tag
127+
id: tag
128+
run: |
129+
TAG="v$(date -u +'%Y.%m.%d')-${GITHUB_SHA::7}"
130+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
131+
echo "Generated tag: $TAG"
132+
133+
- name: Create GitHub Release
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
tag_name: ${{ steps.tag.outputs.tag }}
137+
name: Build ${{ steps.tag.outputs.tag }}
138+
generate_release_notes: true
139+
files: "*.zip"

0 commit comments

Comments
 (0)