You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

release.yml 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. name: release
  2. on:
  3. schedule:
  4. - cron: '0 13 * * *' # This schedule runs every 13:00:00Z(21:00:00+08:00)
  5. # The "create tags" trigger is specifically focused on the creation of new tags, while the "push tags" trigger is activated when tags are pushed, including both new tag creations and updates to existing tags.
  6. create:
  7. tags:
  8. - "v*.*.*" # normal release
  9. - "nightly" # the only one mutable tag
  10. # https://docs.github.com/en/actions/using-jobs/using-concurrency
  11. concurrency:
  12. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  13. cancel-in-progress: true
  14. jobs:
  15. release:
  16. runs-on: [ "self-hosted", "overseas" ]
  17. steps:
  18. - name: Ensure workspace ownership
  19. run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE
  20. # https://github.com/actions/checkout/blob/v3/README.md
  21. - name: Check out code
  22. uses: actions/checkout@v4
  23. with:
  24. token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable
  25. fetch-depth: 0
  26. fetch-tags: true
  27. - name: Prepare release body
  28. run: |
  29. if [[ $GITHUB_EVENT_NAME == 'create' ]]; then
  30. RELEASE_TAG=${GITHUB_REF#refs/tags/}
  31. if [[ $RELEASE_TAG == 'nightly' ]]; then
  32. PRERELEASE=true
  33. else
  34. PRERELEASE=false
  35. fi
  36. echo "Workflow triggered by create tag: $RELEASE_TAG"
  37. else
  38. RELEASE_TAG=nightly
  39. PRERELEASE=true
  40. echo "Workflow triggered by schedule"
  41. fi
  42. echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
  43. echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
  44. RELEASE_DATETIME=$(date --rfc-3339=seconds)
  45. echo Release $RELEASE_TAG created from $GITHUB_SHA at $RELEASE_DATETIME > release_body.md
  46. - name: Move the existing mutable tag
  47. # https://github.com/softprops/action-gh-release/issues/171
  48. run: |
  49. git fetch --tags
  50. if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
  51. # Determine if a given tag exists and matches a specific Git commit.
  52. # actions/checkout@v4 fetch-tags doesn't work when triggered by schedule
  53. if [ "$(git rev-parse -q --verify "refs/tags/$RELEASE_TAG")" = "$GITHUB_SHA" ]; then
  54. echo "mutable tag $RELEASE_TAG exists and matches $GITHUB_SHA"
  55. else
  56. git tag -f $RELEASE_TAG $GITHUB_SHA
  57. git push -f origin $RELEASE_TAG:refs/tags/$RELEASE_TAG
  58. echo "created/moved mutable tag $RELEASE_TAG to $GITHUB_SHA"
  59. fi
  60. fi
  61. - name: Create or overwrite a release
  62. # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release
  63. uses: softprops/action-gh-release@v2
  64. with:
  65. token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable
  66. prerelease: ${{ env.PRERELEASE }}
  67. tag_name: ${{ env.RELEASE_TAG }}
  68. # The body field does not support environment variable substitution directly.
  69. body_path: release_body.md
  70. # https://github.com/marketplace/actions/docker-login
  71. - name: Login to Docker Hub
  72. uses: docker/login-action@v3
  73. with:
  74. username: infiniflow
  75. password: ${{ secrets.DOCKERHUB_TOKEN }}
  76. # https://github.com/marketplace/actions/build-and-push-docker-images
  77. - name: Build and push full image
  78. uses: docker/build-push-action@v6
  79. with:
  80. context: .
  81. push: true
  82. tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}
  83. file: Dockerfile
  84. platforms: linux/amd64
  85. # https://github.com/marketplace/actions/build-and-push-docker-images
  86. - name: Build and push slim image
  87. uses: docker/build-push-action@v6
  88. with:
  89. context: .
  90. push: true
  91. tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}-slim
  92. file: Dockerfile
  93. build-args: LIGHTEN=1
  94. platforms: linux/amd64
  95. - name: Build ragflow-sdk
  96. if: startsWith(github.ref, 'refs/tags/v')
  97. run: |
  98. cd sdk/python && \
  99. uv build
  100. - name: Publish package distributions to PyPI
  101. if: startsWith(github.ref, 'refs/tags/v')
  102. uses: pypa/gh-action-pypi-publish@release/v1
  103. with:
  104. packages-dir: sdk/python/dist/
  105. password: ${{ secrets.PYPI_API_TOKEN }}
  106. verbose: true