Skip to content

Commit ebe9dca

Browse files
committed
Break c-cpp build in unix and windows workflows
1 parent 6e54af5 commit ebe9dca

2 files changed

Lines changed: 81 additions & 69 deletions

File tree

.github/workflows/c-cpp-build-template.yml

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -161,72 +161,3 @@ jobs:
161161
with:
162162
name: macos-dist
163163
path: "${{ steps.detect.outputs.dir }}/dist/*.tar.gz"
164-
c-cpp-windows-build-template:
165-
runs-on: windows-2025
166-
steps:
167-
- name: Checkout code
168-
uses: actions/checkout@v5
169-
with:
170-
persist-credentials: false
171-
- name: Install and setup MSYS2 with MinGW64
172-
uses: msys2/setup-msys2@fb197b72ce45fb24f17bf3f807a388985654d1f2
173-
with:
174-
msystem: MINGW64
175-
update: true
176-
install: >-
177-
base-devel
178-
autoconf
179-
automake
180-
libtool
181-
mingw-w64-x86_64-toolchain
182-
mingw-w64-x86_64-make
183-
mingw-w64-x86_64-pkgconf
184-
mingw-w64-x86_64-libpcap
185-
mingw-w64-x86_64-tcl
186-
- name: Detect working directory
187-
id: detect
188-
run: |
189-
if [[ -d c-cpp ]]; then
190-
echo "dir=c-cpp" >> "${GITHUB_OUTPUT}"
191-
else
192-
echo "dir=." >> "${GITHUB_OUTPUT}"
193-
fi
194-
- name: Configure and build
195-
working-directory: ${{ steps.detect.outputs.dir }}
196-
shell: msys2 {0}
197-
run: |
198-
[[ -x ./autogen.sh ]] && ./autogen.sh
199-
[[ -x ./configure ]] && ./configure --host=x86_64-w64-mingw64
200-
[[ -s Makefile ]] || {
201-
echo "I couldn't find an autogen.sh, configure, or Makefile."
202-
echo "Please check your files."
203-
exit 1
204-
}
205-
make
206-
- name: Get properties from configure.ac
207-
working-directory: ${{ steps.detect.outputs.dir }}
208-
id: props
209-
run: |
210-
name="$(sed -n 's/AC_INIT(\[\([^]]*\)\],.*/\1/p' configure.ac)"
211-
echo "name=${name}" >> "${GITHUB_OUTPUT}"
212-
version="$(sed -n 's/AC_INIT(\[[^]]*\], \[\([^]]*\)\], \[[^]]*\])/\1/p' configure.ac)"
213-
echo "version=${version}" >> "${GITHUB_OUTPUT}"
214-
- name: Create source package
215-
working-directory: ${{ steps.detect.outputs.dir }}
216-
run: |
217-
make dist
218-
- name: Create Windows binary package
219-
working-directory: ${{ steps.detect.outputs.dir }}
220-
run: |
221-
make binary-dist
222-
- name: Prepare packages to distribution
223-
working-directory: ${{ steps.detect.outputs.dir }}
224-
run: |
225-
md dist
226-
move "${{ steps.props.outputs.name }}-${{ steps.props.outputs.version }}-bin.zip" ^
227-
"dist/${{ steps.props.outputs.name }}-${{ steps.props.outputs.version }}-windows.zip"
228-
- name: Upload Windows artifacts
229-
uses: actions/upload-artifact@v4
230-
with:
231-
name: windows-dist
232-
path: "${{ steps.detect.outputs.dir }}/dist/*.zip"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 Fabrício Barros Cabral
2+
# SPDX-License-Identifier: MIT
3+
---
4+
# yamllint disable rule:line-length
5+
name: c-cpp-windows-build-template
6+
'on':
7+
workflow_call:
8+
defaults:
9+
run:
10+
shell: msys2 {0}
11+
permissions:
12+
contents: read
13+
jobs:
14+
c-cpp-windows-build-template:
15+
runs-on: windows-2025
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v5
19+
with:
20+
persist-credentials: false
21+
- name: Install and setup MSYS2 with MinGW64
22+
uses: msys2/setup-msys2@fb197b72ce45fb24f17bf3f807a388985654d1f2
23+
with:
24+
msystem: MINGW64
25+
update: true
26+
install: >-
27+
base-devel
28+
autoconf
29+
automake
30+
libtool
31+
mingw-w64-x86_64-toolchain
32+
mingw-w64-x86_64-make
33+
mingw-w64-x86_64-pkgconf
34+
mingw-w64-x86_64-libpcap
35+
mingw-w64-x86_64-tcl
36+
- name: Detect working directory
37+
id: detect
38+
run: |
39+
if [[ -d c-cpp ]]; then
40+
echo "dir=c-cpp" >> "${GITHUB_OUTPUT}"
41+
else
42+
echo "dir=." >> "${GITHUB_OUTPUT}"
43+
fi
44+
- name: Configure and build
45+
working-directory: ${{ steps.detect.outputs.dir }}
46+
run: |
47+
[[ -x ./autogen.sh ]] && ./autogen.sh
48+
[[ -x ./configure ]] && ./configure --host=x86_64-w64-mingw64
49+
[[ -s Makefile ]] || {
50+
echo "I couldn't find an autogen.sh, configure, or Makefile."
51+
echo "Please check your files."
52+
exit 1
53+
}
54+
make
55+
- name: Get properties from configure.ac
56+
working-directory: ${{ steps.detect.outputs.dir }}
57+
id: props
58+
run: |
59+
name="$(sed -n 's/AC_INIT(\[\([^]]*\)\],.*/\1/p' configure.ac)"
60+
echo "name=${name}" >> "${GITHUB_OUTPUT}"
61+
version="$(sed -n 's/AC_INIT(\[[^]]*\], \[\([^]]*\)\], \[[^]]*\])/\1/p' configure.ac)"
62+
echo "version=${version}" >> "${GITHUB_OUTPUT}"
63+
- name: Create source package
64+
working-directory: ${{ steps.detect.outputs.dir }}
65+
run: |
66+
make dist
67+
- name: Create Windows binary package
68+
working-directory: ${{ steps.detect.outputs.dir }}
69+
run: |
70+
make binary-dist
71+
- name: Prepare packages to distribution
72+
working-directory: ${{ steps.detect.outputs.dir }}
73+
run: |
74+
md dist
75+
move "${{ steps.props.outputs.name }}-${{ steps.props.outputs.version }}-bin.zip" ^
76+
"dist/${{ steps.props.outputs.name }}-${{ steps.props.outputs.version }}-windows.zip"
77+
- name: Upload Windows artifacts
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: windows-dist
81+
path: "${{ steps.detect.outputs.dir }}/dist/*.zip"

0 commit comments

Comments
 (0)