zhichyu commited on
Commit
3bbcfdd
·
1 Parent(s): d512196

Fix release.yml

Browse files
Files changed (1) hide show
  1. .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
- - 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
 
30
- - name: Prepare release body
31
- run: |
32
- if [[ $GITHUB_EVENT_NAME == 'create' ]]; then
33
- RELEASE_TAG=${GITHUB_REF#refs/tags/}
34
- if [[ $RELEASE_TAG == 'nightly' ]]; then
35
- PRERELEASE=true
 
 
 
 
36
  else
37
- PRERELEASE=false
 
 
38
  fi
39
- echo "Workflow triggered by create tag: $RELEASE_TAG"
40
- else
41
- RELEASE_TAG=nightly
42
- PRERELEASE=true
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
- - name: Move the existing mutable tag
51
- # https://github.com/softprops/action-gh-release/issues/171
52
- run: |
53
- git fetch --tags
54
- if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
55
- # Determine if a given tag exists and matches a specific Git commit.
56
- # actions/checkout@v4 fetch-tags doesn't work when triggered by schedule
57
- if [ "$(git rev-parse -q --verify "refs/tags/$RELEASE_TAG")" = "$GITHUB_SHA" ]; then
58
- echo "mutable tag $RELEASE_TAG exists and matches $GITHUB_SHA"
59
- else
60
- git tag -f $RELEASE_TAG $GITHUB_SHA
61
- git push -f origin $RELEASE_TAG:refs/tags/$RELEASE_TAG
62
- echo "created/moved mutable tag $RELEASE_TAG to $GITHUB_SHA"
 
63
  fi
64
- fi
65
 
66
- - name: Create or overwrite a release
67
- # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release
68
- uses: softprops/action-gh-release@v2
69
- with:
70
- token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable
71
- prerelease: ${{ env.PRERELEASE }}
72
- tag_name: ${{ env.RELEASE_TAG }}
73
- # The body field does not support environment variable substitution directly.
74
- body_path: release_body.md
75
 
76
- - name: Set up QEMU
77
- uses: docker/setup-qemu-action@v3
78
 
79
- - name: Set up Docker Buildx
80
- uses: docker/setup-buildx-action@v3
81
 
82
- # https://github.com/marketplace/actions/docker-login
83
- - name: Login to Docker Hub
84
- uses: docker/login-action@v3
85
- with:
86
- username: infiniflow
87
- password: ${{ secrets.DOCKERHUB_TOKEN }}
88
 
89
- # https://github.com/marketplace/actions/build-and-push-docker-images
90
- - name: Build and push full image
91
- uses: docker/build-push-action@v6
92
- with:
93
- context: .
94
- push: true
95
- tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}
96
- file: Dockerfile
97
- platforms: linux/amd64
98
 
99
- # https://github.com/marketplace/actions/build-and-push-docker-images
100
- - name: Build and push slim image
101
- uses: docker/build-push-action@v6
102
- with:
103
- context: .
104
- push: true
105
- tags: infiniflow/ragflow:${{ env.RELEASE_TAG }}-slim
106
- file: Dockerfile
107
- build-args: LIGHTEN=1
108
- platforms: linux/amd64
109
 
110
- - name: Build ragflow-sdk
111
- if: startsWith(github.ref, 'refs/tags/v')
112
- run: |
113
- cd sdk/python && \
114
- poetry build
115
 
116
- - name: Publish package distributions to PyPI
117
- if: startsWith(github.ref, 'refs/tags/v')
118
- uses: pypa/gh-action-pypi-publish@release/v1
119
- with:
120
- packages-dir: dist/
121
- password: ${{ secrets.PYPI_API_TOKEN }}
122
- verbose: true
 
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