Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3d2b3ff7e | |||
| 9b4a9ea97d | |||
| 9223f3c5ff | |||
| 3be193f8c4 | |||
| d6d06e90a6 | |||
| ed4f144e26 |
+51
-23
@@ -34,12 +34,12 @@ jobs:
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://verdaccio:4873/windychen-utils/$VERSION)
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo "Verdaccio: version $VERSION already exists, skipping."
|
||||
echo "Verdaccio|skipped|版本 ${VERSION} 已存在" > /tmp/publish_result.txt
|
||||
echo "verdaccio_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
||||
else
|
||||
if npm publish 2>&1; then
|
||||
echo "Verdaccio|published|已发布 v${VERSION}" > /tmp/publish_result.txt
|
||||
echo "verdaccio_result=published|已发布 v${VERSION}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Verdaccio|failed|发布失败" > /tmp/publish_result.txt
|
||||
echo "verdaccio_result=failed|发布失败" >> $GITHUB_OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -49,46 +49,74 @@ jobs:
|
||||
run: |
|
||||
npm config set //gitea:3000/api/packages/windychen/npm/:_authToken ${{ secrets.NPM_GITEA_TOKEN }}
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://gitea:3000/api/packages/windychen/npm/windychen-utils/$VERSION)
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
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
|
||||
echo "Gitea: version $VERSION already exists, skipping."
|
||||
echo "Gitea|skipped|版本 ${VERSION} 已存在" >> /tmp/publish_result.txt
|
||||
echo "gitea_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
||||
else
|
||||
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
|
||||
echo "Gitea|failed|发布失败" >> /tmp/publish_result.txt
|
||||
echo "gitea_result=failed|发布失败" >> $GITHUB_OUTPUT
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Create Gitea Release
|
||||
if: always() && steps.publish-gitea.outcome == 'success'
|
||||
run: |
|
||||
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\"" || true)
|
||||
if [ "$EXISTS" = "0" ]; then
|
||||
curl -s -X POST \
|
||||
"http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases" \
|
||||
-H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"body\":\"## windychen-utils v${VERSION}\n\n- 发布到 Verdaccio\n- 发布到 Gitea Packages\",\"target_commitish\":\"main\"}"
|
||||
else
|
||||
echo "Release v${VERSION} already exists, skipping."
|
||||
fi
|
||||
|
||||
- name: Notify DingTalk
|
||||
if: always()
|
||||
run: |
|
||||
STATUS="${{ job.status }}"
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
|
||||
parse_result() {
|
||||
local raw="$1"
|
||||
local target="$2"
|
||||
local icon="${raw%%|*}"
|
||||
local detail="${raw#*|}"
|
||||
case "$icon" in
|
||||
published) echo "📦 ${target}: ${detail}" ;;
|
||||
skipped) echo "⏭️ ${target}: ${detail}" ;;
|
||||
failed) echo "❌ ${target}: ${detail}" ;;
|
||||
*) echo "⚠️ ${target}: ${detail}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
VERD_RESULT="${{ steps.publish-verdaccio.outputs.verdaccio_result }}"
|
||||
GITEA_RESULT="${{ steps.publish-gitea.outputs.gitea_result }}"
|
||||
|
||||
if [ -n "$VERD_RESULT" ]; then
|
||||
VERD_LINE=$(parse_result "$VERD_RESULT" "Verdaccio")
|
||||
else
|
||||
VERD_LINE="⚠️ Verdaccio: 未执行"
|
||||
GITEA_LINE="⚠️ Gitea: 未执行"
|
||||
if [ -f /tmp/publish_result.txt ]; then
|
||||
while IFS='|' read -r TARGET ICON DETAIL; do
|
||||
case "$ICON" in
|
||||
published) EMOJI="📦" ;;
|
||||
skipped) EMOJI="⏭️" ;;
|
||||
failed) EMOJI="❌" ;;
|
||||
*) EMOJI="⚠️" ;;
|
||||
esac
|
||||
LINE="${EMOJI} ${TARGET}: ${DETAIL}"
|
||||
case "$TARGET" in
|
||||
Verdaccio) VERD_LINE="$LINE" ;;
|
||||
Gitea) GITEA_LINE="$LINE" ;;
|
||||
esac
|
||||
done < /tmp/publish_result.txt
|
||||
fi
|
||||
|
||||
if [ -n "$GITEA_RESULT" ]; then
|
||||
GITEA_LINE=$(parse_result "$GITEA_RESULT" "Gitea")
|
||||
else
|
||||
GITEA_LINE="⚠️ Gitea: 未执行"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "success" ]; then
|
||||
TITLE="✅ windychen-utils v${VERSION} 构建完成 chen-fnos"
|
||||
else
|
||||
TITLE="❌ windychen-utils v${VERSION} 构建失败 chen-fnos"
|
||||
fi
|
||||
|
||||
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \
|
||||
-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 }}\"}}"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "windychen-utils",
|
||||
"version": "1.1.8",
|
||||
"version": "1.1.12",
|
||||
"main": "dist/windychen-utils.cjs.js",
|
||||
"module": "dist/windychen-utils.esm.js",
|
||||
"browser": "dist/windychen-utils.js",
|
||||
|
||||
Reference in New Issue
Block a user