Compare commits
1
Commits
df2e19efc3
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab482ca4da |
@@ -2,19 +2,19 @@ name: Release
|
|||||||
|
|
||||||
# 发版规则:dev 合并到 master,且合并请求标题为 vX.X.X
|
# 发版规则:dev 合并到 master,且合并请求标题为 vX.X.X
|
||||||
# 标题不是 vX.X.X 时只做构建验证,不发布
|
# 标题不是 vX.X.X 时只做构建验证,不发布
|
||||||
# 也支持手动触发,按 package.json 版本发布,用于失败后重发
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
types:
|
types:
|
||||||
- closed
|
- closed
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: act_runner_node
|
runs-on: act_runner_node
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
|
if: ${{ github.event.pull_request.merged == true }}
|
||||||
|
env:
|
||||||
|
NEXUS_AUTH: ${{ secrets.NEXUS_AUTH }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -22,16 +22,10 @@ jobs:
|
|||||||
- name: Resolve release version
|
- name: Resolve release version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
pkg_version=$(node -p "require('./package.json').version")
|
|
||||||
echo "package.json 版本:$pkg_version"
|
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
||||||
echo "手动触发,按 package.json 版本发布"
|
|
||||||
echo "version=$pkg_version" >> $GITHUB_OUTPUT
|
|
||||||
echo "publish=true" >> $GITHUB_OUTPUT
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
title="${{ github.event.pull_request.title }}"
|
title="${{ github.event.pull_request.title }}"
|
||||||
|
pkg_version=$(node -p "require('./package.json').version")
|
||||||
echo "PR 标题:$title"
|
echo "PR 标题:$title"
|
||||||
|
echo "package.json 版本:$pkg_version"
|
||||||
if echo "$title" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
if echo "$title" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||||
if [ "v$pkg_version" != "$title" ]; then
|
if [ "v$pkg_version" != "$title" ]; then
|
||||||
echo "FAIL: 标题 $title 与 package.json 版本 $pkg_version 不一致"
|
echo "FAIL: 标题 $title 与 package.json 版本 $pkg_version 不一致"
|
||||||
@@ -45,22 +39,17 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Configure nexus auth
|
- name: Configure nexus auth
|
||||||
env:
|
|
||||||
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
|
||||||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$NEXUS_USERNAME" ] || [ -z "$NEXUS_PASSWORD" ]; then
|
if [ -z "$NEXUS_AUTH" ]; then
|
||||||
echo "FAIL: 缺少 secrets.NEXUS_USERNAME 或 secrets.NEXUS_PASSWORD"
|
echo "FAIL: 缺少 secrets.NEXUS_AUTH"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
auth=$(printf '%s:%s' "$NEXUS_USERNAME" "$NEXUS_PASSWORD" | base64 | tr -d '\n')
|
|
||||||
{
|
{
|
||||||
echo "//nexus.imyeyu.com/repository/npm-group/:_auth=${auth}"
|
echo "//nexus.imyeyu.com/repository/npm-group/:_auth=${NEXUS_AUTH}"
|
||||||
echo "//nexus.imyeyu.com/repository/npm-group/:always-auth=true"
|
echo "//nexus.imyeyu.com/repository/npm-group/:always-auth=true"
|
||||||
echo "//nexus.imyeyu.com/repository/npm-timi/:_auth=${auth}"
|
echo "//nexus.imyeyu.com/repository/npm-timi/:_auth=${NEXUS_AUTH}"
|
||||||
echo "//nexus.imyeyu.com/repository/npm-timi/:always-auth=true"
|
echo "//nexus.imyeyu.com/repository/npm-timi/:always-auth=true"
|
||||||
} > ~/.npmrc
|
} > ~/.npmrc
|
||||||
echo "OK: nexus 认证已配置"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
@@ -74,8 +63,8 @@ jobs:
|
|||||||
- name: Ensure version not published
|
- name: Ensure version not published
|
||||||
if: ${{ steps.version.outputs.publish == 'true' }}
|
if: ${{ steps.version.outputs.publish == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
if npm view "timi-ts@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then
|
if npm view "@timi/ts@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then
|
||||||
echo "FAIL: timi-ts@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本"
|
echo "FAIL: @timi/ts@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "OK: 版本未占用"
|
echo "OK: 版本未占用"
|
||||||
@@ -91,7 +80,7 @@ jobs:
|
|||||||
GITEA_SERVER_URL: ${{ github.server_url }}
|
GITEA_SERVER_URL: ${{ github.server_url }}
|
||||||
GITEA_INTERNAL_URL: ${{ vars.TIMI_GITEA_INTERNAL_URL }}
|
GITEA_INTERNAL_URL: ${{ vars.TIMI_GITEA_INTERNAL_URL }}
|
||||||
GITEA_REPOSITORY: ${{ github.repository }}
|
GITEA_REPOSITORY: ${{ github.repository }}
|
||||||
RELEASE_TAG: v${{ steps.version.outputs.version }}
|
RELEASE_TAG: ${{ github.event.pull_request.title }}
|
||||||
RELEASE_TARGET: ${{ github.sha }}
|
RELEASE_TARGET: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$GITEA_TOKEN" ]; then
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# timi-ts
|
# @timi/ts
|
||||||
|
|
||||||
平台无关的 TypeScript 通用工具库,供 `timi-web`、`timi-wxmp` 及其他业务项目复用。
|
平台无关的 TypeScript 通用工具库,供 `@timi/web`、`timi-wxmp` 及其他业务项目复用。
|
||||||
|
|
||||||
## 内容
|
## 内容
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "timi-ts",
|
"name": "@timi/ts",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "平台无关的 TypeScript 通用工具库",
|
"description": "平台无关的 TypeScript 通用工具库",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
Reference in New Issue
Block a user