build.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. name: GitHub CI
  2. on:
  3. push:
  4. branches: [ master ]
  5. tags:
  6. - '**'
  7. workflow_dispatch:
  8. pull_request:
  9. concurrency:
  10. group: ${{ github.ref }}-${{ github.workflow }}
  11. cancel-in-progress: true
  12. jobs:
  13. linux_build:
  14. strategy:
  15. matrix:
  16. include:
  17. - arch: x86
  18. artifact: subconverter_linux32
  19. os: ubuntu-latest
  20. - arch: amd64
  21. artifact: subconverter_linux64
  22. os: ubuntu-latest
  23. - arch: armv7
  24. artifact: subconverter_armv7
  25. os: ubuntu-24.04-arm
  26. - arch: aarch64
  27. artifact: subconverter_aarch64
  28. os: ubuntu-24.04-arm
  29. runs-on: ${{ matrix.os }}
  30. name: Linux ${{ matrix.arch }} Build
  31. steps:
  32. - name: Checkout base
  33. uses: actions/checkout@v4
  34. - name: Add commit id into version
  35. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  36. run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
  37. - name: Build
  38. run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:${{ matrix.arch }}-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
  39. - name: Upload
  40. uses: actions/upload-artifact@v4
  41. with:
  42. name: ${{ matrix.artifact }}
  43. path: subconverter/
  44. - name: Package Release
  45. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  46. run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
  47. - name: Draft Release
  48. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  49. uses: softprops/action-gh-release@v2
  50. with:
  51. files: ${{ matrix.artifact }}.tar.gz
  52. draft: true
  53. macos_build:
  54. strategy:
  55. matrix:
  56. include:
  57. - arch: x86
  58. artifact: subconverter_darwin64
  59. os: macos-15-intel
  60. - arch: arm
  61. artifact: subconverter_darwinarm
  62. os: macos-latest
  63. runs-on: ${{ matrix.os }}
  64. name: macOS ${{ matrix.arch }} Build
  65. steps:
  66. - name: Checkout base
  67. uses: actions/checkout@v4
  68. - name: Setup Python
  69. uses: actions/setup-python@v5
  70. with:
  71. python-version: '3.11'
  72. - name: Add commit id into version
  73. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  74. run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
  75. - name: Build
  76. run: bash scripts/build.macos.release.sh
  77. - name: Upload
  78. uses: actions/upload-artifact@v4
  79. with:
  80. name: ${{ matrix.artifact }}
  81. path: subconverter/
  82. - name: Package Release
  83. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  84. run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
  85. - name: Draft Release
  86. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  87. uses: softprops/action-gh-release@v2
  88. with:
  89. files: ${{ matrix.artifact }}.tar.gz
  90. draft: true
  91. windows_build:
  92. strategy:
  93. matrix:
  94. include:
  95. - arch: x86
  96. artifact: subconverter_win32
  97. env: i686
  98. msystem: MINGW32
  99. - arch: amd64
  100. artifact: subconverter_win64
  101. env: x86_64
  102. msystem: MINGW64
  103. runs-on: windows-latest
  104. name: Windows ${{ matrix.arch }} Build
  105. defaults:
  106. run:
  107. shell: msys2 {0}
  108. steps:
  109. - name: Checkout base
  110. uses: actions/checkout@v4
  111. - name: Setup Python
  112. uses: actions/setup-python@v5
  113. with:
  114. python-version: '3.11'
  115. - name: Setup Node.js
  116. uses: actions/setup-node@v4
  117. with:
  118. node-version: '16'
  119. - name: Setup MSYS2
  120. uses: msys2/setup-msys2@v2
  121. with:
  122. update: true
  123. install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch
  124. msystem: ${{ matrix.msystem }}
  125. path-type: inherit
  126. - name: Add commit id into version
  127. if: ${{ !startsWith(github.ref, 'refs/tags/') }}
  128. run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
  129. - name: Build
  130. run: bash scripts/build.windows.release.sh
  131. - name: Upload
  132. uses: actions/upload-artifact@v4
  133. with:
  134. name: ${{ matrix.artifact }}
  135. path: subconverter/
  136. - name: Package Release
  137. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  138. run: 7z a ${{ matrix.artifact }}.7z subconverter/
  139. - name: Draft Release
  140. if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
  141. uses: softprops/action-gh-release@v2
  142. with:
  143. files: ${{ matrix.artifact }}.7z
  144. draft: true