push.yaml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. name: Push to master
  2. run-name: ${{ github.ref_name }} push run 🚀
  3. on:
  4. push:
  5. branches:
  6. - master
  7. - main
  8. - 'release/**'
  9. tags:
  10. - '*'
  11. permissions:
  12. contents: write
  13. concurrency:
  14. group: '${{ github.workflow }} @ ${{ github.ref }}'
  15. cancel-in-progress: ${{ github.ref_type == 'tag' }}
  16. jobs:
  17. check-format:
  18. name: Check Formatting 🔍
  19. if: github.ref_name == 'master'
  20. uses: ./.github/workflows/check-format.yaml
  21. permissions:
  22. contents: read
  23. build-project:
  24. name: Build Project 🧱
  25. uses: ./.github/workflows/build-project.yaml
  26. secrets: inherit
  27. permissions:
  28. contents: read
  29. create-release:
  30. name: Create Release 🛫
  31. if: github.ref_type == 'tag'
  32. runs-on: ubuntu-22.04
  33. needs: build-project
  34. defaults:
  35. run:
  36. shell: bash
  37. steps:
  38. - name: Check Release Tag ☑️
  39. id: check
  40. run: |
  41. : Check Release Tag ☑️
  42. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  43. shopt -s extglob
  44. case "${GITHUB_REF_NAME}" in
  45. +([0-9]).+([0-9]).+([0-9]) )
  46. echo 'validTag=true' >> $GITHUB_OUTPUT
  47. echo 'prerelease=false' >> $GITHUB_OUTPUT
  48. echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
  49. ;;
  50. +([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) )
  51. echo 'validTag=true' >> $GITHUB_OUTPUT
  52. echo 'prerelease=true' >> $GITHUB_OUTPUT
  53. echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
  54. ;;
  55. *) echo 'validTag=false' >> $GITHUB_OUTPUT ;;
  56. esac
  57. - name: Download Build Artifacts 📥
  58. uses: actions/download-artifact@v4
  59. if: fromJSON(steps.check.outputs.validTag)
  60. id: download
  61. - name: Rename Files 🏷️
  62. if: fromJSON(steps.check.outputs.validTag)
  63. run: |
  64. : Rename Files 🏷️
  65. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  66. shopt -s extglob
  67. shopt -s nullglob
  68. root_dir="$(pwd)"
  69. commit_hash="${GITHUB_SHA:0:9}"
  70. variants=(
  71. 'windows-x64;zip|exe'
  72. 'macos-universal;tar.xz|pkg'
  73. 'ubuntu-22.04-x86_64;tar.xz|deb|ddeb'
  74. 'sources;tar.xz'
  75. )
  76. for variant_data in "${variants[@]}"; do
  77. IFS=';' read -r variant suffix <<< "${variant_data}"
  78. candidates=(*-${variant}-${commit_hash}/@(*|*-dbgsym).@(${suffix}))
  79. for candidate in "${candidates[@]}"; do
  80. mv "${candidate}" "${root_dir}"
  81. done
  82. done
  83. - name: Generate Checksums 🪪
  84. if: fromJSON(steps.check.outputs.validTag)
  85. run: |
  86. : Generate Checksums 🪪
  87. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  88. shopt -s extglob
  89. echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt
  90. for file in ${{ github.workspace }}/@(*.exe|*.deb|*.ddeb|*.pkg|*.tar.xz|*.zip); do
  91. echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt
  92. done
  93. - name: Create Release 🛫
  94. if: fromJSON(steps.check.outputs.validTag)
  95. id: create_release
  96. uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564
  97. with:
  98. draft: true
  99. prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }}
  100. tag_name: ${{ steps.check.outputs.version }}
  101. name: ${{ needs.build-project.outputs.pluginName }} ${{ steps.check.outputs.version }}
  102. body_path: ${{ github.workspace }}/CHECKSUMS.txt
  103. files: |
  104. ${{ github.workspace }}/*.exe
  105. ${{ github.workspace }}/*.zip
  106. ${{ github.workspace }}/*.pkg
  107. ${{ github.workspace }}/*.deb
  108. ${{ github.workspace }}/*.ddeb
  109. ${{ github.workspace }}/*.tar.xz