|
| 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