Skip to content

Commit

Permalink
feat: 支持自动化Release流程,发布新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl committed Jul 23, 2024
1 parent 8f8d793 commit 79bb926
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
57 changes: 22 additions & 35 deletions .github/workflows/CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,40 @@ jobs:
name: 创建Github发布
runs-on: ubuntu-latest
# 主库next且执行release更新时执行
if: github.repository == '142vip/142vip-oauth' && startsWith(github.event.head_commit.message, 'chore(release):')
if: github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0

# 打成压缩包
- name: Create Zip Package
run: |
zip -r 142vip-oauth.zip . \
-x "node_modules/*" \
-x "*.git*"
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v3
with:
version: 7.33.2

# 提取版本号
- name: Get New Version Number
id: releaseVersion
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20.12.2
# 淘宝镜像加速
registry-url: 'https://registry.npmmirror.com'
# 缓存
cache: pnpm

# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
./scripts/ci
# 创建发布版本
- name: Create New Release
id: createRelease
uses: actions/create-release@latest
# Github发布版本,并更新Release信息
- run: pnpm build && npx changelog
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: v${{ steps.releaseVersion.outputs.version }}
release_name: v${{ steps.releaseVersion.outputs.version }}
body: |
Release ${{ steps.releaseVersion.outputs.version }}
GITHUB_TOKEN: ${{secrets.TOKEN}}

### ✨ Features

### 🐛 Bug Fixes
# 更新资源
- name: Upload Resource Assets
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ./142vip-oauth.zip
asset_name: 142vip-oauth.zip
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm && chmod +x ./scripts/*",
"dev": "vitepress dev --port 8080 --host",
"build": "npx fa turbo --build",
"build": "npx turbo run build --color --only",
"build:fairy-cli": "npx turbo run build --filter=@142vip/fairy-cli --color --only",
"build:docs": "vitepress build",
"clean": "npx fa clean --ignore-tips --all",
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 79bb926

Please sign in to comment.