| 1 | name: mingw-w64 |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [master] |
| 6 | pull_request: |
| 7 | branches: [master] |
| 8 | |
| 9 | concurrency: |
| 10 | group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | cancel-in-progress: true |
| 12 | |
| 13 | jobs: |
| 14 | build: |
| 15 | permissions: |
| 16 | contents: read |
| 17 | runs-on: windows-2022 |
| 18 | defaults: |
| 19 | run: |
| 20 | shell: msys2 {0} |
| 21 | steps: |
| 22 | - uses: msys2/setup-msys2@v2 |
| 23 | - uses: actions/checkout@v5 |
| 24 | with: |
| 25 | fetch-depth: 0 |
| 26 | - name: Compute version |
| 27 | id: version |
| 28 | run: | |
| 29 | VERSION=$(bash scripts/compute-version.sh) |
| 30 | echo "VERSION=$VERSION" >> "$GITHUB_ENV" |
| 31 | echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 32 | echo "Computed version: $VERSION" |
| 33 | - name: Install dependencies |
| 34 | run: pacman -S --noconfirm base-devel mingw-w64-x86_64-toolchain cmake ninja python |
| 35 | - name: Build with mingw-w64 |
| 36 | run: | |
| 37 | CC=/mingw64/bin/cc CXX=/mingw64/bin/c++ cmake \ |
| 38 | -B build -G Ninja \ |
| 39 | -DCMAKE_BUILD_TYPE=Release \ |
| 40 | -DCMAKE_INSTALL_PREFIX=$PWD/install \ |
| 41 | -DENABLE_GTEST=ON \ |
| 42 | -DBUILD_OPENCC_JIEBA_PLUGIN=ON \ |
| 43 | -DBUILD_SHARED_LIBS=OFF |
| 44 | cmake --build build |
| 45 | cmake --install build |
| 46 | - name: Run test |
| 47 | run: | |
| 48 | cd build |
| 49 | ctest |
| 50 | - name: Test standalone plugin build |
| 51 | run: | |
| 52 | CC=/mingw64/bin/cc CXX=/mingw64/bin/c++ cmake \ |
| 53 | -S plugins/jieba -B build-standalone -G Ninja \ |
| 54 | -DCMAKE_BUILD_TYPE=Release \ |
| 55 | -DOpenCC_DIR=$PWD/install/lib/cmake/opencc |
| 56 | cmake --build build-standalone |
| 57 | - name: list installed files |
| 58 | if: ${{ always() }} |
| 59 | run: | |
| 60 | echo "=== Contents of install/bin ===" |
| 61 | if [ -d install/bin ]; then ls -lh install/bin/; fi |
| 62 | echo -e "\n=== Contents of install/share/opencc ===" |
| 63 | if [ -d install/share/opencc ]; then ls -lh install/share/opencc/; fi |
| 64 | echo -e "\n=== All installed files ===" |
| 65 | if [ -d install ]; then find install -type f; fi |
| 66 | - name: upload artifacts |
| 67 | if: ${{ always() }} |
| 68 | uses: actions/upload-artifact@v7 |
| 69 | with: |
| 70 | name: opencc-${{ env.VERSION }}-mingw |
| 71 | path: | |
| 72 | install/** |
| 73 | build/src/tools/*.exe |
| 74 | build/Testing/** |
| 75 | build/ctest.log |