Merge pull request 'fix: 修正run_on标签名' (#6) from feature/route into develop
Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user