mirror of
https://github.com/dataelement/bisheng.git
synced 2026-10-29 18:14:15 +08:00
Update ci.yml
This commit is contained in:
+45
-88
@@ -1,4 +1,4 @@
|
||||
name: CI
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -7,101 +7,76 @@ on:
|
||||
- "v*"
|
||||
|
||||
env:
|
||||
DOCKERHUB_REPO: dataelement/
|
||||
|
||||
DOCKERHUB_REPO: project/
|
||||
PY_NEXUS: 110.16.193.170:50083
|
||||
DOCKER_NEXUS: 110.16.193.170:50080
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_bisheng_langchain:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
#if: startsWith(github.event.ref, 'refs/tags')
|
||||
steps:
|
||||
# deploy
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: git message
|
||||
id: git_message
|
||||
run: |
|
||||
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
|
||||
- name: Set Environment Variable
|
||||
run: echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
|
||||
|
||||
# 构建 bisheng_langchain
|
||||
- name: Set python version 3.8
|
||||
# 构建 bisheng-langchain
|
||||
- name: Set python version 3.10
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Build PyPi bisheng-langchain and push
|
||||
id: pypi_build_bisheng_langchain
|
||||
#- name: Build PyPi bisheng-langchain and push
|
||||
# id: pypi_build_bisheng_langchain
|
||||
# run: |
|
||||
# pip install Cython
|
||||
# pip install wheel
|
||||
# pip install twine
|
||||
# cd ./src/bisheng-langchain
|
||||
# python setup.py bdist_wheel
|
||||
# repo="http://${{ env.PY_NEXUS }}/repository/pypi-hosted/"
|
||||
# twine upload --verbose -u ${{ secrets.NEXUS_USER }} -p ${{ secrets.NEXUS_PASSWORD }} --repository-url $repo dist/*.whl
|
||||
# cd ../../
|
||||
|
||||
# 发布到 私有仓库
|
||||
- name: set insecure registry
|
||||
run: |
|
||||
pip install Cython
|
||||
pip install wheel
|
||||
pip install twine
|
||||
cd ./src/bisheng-langchain
|
||||
python setup.py bdist_wheel
|
||||
set +e
|
||||
twine upload dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }} --repository pypi
|
||||
set -e
|
||||
|
||||
build_bisheng:
|
||||
needs: build_bisheng_langchain
|
||||
runs-on: ubuntu-latest
|
||||
# if: startsWith(github.event.ref, 'refs/tags')
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
echo "{ \"insecure-registries\": [\"http://${{ env.DOCKER_NEXUS }}\"] }" | sudo tee /etc/docker/daemon.json
|
||||
sudo service docker restart
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
|
||||
- name: Set Environment Variable
|
||||
run: echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
|
||||
# - name: Set up QEMU
|
||||
# uses: docker/setup-qemu-action@v1
|
||||
|
||||
# 登录 docker hub
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
- name: Login Nexus Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
|
||||
# DOCKERHUB_USERNAME 是 docker hub 账号名.
|
||||
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
registry: http://${{ env.DOCKER_NEXUS }}/
|
||||
username: ${{ secrets.NEXUS_USER }}
|
||||
password: ${{ secrets.NEXUS_PASSWORD }}
|
||||
|
||||
# - name: Login to DockerHub
|
||||
# uses: docker/login-action@v1
|
||||
# with:
|
||||
# registry: https://cr.dataelem.com/
|
||||
# username: ${{ secrets.CR_DOCKERHUB_USERNAME }}
|
||||
# password: ${{ secrets.CR_DOCKERHUB_TOKEN }}
|
||||
|
||||
# 构建 backend 并推送到 Docker hub
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: install poetry
|
||||
# 替换poetry编译为私有服务
|
||||
- name: replace self-host repo
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
installer-parallel: true
|
||||
|
||||
- name: build lock
|
||||
run: |
|
||||
run: |
|
||||
cd ./src/backend
|
||||
pip install bisheng_langchain==$RELEASE_VERSION
|
||||
poetry source add --priority=supplemental foo http://${{ secrets.NEXUS_PUBLIC }}:${{ secrets.NEXUS_PUBLIC_PASSWORD }}@${{ env.PY_NEXUS }}/repository/pypi-group/simple
|
||||
poetry lock
|
||||
# 安装 nltk
|
||||
pip install nltk
|
||||
python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
|
||||
mv /home/runner/nltk_data/taggers ./
|
||||
cd ../../
|
||||
|
||||
# 构建 backend 并推送到 Docker hub
|
||||
- name: Build backend and push
|
||||
id: docker_build_backend
|
||||
uses: docker/build-push-action@v2
|
||||
@@ -111,14 +86,12 @@ jobs:
|
||||
# 是否 docker push
|
||||
push: true
|
||||
# docker build arg, 注入 APP_NAME/APP_VERSION
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
APP_NAME="bisheng-backend"
|
||||
APP_VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
# 生成两个 docker tag: ${APP_VERSION} 和 latest
|
||||
tags: |
|
||||
${{ env.DOCKERHUB_REPO }}bisheng-backend:latest
|
||||
${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
|
||||
${{ env.DOCKER_NEXUS }}/${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
|
||||
# 构建 Docker frontend 并推送到 Docker hub
|
||||
- name: Build frontend and push
|
||||
id: docker_build_frontend
|
||||
@@ -129,26 +102,10 @@ jobs:
|
||||
# 是否 docker push
|
||||
push: true
|
||||
# docker build arg, 注入 APP_NAME/APP_VERSION
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
APP_NAME="bisheng-frontend"
|
||||
APP_VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
# 生成两个 docker tag: ${APP_VERSION} 和 latest
|
||||
tags: |
|
||||
${{ env.DOCKERHUB_REPO }}bisheng-frontend:latest
|
||||
${{ env.DOCKERHUB_REPO }}bisheng-frontend:${{ steps.get_version.outputs.VERSION }}
|
||||
${{ env.DOCKER_NEXUS }}/${{ env.DOCKERHUB_REPO }}bisheng-frontend:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- name: Process git message
|
||||
id: process_message
|
||||
run: |
|
||||
value=$(echo "${{ github.event.head_commit.message }}" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/%0A/g')
|
||||
value=$(echo "${value}" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\r/%0A/g')
|
||||
echo "message=${value}" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: notify feishu
|
||||
uses: fjogeleit/http-request-action@v1
|
||||
with:
|
||||
url: ${{ secrets.FEISHU_WEBHOOK }}
|
||||
method: 'POST'
|
||||
data: '{"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ steps.get_version.outputs.VERSION }}发布成功", "content": [[{"tag":"text","text":"发布功能:"},{"tag":"text","text":"${{ env.message }}"}]]}}}}'
|
||||
|
||||
Reference in New Issue
Block a user