check-jdk-updates.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: Check JDK for non-major updates
  2. on:
  3. schedule:
  4. - cron: '0 0 1 * *' # run once a month at the first day of month
  5. workflow_dispatch:
  6. env:
  7. JDK_VERSION: '23.0.1+11'
  8. JDK_VENDOR: temurin
  9. RUNTIME_VERSION_HELPER: >
  10. public class Test {
  11. public static void main(String[] args) {
  12. System.out.println(Runtime.version());
  13. }
  14. }
  15. jobs:
  16. check-version:
  17. name: Checkout latest jdk version
  18. runs-on: ubuntu-latest
  19. env:
  20. JDK_MAJOR_VERSION: 'toBeFilled'
  21. steps:
  22. - name: Determine current major version
  23. run: echo 'JDK_MAJOR_VERSION=${{ env.JDK_VERSION }}'.substring(0,20) >> "$env:GITHUB_ENV"
  24. shell: pwsh
  25. - name: Checkout latest JDK ${{ env.JDK_MAJOR_VERSION }}
  26. uses: actions/setup-java@v4
  27. with:
  28. java-version: ${{ env.JDK_MAJOR_VERSION}}
  29. distribution: ${{ env.JDK_VENDOR }}
  30. check-latest: true
  31. - name: Determine if update is available
  32. id: determine
  33. shell: pwsh
  34. run: |
  35. $latestVersion = 0,0,0,0 #INTERIM, UPDATE, PATCH and BUILD
  36. $currentVersion = 0,0,0,0
  37. # Get the latest JDK runtime version
  38. "${env:RUNTIME_VERSION_HELPER}" | Set-Content -Path "GetRuntimeVersion.java"
  39. $latestVersionString = & java GetRuntimeVersion.java
  40. $runtimeVersionAndBuild = $latestVersionString.Split('+')
  41. if($runtimeVersionAndBuild.Length -eq 2) {
  42. $latestVersion[3]=$runtimeVersionAndBuild[1];
  43. }
  44. $tmp=$runtimeVersionAndBuild[0].Split('.')
  45. for($i=0;$i -lt $latestVersion.Length; $i++) {
  46. $latestVersion[$i]=$tmp[$i+1];
  47. }
  48. # Get the current JDK version
  49. $runtimeVersionAndBuild = '${{ env.JDK_VERSION}}'.Split('+')
  50. if($runtimeVersionAndBuild.Length -eq 2) {
  51. $currentVersion[3]=$runtimeVersionAndBuild[1];
  52. }
  53. $tmp=$runtimeVersionAndBuild[0].Split('.')
  54. for($i=0;$i -lt $currentVersion.Length; $i++) {
  55. $currentVersion[$i]=$tmp[$i+1];
  56. }
  57. # compare
  58. for($i=0; $i -lt $currentVersion.Length ; $i++) {
  59. if($latestVersion[$i] -gt $currentVersion[$i]){
  60. echo 'UPDATE_AVAILABLE=true' >> "$env:GITHUB_OUTPUT"
  61. echo "LATEST_JDK_VERSION='${latestVersionString}'" >> "$env:GITHUB_OUTPUT"
  62. return 0;
  63. }
  64. }
  65. - name: Notify
  66. if: steps.determine.outputs.UPDATE_AVAILABLE == 'true'
  67. uses: rtCamp/action-slack-notify@v2
  68. env:
  69. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  70. SLACK_USERNAME: 'Cryptobot'
  71. SLACK_ICON: false
  72. SLACK_ICON_EMOJI: ':bot:'
  73. SLACK_CHANNEL: 'cryptomator-desktop'
  74. SLACK_TITLE: "JDK update available"
  75. SLACK_MESSAGE: "Cryptomator-CI JDK can be upgraded to ${{ steps.determine.outputs.LATEST_JDK_VERSION }}. Check the Nextcloud collective for instructions."
  76. SLACK_FOOTER: false
  77. MSG_MINIMAL: true