bump-dashboard-version.yaml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  32. - name: Create PR to update dashboard version in Makefile
  33. run: |
  34. set -euxo pipefail
  35. git config --global user.name "${GITHUB_ACTOR}"
  36. git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  37. git fetch origin
  38. BASE_BRANCH="$(git branch --remotes --list 'origin/release-5?' | sort -r | head -n 1 | cut -d '/' -f 2)"
  39. NEW_BRANCH="bump-${EMQX_NAME}-dashboard-version-$(date +"%Y%m%d-%H%M%S")"
  40. git checkout -b ${NEW_BRANCH} --track origin/${BASE_BRANCH}
  41. case "${EMQX_NAME}" in
  42. emqx)
  43. sed -i "s|EMQX_DASHBOARD_VERSION=.*|EMQX_DASHBOARD_VERSION=${DASHBOARD_VERSION}|" Makefile
  44. ;;
  45. emqx-enterprise)
  46. sed -i "s|EMQX_EE_DASHBOARD_VERSION=.*|EMQX_EE_DASHBOARD_VERSION=${DASHBOARD_VERSION}|" Makefile
  47. ;;
  48. esac
  49. git add Makefile
  50. git commit -m "chore: bump dashboard version"
  51. git push origin ${NEW_BRANCH}:${NEW_BRANCH}
  52. 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
  53. gh pr close $pr --repo ${{ github.repository }} --delete-branch || true
  54. done
  55. gh pr create --title "bump ${EMQX_NAME} dashboard version" --body '' --base ${BASE_BRANCH} --head ${NEW_BRANCH} --label bump-dashboard-version --repo ${{ github.repository }}