From e00bda534b8755e9933600bd190630061376fb15 Mon Sep 17 00:00:00 2001 From: 7iwind <7wind@7iwind.cn> Date: Sun, 26 Jul 2026 13:07:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3run=5Fon=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/release.yml | 53 +++++++++++++----------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index ff3a09b..25f8336 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,5 +1,4 @@ name: Release - on: push: branches: [main] @@ -53,13 +52,11 @@ jobs: run: | PKG="datarouter-${{ matrix.target.name }}" mkdir -p "dist/$PKG" - cp datarouter.h datarouter_config_template.h LICENSE README.md "dist/$PKG/" - cp build/libDataRouter.a "dist/$PKG/" 2>/dev/null || true - cp build/libDataRouter.so "dist/$PKG/" 2>/dev/null || true - cp build/libDataRouter.dll "dist/$PKG/" 2>/dev/null || true - cp build/libDataRouter.dll.a "dist/$PKG/" 2>/dev/null || true - cp build/example "dist/$PKG/" 2>/dev/null || true - cp build/example.exe "dist/$PKG/" 2>/dev/null || true + cp datarouter.h datarouter_config_template.h LICENSE "dist/$PKG/" + [ -f README.md ] && cp README.md "dist/$PKG/" + for f in libDataRouter.a libDataRouter.so libDataRouter.dll libDataRouter.dll.a example example.exe; do + [ -f "build/$f" ] && cp "build/$f" "dist/$PKG/" + done - uses: actions/upload-artifact@v4 with: @@ -68,9 +65,7 @@ jobs: release: needs: build - runs-on: ubuntu-latest - permissions: - contents: write + runs-on: ubuntu-builder steps: - uses: actions/checkout@v4 with: @@ -79,50 +74,40 @@ jobs: - name: Verify merge commit run: | PARENTS=$(git log --format="%P" -1 | wc -w) - if [ "$PARENTS" -lt 2 ]; then - echo "Not a merge commit. Skipping release." - exit 78 - fi + [ "$PARENTS" -ge 2 ] || exit 78 - name: Read tag from HEAD id: tag run: | TAG=$(git tag --points-at HEAD | grep '^v' | head -n1) - if [ -z "$TAG" ]; then - echo "No v* tag on HEAD. Create a tag manually, then merge." - exit 78 - fi + [ -n "$TAG" ] || exit 78 echo "tag=$TAG" >> "$GITHUB_OUTPUT" - uses: actions/download-artifact@v4 with: path: artifacts - - name: Create release & upload assets via Gitea API - env: - GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create release & upload assets run: | TAG="${{ steps.tag.outputs.tag }}" - SERVER="${GITHUB_SERVER_URL:-https://git.7iwind.cn}" - GITEA_API="${SERVER}/api/v1/repos/${GITHUB_REPOSITORY}/releases" + API="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" - echo "=== Create release for tag ${TAG} ===" + echo "=== Creating release $TAG ===" RESP=$(curl -s -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Authorization: token ${{ gitea.token }}" \ -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"${TAG}\",\"name\":\"DataRouter ${TAG}\",\"body\":\"## DataRouter ${TAG}\\n\\n合并 develop → main 后自动构建发布。\"}" \ - "${GITEA_API}") + -d "{\"tag_name\":\"${TAG}\",\"name\":\"DataRouter ${TAG}\"}" \ + "$API") ID=$(echo "$RESP" | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])") - echo "Release ID: ${ID}" for dir in artifacts/*/; do name="$(basename "$dir").tar.gz" - tar czf "/tmp/${name}" -C "$dir" . - echo "Uploading ${name} ..." + tar czf "/tmp/$name" -C "$dir" . + echo "Uploading $name" curl -s -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Authorization: token ${{ gitea.token }}" \ -H "Content-Type: application/octet-stream" \ - --data-binary @"/tmp/${name}" \ - "${GITEA_API}/${ID}/assets?name=${name}" + --data-binary @"/tmp/$name" \ + "${API}/${ID}/assets?name=${name}" done