From 35f07e96e19534f0ca643db2c43e4f60896b3bb5 Mon Sep 17 00:00:00 2001 From: gooker_young Date: Sat, 4 Jul 2026 10:45:35 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=9B=B4=E6=96=B0CI=E5=92=8Crelease?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 将CI容器镜像从固定版本改为latest 2. 简化PyPI发布步骤,改用uv publish命令 3. 重构Gitea发布脚本,优化release创建和资产上传流程 --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 44 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42ec0c9..1012f56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: name: Lint, Typecheck & Test runs-on: ubuntu-latest container: - image: pyflowx-ci:1.0.0 + image: pyflowx-ci:latest env: UV_LINK_MODE: copy # ---- 国内源 ---- diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2217f12..2e31c41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,24 +25,34 @@ jobs: - name: Build distributions run: uv build - - - name: Publish to PyPI - uses: http://gitea:3000/zhou/gh-action-pypi-publish.git@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} - - - name: Create Gitea Release + + - name: Publish to pypi + run: uv publish --token '${{ secrets.PYPI_API_TOKEN }}' + + - name: Create Gitea Release & Upload Assets + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ github.ref_name }} + REPO: ${{ github.repository }} + GITEA_URL: http://gitea:3000 run: | - VERSION=${GITHUB_REF#refs/tags/v} - REPO=${GITHUB_REPOSITORY} - UPLOAD_URL=$(curl -s -X POST "https://git.gookeryoung.cn/api/v1/repos/${REPO}/releases" \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + set -e + # 1. 创建 Release + RELEASE_ID=$(curl -sS -X POST "$GITEA_URL/api/v1/repos/$REPO/releases" \ + -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ - -d "{\"tag_name\": \"v${VERSION}\", \"name\": \"v${VERSION}\", \"draft\": false, \"prerelease\": false}" \ - | jq -r '.upload_url') - for file in dist/*; do - curl -s -X POST "${UPLOAD_URL}?name=$(basename $file)" \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -d "{\"tag_name\":\"$TAG_NAME\",\"name\":\"Release $TAG_NAME\",\"body\":\"Automated release from CI\",\"draft\":false,\"prerelease\":false}" \ + | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])") + + echo "Created release id=$RELEASE_ID" + + # 2. 上传 dist/ 下所有文件作为附件 + for f in dist/*; do + echo "Uploading $f ..." + curl -sS -X POST "$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$(basename $f)" \ + -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/octet-stream" \ - --data-binary @"$file" + --data-binary "@$f" done + +