release.yaml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. name: Upload release assets
  2. on:
  3. release:
  4. types:
  5. - published
  6. workflow_dispatch:
  7. inputs:
  8. tag:
  9. type: string
  10. required: true
  11. publish_release_artefacts:
  12. type: boolean
  13. required: true
  14. default: false
  15. jobs:
  16. upload:
  17. runs-on: ubuntu-20.04
  18. strategy:
  19. fail-fast: false
  20. steps:
  21. - uses: aws-actions/configure-aws-credentials@v1-node16
  22. with:
  23. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  24. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  25. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  26. - uses: actions/checkout@v3
  27. with:
  28. ref: ${{ github.event.inputs.tag }}
  29. - name: Detect profile
  30. id: profile
  31. run: |
  32. if git describe --tags --match '[v|e]*' --exact; then
  33. REF=$(git describe --tags --match '[v|e]*' --exact)
  34. else
  35. echo "Only release tags matching '[v|e]*' are supported"
  36. exit 1
  37. fi
  38. case "$REF" in
  39. v*)
  40. echo "profile=emqx" >> $GITHUB_OUTPUT
  41. echo "version=$(./pkg-vsn.sh emqx)" >> $GITHUB_OUTPUT
  42. echo "s3dir=emqx-ce" >> $GITHUB_OUTPUT
  43. ;;
  44. e*)
  45. echo "profile=emqx-enterprise" >> $GITHUB_OUTPUT
  46. echo "version=$(./pkg-vsn.sh emqx-enterprise)" >> $GITHUB_OUTPUT
  47. echo "s3dir=emqx-ee" >> $GITHUB_OUTPUT
  48. ;;
  49. esac
  50. - name: Get packages
  51. run: |
  52. BUCKET=${{ secrets.AWS_S3_BUCKET }}
  53. OUTPUT_DIR=${{ steps.profile.outputs.s3dir }}
  54. aws s3 cp --recursive s3://$BUCKET/$OUTPUT_DIR/${{ github.ref_name }} packages
  55. cd packages
  56. DEFAULT_BEAM_PLATFORM='otp24.3.4.2-1'
  57. # all packages including full-name and default-name are uploaded to s3
  58. # but we only upload default-name packages (and elixir) as github artifacts
  59. # so we rename (overwrite) non-default packages before uploading
  60. while read -r fname; do
  61. default_fname=$(echo "$fname" | sed "s/-${DEFAULT_BEAM_PLATFORM}//g")
  62. echo "$fname -> $default_fname"
  63. mv -f "$fname" "$default_fname"
  64. done < <(find . -maxdepth 1 -type f | grep -E "emqx(-enterprise)?-5\.[0-9]+\.[0-9]+.*-${DEFAULT_BEAM_PLATFORM}" | grep -v elixir)
  65. - uses: alexellis/upload-assets@0.4.0
  66. env:
  67. GITHUB_TOKEN: ${{ github.token }}
  68. with:
  69. asset_paths: '["packages/*"]'
  70. - name: update to emqx.io
  71. if: github.event_name == 'release' || inputs.publish_release_artefacts
  72. run: |
  73. set -e -x -u
  74. curl -w %{http_code} \
  75. --insecure \
  76. -H "Content-Type: application/json" \
  77. -H "token: ${{ secrets.EMQX_IO_TOKEN }}" \
  78. -X POST \
  79. -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ github.ref_name }}\" }" \
  80. ${{ secrets.EMQX_IO_RELEASE_API }}
  81. - name: update homebrew packages
  82. if: steps.profile.outputs.profile == 'emqx' && (github.event_name == 'release' || inputs.publish_release_artefacts)
  83. run: |
  84. if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then
  85. curl --silent --show-error \
  86. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  87. -H "Accept: application/vnd.github.v3+json" \
  88. -X POST \
  89. -d "{\"ref\":\"v1.0.4\",\"inputs\":{\"version\": \"${{ github.ref_name }}\"}}" \
  90. "https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches"
  91. fi