release.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 && sudo apt-get install -y rpm || echo "::warning::rpm tools missing — .rpm may be skipped"
  56. ./gradlew buildAll -PdepCheck=false --stacktrace || echo "::warning::linux/android buildAll failed — skipped"
  57. # ---------- windows (.exe) ----------
  58. - name: Build windows .exe
  59. if: matrix.os == 'windows-latest'
  60. shell: bash
  61. continue-on-error: true
  62. run: ./gradlew :desktopApp:packageReleaseExe --stacktrace || echo "::warning::windows .exe failed — skipped"
  63. # ---------- macos (.dmg) ----------
  64. - name: Build macOS .dmg
  65. if: matrix.os == 'macos-latest'
  66. shell: bash
  67. continue-on-error: true
  68. run: ./gradlew :desktopApp:packageReleaseDmg --stacktrace || echo "::warning::macOS .dmg failed — skipped"
  69. # ---------- ios (not available) ----------
  70. - name: iOS (skipped — no iOS target)
  71. if: matrix.os == 'macos-latest'
  72. shell: bash
  73. run: |
  74. echo "::warning::iOS skipped — project has no iOS Kotlin target (commonMain uses JVM-only libs vlcj/jna)"
  75. # ---------- collect whatever got produced ----------
  76. - name: Collect artifacts
  77. shell: bash
  78. run: |
  79. VER='${{ steps.ver.outputs.version }}'
  80. mkdir -p upload
  81. # linux/android: buildAll already wrote versioned files into releases/
  82. cp -v releases/* upload/ 2>/dev/null || true
  83. # desktop installers from jpackage (windows/mac, also deb/rpm if present)
  84. find packages -type f \( -name '*.exe' -o -name '*.msi' -o -name '*.dmg' -o -name '*.pkg' \) -exec cp -v {} upload/ \; 2>/dev/null || true
  85. # reports copied into the release (zipped tree)
  86. if [ -d reports ] && [ -n "$(ls -A reports 2>/dev/null)" ]; then
  87. (cd reports && zip -r "../upload/mjdev-desktop-${VER}-reports.zip" .) || echo "::warning::reports zip failed"
  88. fi
  89. echo "=== produced for ${{ matrix.target }} ==="; ls -la upload/ || true
  90. - name: Upload build artifacts
  91. if: always()
  92. uses: actions/upload-artifact@v4
  93. with:
  94. name: dist-${{ matrix.target }}
  95. path: upload/
  96. if-no-files-found: warn
  97. release:
  98. name: Publish GitHub Release
  99. needs: package
  100. if: always()
  101. runs-on: ubuntu-latest
  102. steps:
  103. - uses: actions/checkout@v4
  104. - name: Read version
  105. id: ver
  106. shell: bash
  107. run: echo "version=$(grep -E '^app-pkg-version' gradle/libs.versions.toml | sed -E 's/.*"(.*)".*/\1/')" >> "$GITHUB_OUTPUT"
  108. - name: Download all artifacts
  109. uses: actions/download-artifact@v4
  110. with:
  111. path: dist
  112. merge-multiple: true
  113. - name: List collected
  114. shell: bash
  115. run: ls -la dist/ || echo "no artifacts produced"
  116. - name: Publish to GitHub Release
  117. uses: softprops/action-gh-release@v2
  118. with:
  119. tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('v{0}', steps.ver.outputs.version) }}
  120. name: mjdev-desktop v${{ steps.ver.outputs.version }}
  121. files: dist/**
  122. fail_on_unmatched_files: false
  123. env:
  124. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}