release.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. name: Release
  2. # Produces versioned distributables for all targets into a GitHub Release.
  3. # Targets that cannot be built on a given host (or fail) are skipped and logged
  4. # as ::warning:: — they never fail the whole release.
  5. # linux (deb/rpm/AppImage) + android (apk) -> ubuntu-latest
  6. # windows (exe) -> windows-latest
  7. # macos (dmg) + ios -> macos-latest
  8. # NOTE: iOS currently cannot be produced — the project has no iOS Kotlin target
  9. # (commonMain uses JVM-only libraries); the iOS step only logs a skip.
  10. on:
  11. workflow_dispatch:
  12. push:
  13. branches:
  14. - main
  15. tags:
  16. - 'v*'
  17. permissions:
  18. contents: write
  19. jobs:
  20. package:
  21. name: Package (${{ matrix.target }})
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. include:
  26. - os: ubuntu-latest
  27. target: linux-android
  28. - os: windows-latest
  29. target: windows
  30. - os: macos-latest
  31. target: macos-ios
  32. runs-on: ${{ matrix.os }}
  33. steps:
  34. - uses: actions/checkout@v4
  35. - name: Set up JDK 17
  36. uses: actions/setup-java@v4
  37. with:
  38. java-version: '17'
  39. distribution: 'temurin'
  40. - name: Setup Gradle
  41. uses: gradle/actions/setup-gradle@v4
  42. - name: Make gradlew executable
  43. shell: bash
  44. run: chmod +x gradlew || true
  45. - name: Read version
  46. id: ver
  47. shell: bash
  48. run: echo "version=$(grep -E '^app-pkg-version' gradle/libs.versions.toml | sed -E 's/.*"(.*)".*/\1/')" >> "$GITHUB_OUTPUT"
  49. # ---------- linux + android + reports (ubuntu) ----------
  50. - name: Build linux + android + reports
  51. if: matrix.os == 'ubuntu-latest'
  52. shell: bash
  53. continue-on-error: true
  54. run: |
  55. sudo apt-get update
  56. sudo apt-get install -y rpm || echo "::warning::rpm tools missing — .rpm may be skipped"
  57. # ISO toolchain (debootstrap/chroot/mksquashfs/grub+mtools) so buildAll's makeIso can
  58. # assemble the bootable live image; missing tools would just skip the ISO.
  59. sudo apt-get install -y debootstrap squashfs-tools xorriso mtools dpkg-dev \
  60. grub-common grub-pc-bin grub-efi-amd64-bin debian-archive-keyring \
  61. || echo "::warning::iso toolchain missing — .iso may be skipped"
  62. ./gradlew buildAll -PdepCheck=false --stacktrace || echo "::warning::linux/android buildAll failed — skipped"
  63. # makeIso is part of buildAll; surface whether the .iso was actually produced
  64. ls -la releases/*.iso 2>/dev/null && echo "ISO produced" || echo "::warning::no .iso in releases/ — makeIso skipped or failed"
  65. # ---------- windows (.exe) ----------
  66. - name: Build windows .exe
  67. if: matrix.os == 'windows-latest'
  68. shell: bash
  69. continue-on-error: true
  70. run: ./gradlew :desktopApp:packageReleaseExe --stacktrace || echo "::warning::windows .exe failed — skipped"
  71. # ---------- macos (.dmg) ----------
  72. - name: Build macOS .dmg
  73. if: matrix.os == 'macos-latest'
  74. shell: bash
  75. continue-on-error: true
  76. run: ./gradlew :desktopApp:packageReleaseDmg --stacktrace || echo "::warning::macOS .dmg failed — skipped"
  77. # ---------- ios (not available) ----------
  78. - name: iOS (skipped — no iOS target)
  79. if: matrix.os == 'macos-latest'
  80. shell: bash
  81. run: |
  82. echo "::warning::iOS skipped — project has no iOS Kotlin target (commonMain uses JVM-only libs vlcj/jna)"
  83. # ---------- collect whatever got produced ----------
  84. - name: Collect artifacts
  85. shell: bash
  86. run: |
  87. VER='${{ steps.ver.outputs.version }}'
  88. mkdir -p upload
  89. # linux/android: buildAll already wrote versioned files into releases/
  90. cp -v releases/* upload/ 2>/dev/null || true
  91. # desktop installers from jpackage (windows/mac, also deb/rpm if present)
  92. find packages -type f \( -name '*.exe' -o -name '*.msi' -o -name '*.dmg' -o -name '*.pkg' \) -exec cp -v {} upload/ \; 2>/dev/null || true
  93. # reports copied into the release (zipped tree)
  94. if [ -d reports ] && [ -n "$(ls -A reports 2>/dev/null)" ]; then
  95. (cd reports && zip -r "../upload/mjdev-desktop-${VER}-reports.zip" .) || echo "::warning::reports zip failed"
  96. fi
  97. echo "=== produced for ${{ matrix.target }} ==="; ls -la upload/ || true
  98. - name: Upload build artifacts
  99. if: always()
  100. uses: actions/upload-artifact@v4
  101. with:
  102. name: dist-${{ matrix.target }}
  103. path: upload/
  104. if-no-files-found: warn
  105. release:
  106. name: Publish GitHub Release
  107. needs: package
  108. if: always()
  109. runs-on: ubuntu-latest
  110. steps:
  111. - uses: actions/checkout@v4
  112. - name: Read version
  113. id: ver
  114. shell: bash
  115. run: echo "version=$(grep -E '^app-pkg-version' gradle/libs.versions.toml | sed -E 's/.*"(.*)".*/\1/')" >> "$GITHUB_OUTPUT"
  116. - name: Download all artifacts
  117. uses: actions/download-artifact@v4
  118. with:
  119. path: dist
  120. merge-multiple: true
  121. - name: List collected
  122. shell: bash
  123. run: ls -la dist/ || echo "no artifacts produced"
  124. - name: Publish to GitHub Release
  125. uses: softprops/action-gh-release@v2
  126. with:
  127. tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('v{0}', steps.ver.outputs.version) }}
  128. name: mjdev-desktop v${{ steps.ver.outputs.version }}
  129. files: dist/**
  130. fail_on_unmatched_files: false
  131. env:
  132. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}