Skip to content

Commit d2b79df

Browse files
committed
Refactor GitHub Actions workflow to consolidate build jobs and add MinGW toolchain support for Windows
1 parent 2a2821b commit d2b79df

2 files changed

Lines changed: 34 additions & 45 deletions

File tree

.github/workflows/build.yml

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,39 @@ permissions:
1111
contents: write
1212

1313
jobs:
14-
build-windows-mingw:
15-
runs-on: windows-latest
16-
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
submodules: recursive
20-
- name: Set up MinGW
21-
run: |
22-
choco install mingw
23-
echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" >> $env:GITHUB_PATH
24-
- name: Configure CMake
25-
run: cmake -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
26-
- name: Build
27-
run: cmake --build build
28-
- name: Rename executable
29-
run: move build\ghostinjector-*.exe build\ghostinjector.exe
30-
- uses: actions/upload-artifact@v4
31-
with:
32-
name: ghostinjector-windows
33-
path: build/ghostinjector.exe
34-
35-
build-linux-gcc:
14+
build-and-release:
3615
runs-on: ubuntu-latest
16+
3717
steps:
38-
- uses: actions/checkout@v4
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
3920
with:
4021
submodules: recursive
22+
4123
- name: Install dependencies
42-
run: sudo apt-get update && sudo apt-get install -y build-essential
43-
- name: Configure CMake
44-
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
45-
- name: Build
46-
run: cmake --build build
47-
- name: Rename executable
48-
run: mv build/ghostinjector-* build/ghostinjector
49-
- uses: actions/upload-artifact@v4
50-
with:
51-
name: ghostinjector-linux
52-
path: build/ghostinjector
53-
54-
release:
55-
runs-on: ubuntu-latest
56-
needs: [build-windows-mingw, build-linux-gcc]
57-
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || startsWith(github.ref, 'refs/tags/v')
58-
steps:
59-
- uses: actions/download-artifact@v4
60-
with:
61-
path: artifacts
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y build-essential mingw-w64
27+
28+
# Build for Linux
29+
- name: Configure CMake for Linux
30+
run: cmake -B build-linux -DCMAKE_BUILD_TYPE=Release
31+
- name: Build for Linux
32+
run: cmake --build build-linux
33+
- name: Rename Linux executable
34+
run: mv build-linux/ghostinjector-* build-linux/ghostinjector
35+
36+
# Build for Windows
37+
- name: Configure CMake for Windows
38+
run: |
39+
cmake -B build-windows -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw.cmake -DCMAKE_BUILD_TYPE=Release
40+
- name: Build for Windows
41+
run: cmake --build build-windows
42+
- name: Rename Windows executable
43+
run: mv build-windows/ghostinjector-*.exe build-windows/ghostinjector.exe
44+
6245
- name: Create Release
46+
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || startsWith(github.ref, 'refs/tags/v')
6347
uses: softprops/action-gh-release@v2
6448
with:
6549
tag_name: ${{ (github.ref == 'refs/heads/main' && 'latest') || github.ref_name }}
@@ -73,8 +57,8 @@ jobs:
7357
- **Windows:** `ghostinjector.exe`
7458
- **Linux:** `ghostinjector`
7559
files: |
76-
artifacts/ghostinjector-windows/ghostinjector.exe
77-
artifacts/ghostinjector-linux/ghostinjector
60+
build-windows/ghostinjector.exe
61+
build-linux/ghostinjector
7862
draft: false
7963
prerelease: ${{ github.ref == 'refs/heads/main' }}
8064
make_latest: ${{ github.ref == 'refs/heads/main' }}

toolchain-mingw.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# toolchain-mingw.cmake
2+
set(CMAKE_SYSTEM_NAME Windows)
3+
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
4+
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
5+
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)

0 commit comments

Comments
 (0)