This commit is contained in:
+36
-23
@@ -34,12 +34,12 @@ jobs:
|
|||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://verdaccio:4873/windychen-utils/$VERSION)
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://verdaccio:4873/windychen-utils/$VERSION)
|
||||||
if [ "$HTTP_CODE" = "200" ]; then
|
if [ "$HTTP_CODE" = "200" ]; then
|
||||||
echo "Verdaccio: version $VERSION already exists, skipping."
|
echo "Verdaccio: version $VERSION already exists, skipping."
|
||||||
echo "Verdaccio|skipped|版本 ${VERSION} 已存在" > /tmp/publish_result.txt
|
echo "verdaccio_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
if npm publish 2>&1; then
|
if npm publish 2>&1; then
|
||||||
echo "Verdaccio|published|已发布 v${VERSION}" > /tmp/publish_result.txt
|
echo "verdaccio_result=published|已发布 v${VERSION}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "Verdaccio|failed|发布失败" > /tmp/publish_result.txt
|
echo "verdaccio_result=failed|发布失败" >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -52,12 +52,12 @@ jobs:
|
|||||||
EXISTS=$(curl -s "http://gitea:3000/api/v1/packages/windychen?q=windychen-utils" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"version\":\"$VERSION\"" || true)
|
EXISTS=$(curl -s "http://gitea:3000/api/v1/packages/windychen?q=windychen-utils" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"version\":\"$VERSION\"" || true)
|
||||||
if [ "$EXISTS" -gt 0 ]; then
|
if [ "$EXISTS" -gt 0 ]; then
|
||||||
echo "Gitea: version $VERSION already exists, skipping."
|
echo "Gitea: version $VERSION already exists, skipping."
|
||||||
echo "Gitea|skipped|版本 ${VERSION} 已存在" >> /tmp/publish_result.txt
|
echo "gitea_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
if npm publish --registry http://gitea:3000/api/packages/windychen/npm/ 2>&1; then
|
if npm publish --registry http://gitea:3000/api/packages/windychen/npm/ 2>&1; then
|
||||||
echo "Gitea|published|已发布 v${VERSION}" >> /tmp/publish_result.txt
|
echo "gitea_result=published|已发布 v${VERSION}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "Gitea|failed|发布失败" >> /tmp/publish_result.txt
|
echo "gitea_result=failed|发布失败" >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
if: always() && steps.publish-gitea.outcome == 'success'
|
if: always() && steps.publish-gitea.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
EXISTS=$(curl -s "http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases/tags/v${VERSION}" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"tag_name\"")
|
EXISTS=$(curl -s "http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases/tags/v${VERSION}" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"tag_name\"" || true)
|
||||||
if [ "$EXISTS" = "0" ]; then
|
if [ "$EXISTS" = "0" ]; then
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
"http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases" \
|
"http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases" \
|
||||||
@@ -82,28 +82,41 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
STATUS="${{ job.status }}"
|
STATUS="${{ job.status }}"
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
VERD_LINE="⚠️ Verdaccio: 未执行"
|
|
||||||
GITEA_LINE="⚠️ Gitea: 未执行"
|
parse_result() {
|
||||||
if [ -f /tmp/publish_result.txt ]; then
|
local raw="$1"
|
||||||
while IFS='|' read -r TARGET ICON DETAIL; do
|
local target="$2"
|
||||||
case "$ICON" in
|
local icon="${raw%%|*}"
|
||||||
published) EMOJI="📦" ;;
|
local detail="${raw#*|}"
|
||||||
skipped) EMOJI="⏭️" ;;
|
case "$icon" in
|
||||||
failed) EMOJI="❌" ;;
|
published) echo "📦 ${target}: ${detail}" ;;
|
||||||
*) EMOJI="⚠️" ;;
|
skipped) echo "⏭️ ${target}: ${detail}" ;;
|
||||||
esac
|
failed) echo "❌ ${target}: ${detail}" ;;
|
||||||
LINE="${EMOJI} ${TARGET}: ${DETAIL}"
|
*) echo "⚠️ ${target}: ${detail}" ;;
|
||||||
case "$TARGET" in
|
esac
|
||||||
Verdaccio) VERD_LINE="$LINE" ;;
|
}
|
||||||
Gitea) GITEA_LINE="$LINE" ;;
|
|
||||||
esac
|
VERD_RESULT="${{ steps.publish-verdaccio.outputs.verdaccio_result }}"
|
||||||
done < /tmp/publish_result.txt
|
GITEA_RESULT="${{ steps.publish-gitea.outputs.gitea_result }}"
|
||||||
|
|
||||||
|
if [ -n "$VERD_RESULT" ]; then
|
||||||
|
VERD_LINE=$(parse_result "$VERD_RESULT" "Verdaccio")
|
||||||
|
else
|
||||||
|
VERD_LINE="⚠️ Verdaccio: 未执行"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$GITEA_RESULT" ]; then
|
||||||
|
GITEA_LINE=$(parse_result "$GITEA_RESULT" "Gitea")
|
||||||
|
else
|
||||||
|
GITEA_LINE="⚠️ Gitea: 未执行"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$STATUS" = "success" ]; then
|
if [ "$STATUS" = "success" ]; then
|
||||||
TITLE="✅ windychen-utils v${VERSION} 构建完成 chen-fnos"
|
TITLE="✅ windychen-utils v${VERSION} 构建完成 chen-fnos"
|
||||||
else
|
else
|
||||||
TITLE="❌ windychen-utils v${VERSION} 构建失败 chen-fnos"
|
TITLE="❌ windychen-utils v${VERSION} 构建失败 chen-fnos"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \
|
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"${TITLE}\",\"text\":\"## ${TITLE}\n\n${VERD_LINE}\n${GITEA_LINE}\n\n- 仓库: windychen/windyChenUtils\n- 分支: ${{ github.ref_name }}\n- 提交: ${{ github.sha }}\"}}"
|
-d "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"${TITLE}\",\"text\":\"## ${TITLE}\n\n${VERD_LINE}\n${GITEA_LINE}\n\n- 仓库: windychen/windyChenUtils\n- 分支: ${{ github.ref_name }}\n- 提交: ${{ github.sha }}\"}}"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "windychen-utils",
|
"name": "windychen-utils",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"main": "dist/windychen-utils.cjs.js",
|
"main": "dist/windychen-utils.cjs.js",
|
||||||
"module": "dist/windychen-utils.esm.js",
|
"module": "dist/windychen-utils.esm.js",
|
||||||
"browser": "dist/windychen-utils.js",
|
"browser": "dist/windychen-utils.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user