Fix release.yml
Browse files- .github/workflows/release.yml +90 -88
.github/workflows/release.yml
CHANGED
|
@@ -18,105 +18,107 @@ jobs:
|
|
| 18 |
release:
|
| 19 |
runs-on: [ "self-hosted", "overseas" ]
|
| 20 |
steps:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
else
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
fi
|
| 39 |
-
echo "
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
echo "Workflow triggered by schedule"
|
| 44 |
-
fi
|
| 45 |
-
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
|
| 46 |
-
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
|
| 47 |
-
RELEASE_DATETIME=$(date --rfc-3339=seconds)
|
| 48 |
-
echo Release $RELEASE_TAG created from $GITHUB_SHA at $RELEASE_DATETIME > release_body.md
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
fi
|
| 64 |
-
fi
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 18 |
release:
|
| 19 |
runs-on: [ "self-hosted", "overseas" ]
|
| 20 |
steps:
|
| 21 |
+
- name: Ensure workspace ownership
|
| 22 |
+
run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE
|
| 23 |
|
| 24 |
+
# https://github.com/actions/checkout/blob/v3/README.md
|
| 25 |
+
- name: Check out code
|
| 26 |
+
uses: actions/checkout@v4
|
| 27 |
+
with:
|
| 28 |
+
token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable
|
| 29 |
+
fetch-depth: 0
|
| 30 |
+
fetch-tags: true
|
| 31 |
|
| 32 |
+
- name: Prepare release body
|
| 33 |
+
run: |
|
| 34 |
+
if [[ $GITHUB_EVENT_NAME == 'create' ]]; then
|
| 35 |
+
RELEASE_TAG=${GITHUB_REF#refs/tags/}
|
| 36 |
+
if [[ $RELEASE_TAG == 'nightly' ]]; then
|
| 37 |
+
PRERELEASE=true
|
| 38 |
+
else
|
| 39 |
+
PRERELEASE=false
|
| 40 |
+
fi
|
| 41 |
+
echo "Workflow triggered by create tag: $RELEASE_TAG"
|
| 42 |
else
|
| 43 |
+
RELEASE_TAG=nightly
|
| 44 |
+
PRERELEASE=true
|
| 45 |
+
echo "Workflow triggered by schedule"
|
| 46 |
fi
|
| 47 |
+
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
|
| 48 |
+
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
|
| 49 |
+
RELEASE_DATETIME=$(date --rfc-3339=seconds)
|
| 50 |
+
echo Release $RELEASE_TAG created from $GITHUB_SHA at $RELEASE_DATETIME > release_body.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
- name: Move the existing mutable tag
|
| 53 |
+
# https://github.com/softprops/action-gh-release/issues/171
|
| 54 |
+
run: |
|
| 55 |
+
git fetch --tags
|
| 56 |
+
if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
|
| 57 |
+
# Determine if a given tag exists and matches a specific Git commit.
|
| 58 |
+
# actions/checkout@v4 fetch-tags doesn't work when triggered by schedule
|
| 59 |
+
if [ "$(git rev-parse -q --verify "refs/tags/$RELEASE_TAG")" = "$GITHUB_SHA" ]; then
|
| 60 |
+
echo "mutable tag $RELEASE_TAG exists and matches $GITHUB_SHA"
|
| 61 |
+
else
|
| 62 |
+
git tag -f $RELEASE_TAG $GITHUB_SHA
|
| 63 |
+
git push -f origin $RELEASE_TAG:refs/tags/$RELEASE_TAG
|
| 64 |
+
echo "created/moved mutable tag $RELEASE_TAG to $GITHUB_SHA"
|
| 65 |
+
fi
|
| 66 |
fi
|
|
|
|
| 67 |
|
| 68 |
+
- name: Create or overwrite a release
|
| 69 |
+
# https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release
|
| 70 |
+
uses: softprops/action-gh-release@v2
|
| 71 |
+
with:
|
| 72 |
+
token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable
|
| 73 |
+
prerelease: ${{ env.PRERELEASE }}
|
| 74 |
+
tag_name: ${{ env.RELEASE_TAG }}
|
| 75 |
+
# The body field does not support environment variable substitution directly.
|
| 76 |
+
body_path: release_body.md
|
| 77 |
|
| 78 |
+
- name: Set up QEMU
|
| 79 |
+
uses: docker/setup-qemu-action@v3
|
| 80 |
|
| 81 |
+
- name: Set up Docker Buildx
|
| 82 |
+
uses: docker/setup-buildx-action@v3
|
| 83 |
|
| 84 |
+
# https://github.com/marketplace/actions/docker-login
|
| 85 |
+
- name: Login to Docker Hub
|
| 86 |
+
uses: docker/login-action@v3
|
| 87 |
+
with:
|
| 88 |
+
username: infiniflow
|
| 89 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 90 |
|
| 91 |
+
# https://github.com/marketplace/actions/build-and-push-docker-images
|
| 92 |
+
- name: Build and push full image
|
| 93 |
+
uses: docker/build-push-action@v6
|
| 94 |
+
with:
|
| 95 |
+
context: .
|
| 96 |
+
push: true
|
| 97 |
+
tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}
|
| 98 |
+
file: Dockerfile
|
| 99 |
+
platforms: linux/amd64
|
| 100 |
|
| 101 |
+
# https://github.com/marketplace/actions/build-and-push-docker-images
|
| 102 |
+
- name: Build and push slim image
|
| 103 |
+
uses: docker/build-push-action@v6
|
| 104 |
+
with:
|
| 105 |
+
context: .
|
| 106 |
+
push: true
|
| 107 |
+
tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}-slim
|
| 108 |
+
file: Dockerfile
|
| 109 |
+
build-args: LIGHTEN=1
|
| 110 |
+
platforms: linux/amd64
|
| 111 |
|
| 112 |
+
- name: Build ragflow-sdk
|
| 113 |
+
if: startsWith(github.ref, 'refs/tags/v')
|
| 114 |
+
run: |
|
| 115 |
+
cd sdk/python && \
|
| 116 |
+
poetry build
|
| 117 |
|
| 118 |
+
- name: Publish package distributions to PyPI
|
| 119 |
+
if: startsWith(github.ref, 'refs/tags/v')
|
| 120 |
+
uses: pypa/gh-action-pypi-publish@release/v1
|
| 121 |
+
with:
|
| 122 |
+
packages-dir: dist/
|
| 123 |
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
| 124 |
+
verbose: true
|