publish-release-artifact.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. name: Publish artifact
  2. on:
  3. release:
  4. types: [published]
  5. permissions:
  6. contents: read # to fetch code (actions/checkout)
  7. jobs:
  8. determine-version:
  9. if: ${{ github.repository_owner == 'jenkinsci' }}
  10. runs-on: ubuntu-latest
  11. outputs:
  12. project-version: ${{ steps.set-version.outputs.project-version }}
  13. is-lts: ${{ steps.set-version.outputs.is-lts }}
  14. is-rc: ${{ steps.set-version.outputs.is-rc }}
  15. steps:
  16. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  17. - name: Set up JDK 21
  18. uses: actions/setup-java@1d018f9b8b9b505bb578a83b230fabcce01af93b #v 5.0.0
  19. with:
  20. distribution: "temurin"
  21. java-version: 25
  22. cache: "maven"
  23. - name: Set version
  24. id: set-version
  25. run: |
  26. version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
  27. dot_count=$(echo $version | sed 's/[^.]//g' | awk '{ print length }')
  28. if [ "${dot_count}" = '2' ]
  29. then
  30. is_lts=true
  31. else
  32. is_lts=false
  33. fi
  34. is_rc=false
  35. if [[ ${version} == *"-SNAPSHOT" ]]; then
  36. is_rc=true
  37. fi
  38. echo "Version is $version, is_lts: $is_lts, is_rc: $is_rc"
  39. echo "is-lts=${is_lts}" >> $GITHUB_OUTPUT
  40. echo "project-version=$version" >> $GITHUB_OUTPUT
  41. echo "is-rc=${is_rc}" >> $GITHUB_OUTPUT
  42. war:
  43. permissions:
  44. contents: write # to upload release asset (softprops/action-gh-release)
  45. runs-on: ubuntu-latest
  46. needs: determine-version
  47. if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
  48. steps:
  49. - name: Fetch war
  50. id: fetch-war
  51. run: |
  52. FILE_NAME=jenkins.war
  53. PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
  54. IS_LTS=${{ needs.determine-version.outputs.is-lts }}
  55. echo $PROJECT_VERSION
  56. echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
  57. echo "signature-file-name=${FILE_NAME}.asc" >> $GITHUB_OUTPUT
  58. REPO=war
  59. if [ ${IS_LTS} = 'true' ]
  60. then
  61. REPO=war-stable
  62. fi
  63. echo $REPO
  64. wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}
  65. wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}.asc
  66. - name: Upload Release Asset
  67. id: upload-war
  68. uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
  69. env:
  70. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  71. with:
  72. files: |
  73. ${{ steps.fetch-war.outputs.file-name }}
  74. ${{ steps.fetch-war.outputs.signature-file-name }}
  75. debian:
  76. permissions:
  77. contents: write # to upload release asset (softprops/action-gh-release)
  78. runs-on: ubuntu-latest
  79. needs: determine-version
  80. if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
  81. steps:
  82. - name: Fetch Deb
  83. id: fetch-deb
  84. if: always()
  85. run: |
  86. PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
  87. echo $PROJECT_VERSION
  88. FILE_NAME=jenkins_${PROJECT_VERSION}_all.deb
  89. IS_LTS=${{ needs.determine-version.outputs.is-lts }}
  90. echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
  91. REPO=debian
  92. if [ ${IS_LTS} = 'true' ]
  93. then
  94. REPO=debian-stable
  95. fi
  96. echo $REPO
  97. wget -q https://get.jenkins.io/${REPO}/${FILE_NAME}
  98. - name: Upload Release Asset
  99. id: upload-deb
  100. if: always()
  101. uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
  102. env:
  103. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  104. with:
  105. files: ${{ steps.fetch-deb.outputs.file-name }}
  106. rpm:
  107. permissions:
  108. contents: write # to upload release asset (softprops/action-gh-release)
  109. runs-on: ubuntu-latest
  110. needs: determine-version
  111. if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
  112. steps:
  113. - name: Fetch RPM
  114. id: fetch-rpm
  115. if: always()
  116. run: |
  117. PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
  118. echo $PROJECT_VERSION
  119. FILE_NAME=jenkins-${PROJECT_VERSION}-1.noarch.rpm
  120. IS_LTS=${{ needs.determine-version.outputs.is-lts }}
  121. echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
  122. REPO=rpm
  123. if [ ${IS_LTS} = 'true' ]
  124. then
  125. REPO=rpm-stable
  126. fi
  127. echo $REPO
  128. wget -q https://get.jenkins.io/${REPO}/${FILE_NAME}
  129. - name: Upload Release Asset
  130. id: upload-rpm
  131. if: always()
  132. uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
  133. env:
  134. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  135. with:
  136. files: ${{ steps.fetch-rpm.outputs.file-name }}
  137. windows:
  138. permissions:
  139. contents: write # to upload release asset (softprops/action-gh-release)
  140. runs-on: ubuntu-latest
  141. needs: determine-version
  142. if: ${{ needs.determine-version.outputs.is-rc == 'false' }}
  143. steps:
  144. - name: Fetch MSI
  145. id: fetch-msi
  146. if: always()
  147. run: |
  148. PROJECT_VERSION=${{ needs.determine-version.outputs.project-version }}
  149. echo $PROJECT_VERSION
  150. FILE_NAME=jenkins.msi
  151. IS_LTS=${{ needs.determine-version.outputs.is-lts }}
  152. echo "file-name=$FILE_NAME" >> $GITHUB_OUTPUT
  153. REPO=windows
  154. if [ ${IS_LTS} = 'true' ]
  155. then
  156. REPO=windows-stable
  157. fi
  158. echo $REPO
  159. wget -q https://get.jenkins.io/${REPO}/${PROJECT_VERSION}/${FILE_NAME}
  160. - name: Upload Release Asset
  161. id: upload-msi
  162. if: always()
  163. uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
  164. env:
  165. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  166. with:
  167. files: ${{ steps.fetch-msi.outputs.file-name }}