Compare commits
4 Commits
4ee2bc52b1
...
v1.1.8
| Author | SHA1 | Date | |
|---|---|---|---|
| cde9795307 | |||
| 54c2fc1de8 | |||
| 52cf3c36ea | |||
| f27b9690df |
+42
-23
@@ -3,12 +3,11 @@ name: Node.js Build
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main", "master"]
|
branches: ["main", "master"]
|
||||||
pull_request:
|
|
||||||
branches: ["main", "master"]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker # 匹配你 runner 的标签
|
if: contains(github.event.head_commit.message, 'chore') && contains(github.event.head_commit.message, '版本') && contains(github.event.head_commit.message, '更新')
|
||||||
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
@@ -28,20 +27,37 @@ jobs:
|
|||||||
- name: Run build
|
- name: Run build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Publish package
|
- name: Publish to Verdaccio
|
||||||
id: publish
|
id: publish-verdaccio
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
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 "Version $VERSION already exists in Verdaccio, skipping publish."
|
echo "Verdaccio: version $VERSION already exists, skipping."
|
||||||
echo "skipped|版本 ${VERSION} 已存在,跳过发布" > /tmp/publish_result.txt
|
echo "Verdaccio|skipped|版本 ${VERSION} 已存在" > /tmp/publish_result.txt
|
||||||
else
|
else
|
||||||
echo "Version $VERSION not found, publishing..."
|
|
||||||
if npm publish 2>&1; then
|
if npm publish 2>&1; then
|
||||||
echo "published|已发布 v${VERSION} 到 Verdaccio" > /tmp/publish_result.txt
|
echo "Verdaccio|published|已发布 v${VERSION}" > /tmp/publish_result.txt
|
||||||
else
|
else
|
||||||
echo "failed|npm publish 失败 (v${VERSION})" > /tmp/publish_result.txt
|
echo "Verdaccio|failed|发布失败" > /tmp/publish_result.txt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Publish to Gitea
|
||||||
|
id: publish-gitea
|
||||||
|
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
|
||||||
|
echo "Gitea: version $VERSION already exists, skipping."
|
||||||
|
echo "Gitea|skipped|版本 ${VERSION} 已存在" >> /tmp/publish_result.txt
|
||||||
|
else
|
||||||
|
if npm publish --registry http://gitea:3000/api/packages/windychen/npm/ 2>&1; then
|
||||||
|
echo "Gitea|published|已发布 v${VERSION}" >> /tmp/publish_result.txt
|
||||||
|
else
|
||||||
|
echo "Gitea|failed|发布失败" >> /tmp/publish_result.txt
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -51,20 +67,23 @@ 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: 未执行"
|
||||||
if [ -f /tmp/publish_result.txt ]; then
|
if [ -f /tmp/publish_result.txt ]; then
|
||||||
PUBLISH_RAW=$(cat /tmp/publish_result.txt)
|
while IFS='|' read -r TARGET ICON DETAIL; do
|
||||||
PUBLISH_ICON=$(echo "$PUBLISH_RAW" | cut -d'|' -f1)
|
case "$ICON" in
|
||||||
PUBLISH_DETAIL=$(echo "$PUBLISH_RAW" | cut -d'|' -f2)
|
published) EMOJI="📦" ;;
|
||||||
else
|
skipped) EMOJI="⏭️" ;;
|
||||||
PUBLISH_ICON="skipped"
|
failed) EMOJI="❌" ;;
|
||||||
PUBLISH_DETAIL="构建失败,未执行发布"
|
*) EMOJI="⚠️" ;;
|
||||||
|
esac
|
||||||
|
LINE="${EMOJI} ${TARGET}: ${DETAIL}"
|
||||||
|
case "$TARGET" in
|
||||||
|
Verdaccio) VERD_LINE="$LINE" ;;
|
||||||
|
Gitea) GITEA_LINE="$LINE" ;;
|
||||||
|
esac
|
||||||
|
done < /tmp/publish_result.txt
|
||||||
fi
|
fi
|
||||||
case "$PUBLISH_ICON" in
|
|
||||||
published) PUB_LINE="📦 发布: ${PUBLISH_DETAIL}" ;;
|
|
||||||
skipped) PUB_LINE="⏭️ 发布: ${PUBLISH_DETAIL}" ;;
|
|
||||||
failed) PUB_LINE="❌ 发布: ${PUBLISH_DETAIL}" ;;
|
|
||||||
*) PUB_LINE="⚠️ 发布: ${PUBLISH_DETAIL}" ;;
|
|
||||||
esac
|
|
||||||
if [ "$STATUS" = "success" ]; then
|
if [ "$STATUS" = "success" ]; then
|
||||||
TITLE="✅ windychen-utils v${VERSION} 构建完成 chen-fnos"
|
TITLE="✅ windychen-utils v${VERSION} 构建完成 chen-fnos"
|
||||||
else
|
else
|
||||||
@@ -72,4 +91,4 @@ jobs:
|
|||||||
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${PUB_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 }}\"}}"
|
||||||
|
|||||||
+5
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "windychen-utils",
|
"name": "windychen-utils",
|
||||||
"version": "1.1.5",
|
"version": "1.1.8",
|
||||||
"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",
|
||||||
@@ -15,6 +15,10 @@
|
|||||||
"author": "windychen",
|
"author": "windychen",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://gitea.windychen00n.work/windychen/windyChenUtils.git"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"webpack": "^5.90.0",
|
"webpack": "^5.90.0",
|
||||||
"webpack-cli": "^5.1.4"
|
"webpack-cli": "^5.1.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user