bump-dashboard-version.yaml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: Bump Dashboard Version
  2. concurrency:
  3. group: bump-dashboard-version-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_dispatch:
  7. inputs:
  8. emqx-name:
  9. required: true
  10. type: choice
  11. default: emqx
  12. options:
  13. - emqx
  14. - emqx-enterprise
  15. version:
  16. description: 'Dashboard version'
  17. type: string
  18. required: true
  19. permissions:
  20. contents: read
  21. jobs:
  22. bump-dashboard-version:
  23. runs-on: ubuntu-latest
  24. env:
  25. EMQX_NAME: ${{ github.event.inputs.emqx-name }}
  26. DASHBOARD_VERSION: ${{ github.event.inputs.version }}
  27. permissions:
  28. contents: write
  29. pull-requests: write
  30. steps:
  31. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  32. - name: Create PR to update dashboard version in Makefile
  33. env:
  34. GH_TOKEN: ${{ github.token }}
  35. run: |
  36. set -euxo pipefail
  37. git config --global user.name "${GITHUB_ACTOR}"
  38. git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  39. git fetch origin
  40. BASE_BRANCH="$(git branch --remotes --list 'origin/release-5?' | sort -r | head -n 1 | cut -d '/' -f 2)"
  41. NEW_BRANCH="bump-${EMQX_NAME}-dashboard-version-$(date +"%Y%m%d-%H%M%S")"
  42. git checkout -b ${NEW_BRANCH} --track origin/${BASE_BRANCH}
  43. case "${EMQX_NAME}" in
  44. emqx)
  45. sed -i "s|EMQX_DASHBOARD_VERSION ?= .*|EMQX_DASHBOARD_VERSION ?= ${DASHBOARD_VERSION}|" Makefile
  46. ;;
  47. emqx-enterprise)
  48. sed -i "s|EMQX_EE_DASHBOARD_VERSION ?= .*|EMQX_EE_DASHBOARD_VERSION ?= ${DASHBOARD_VERSION}|" Makefile
  49. ;;
  50. esac
  51. git add Makefile
  52. git commit -m "chore: bump dashboard version"
  53. git push origin ${NEW_BRANCH}:${NEW_BRANCH}
  54. for pr in $(gh pr list --state open --base ${BASE_BRANCH} --label bump-dashboard-version --search "bump ${EMQX_NAME} dashboard version in:title" --repo ${{ github.repository }} --json number --jq '.[] | .number'); do
  55. gh pr close $pr --repo ${{ github.repository }} --delete-branch || true
  56. done
  57. gh pr create --title "bump ${EMQX_NAME} dashboard version" --body '' --base ${BASE_BRANCH} --head ${NEW_BRANCH} --label bump-dashboard-version --repo ${{ github.repository }}