Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,26 @@ var bytes = ExcelHelper.ObjectToExcelBytes(models, options =>

## 开发和发布

- **[自动化发布脚本 `release.ps1`](release.ps1)** - 一键完成版本更新、提交和 Tag 创建的 PowerShell 脚本
- **[自动化发布系统说明](RELEASE_AUTOMATION.md)** - 包含 Copilot 指令、版本管理和自动发布流程的完整说明
- **[版本管理规范](.github/VERSIONING.md)** - 语义化版本规范和版本号递增规则
- **[发布流程指南](.github/RELEASE_GUIDE.md)** - 详细的发布步骤和故障排查指南
- **[Copilot 使用说明](.github/copilot-instructions.md)** - GitHub Copilot 开发指导和项目规范

### 快速发布新版本

使用自动化脚本一键发布:

```powershell
# Windows
.\release.ps1 -Version 2.0.4

# Linux/macOS (需要 PowerShell Core)
pwsh ./release.ps1 -Version 2.0.4
```

详细说明请参阅 [RELEASE_AUTOMATION.md](RELEASE_AUTOMATION.md)。

## 贡献者

[![Contributors](https://contrib.rocks/image?repo=chsword/Excel2Object)](https://github.com/chsword/Excel2Object/graphs/contributors)
Expand Down
15 changes: 15 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,26 @@ For more information, please visit: http://www.cnblogs.com/chsword/p/excel2objec

## Development and Release

- **[Automated Release Script `release.ps1`](release.ps1)** - PowerShell script for one-click version update, commit, and tag creation
- **[Automated Release System Documentation](RELEASE_AUTOMATION.md)** - Complete guide including Copilot instructions, version management, and automated release workflow
- **[Versioning Guidelines](.github/VERSIONING.md)** - Semantic versioning specification and version increment rules
- **[Release Process Guide](.github/RELEASE_GUIDE.md)** - Detailed release steps and troubleshooting guide
- **[Copilot Instructions](.github/copilot-instructions.md)** - GitHub Copilot development guidelines and project conventions

### Quick Release

Use the automation script for one-click release:

```powershell
# Windows
.\release.ps1 -Version 2.0.4

# Linux/macOS (PowerShell Core required)
pwsh ./release.ps1 -Version 2.0.4
```

See [RELEASE_AUTOMATION.md](RELEASE_AUTOMATION.md) for detailed instructions.

## Contributors

[![Contributors](https://contrib.rocks/image?repo=chsword/Excel2Object)](https://github.com/chsword/Excel2Object/graphs/contributors)
Expand Down
89 changes: 89 additions & 0 deletions RELEASE_AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,32 @@ graph TD

### 发布新版本 / Releasing a New Version

#### 方法一:使用自动化脚本(推荐)/ Method 1: Using Automation Script (Recommended)

**一键发布 / One-Click Release**:

```powershell
# Windows
.\release.ps1 -Version 2.0.4

# Linux/macOS (需要 PowerShell Core)
pwsh ./release.ps1 -Version 2.0.4
```

该脚本会自动完成以下所有步骤 / This script automatically completes all the following steps:
- ✓ 更新 csproj 版本号 / Update csproj version
- ✓ 提交代码 / Commit changes
- ✓ 创建 Tag / Create tag
- ✓ 推送到远程仓库 / Push to remote

详细参数和用法请参阅 [工具和脚本](#工具和脚本--tools-and-scripts) 章节。

See [Tools and Scripts](#工具和脚本--tools-and-scripts) section for detailed parameters and usage.

---

#### 方法二:手动发布 / Method 2: Manual Release

**步骤 / Steps**:

1. **更新版本号** / Update Version Number
Expand Down Expand Up @@ -229,6 +255,69 @@ GitHub 仓库 → Settings → Environments → New environment

## 🛠️ 工具和脚本 / Tools and Scripts

### 自动化发布脚本 / Automated Release Script

**脚本位置 / Script Location**: `release.ps1`

**详细指南 / Detailed Guide**: 📖 [RELEASE_SCRIPT_GUIDE.md](RELEASE_SCRIPT_GUIDE.md)

这是一个 PowerShell 脚本,可以一键完成版本更新、代码提交和 Tag 创建的全部流程。

This is a PowerShell script that automates the entire process of version update, code commit, and tag creation.

**基本用法 / Basic Usage**:

```powershell
# Windows
.\release.ps1 -Version 2.0.4

# Linux/macOS (需要安装 PowerShell Core)
pwsh ./release.ps1 -Version 2.0.4
```

**参数说明 / Parameters**:

| 参数 | 必需 | 说明 |
|------|------|------|
| `-Version` | 是 | 新版本号,格式:主版本.次版本.修订版 (例如: 2.0.3) |
| `-SkipPush` | 否 | 仅创建本地提交和标签,不推送到远程仓库 |
| `-Force` | 否 | 强制执行,跳过所有确认提示 |

**使用示例 / Examples**:

```powershell
# 发布新版本 2.0.4(会提示确认)
.\release.ps1 -Version 2.0.4

# 仅本地提交,不推送到远程
.\release.ps1 -Version 2.1.0 -SkipPush

# 强制执行,跳过确认提示
.\release.ps1 -Version 3.0.0 -Force

# 组合参数使用
.\release.ps1 -Version 2.0.5 -SkipPush -Force
```

**脚本执行流程 / Script Workflow**:

1. ✓ 验证版本号格式(必须符合语义化版本)
2. ✓ 检查 Git 仓库状态
3. ✓ 检查 Tag 是否已存在
4. ✓ 更新 `Chsword.Excel2Object.csproj` 中的版本号
5. ✓ 提交代码:`git commit -m "chore: bump version to X.Y.Z"`
6. ✓ 创建 Git Tag:`git tag vX.Y.Z`
7. ✓ 推送到远程仓库(除非使用 `-SkipPush`)

**注意事项 / Notes**:

- 脚本会自动检查工作目录是否有未提交的更改
- 如果 Tag 已存在,脚本会报错并提示如何删除
- 推送后会自动触发 GitHub Actions 的发布流程
- Windows 用户可能需要设置 PowerShell 执行策略:`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`

---

### 本地测试 NuGet 包构建 / Test NuGet Package Build Locally

```bash
Expand Down
167 changes: 167 additions & 0 deletions RELEASE_SCRIPT_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Release Script Usage Guide / 发布脚本使用指南

## English

### Prerequisites

- **Windows**: PowerShell 5.1 or later (comes with Windows 10/11)
- **Linux/macOS**: PowerShell Core 7.0+ ([Install PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell))

### Quick Start

```powershell
# Release a new version
.\release.ps1 -Version 2.0.4
```

The script will:
1. ✓ Validate version format
2. ✓ Update version in `.csproj` file
3. ✓ Commit changes
4. ✓ Create git tag
5. ✓ Push to remote repository

### Usage Examples

#### Basic Release
```powershell
.\release.ps1 -Version 2.0.4
```
This will prompt for confirmation before each major step.

#### Local-Only Release
```powershell
.\release.ps1 -Version 2.0.4 -SkipPush
```
Creates commit and tag locally, but doesn't push to remote.

#### Force Release (No Confirmations)
```powershell
.\release.ps1 -Version 2.0.4 -Force
```
Skips all confirmation prompts.

#### Combined Flags
```powershell
.\release.ps1 -Version 2.0.4 -SkipPush -Force
```
Creates local commit/tag without pushing, no confirmations.

### Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `-Version` | Yes | Version number in format: `Major.Minor.Patch` (e.g., `2.0.4`) |
| `-SkipPush` | No | Create local commits and tags only, don't push to remote |
| `-Force` | No | Skip all confirmation prompts |

### Troubleshooting

#### Error: "Tag already exists"
```powershell
# Delete local and remote tag
git tag -d v2.0.4
git push origin :refs/tags/v2.0.4

# Then run the script again
.\release.ps1 -Version 2.0.4
```

#### Error: "Execution policy"
On Windows, you might need to allow script execution:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```

#### Get Help
```powershell
Get-Help .\release.ps1 -Detailed
```

---

## 中文

### 前置要求

- **Windows**: PowerShell 5.1 或更高版本(Windows 10/11 自带)
- **Linux/macOS**: PowerShell Core 7.0+ ([安装 PowerShell](https://docs.microsoft.com/zh-cn/powershell/scripting/install/installing-powershell))

### 快速开始

```powershell
# 发布新版本
.\release.ps1 -Version 2.0.4
```

脚本将执行:
1. ✓ 验证版本号格式
2. ✓ 更新 `.csproj` 文件中的版本号
3. ✓ 提交更改
4. ✓ 创建 git 标签
5. ✓ 推送到远程仓库

### 使用示例

#### 基本发布
```powershell
.\release.ps1 -Version 2.0.4
```
在每个主要步骤前会提示确认。

#### 仅本地发布
```powershell
.\release.ps1 -Version 2.0.4 -SkipPush
```
在本地创建提交和标签,但不推送到远程。

#### 强制发布(无确认)
```powershell
.\release.ps1 -Version 2.0.4 -Force
```
跳过所有确认提示。

#### 组合参数
```powershell
.\release.ps1 -Version 2.0.4 -SkipPush -Force
```
创建本地提交/标签但不推送,无确认提示。

### 参数说明

| 参数 | 必需 | 说明 |
|------|------|------|
| `-Version` | 是 | 版本号格式:`主版本.次版本.修订版`(例如:`2.0.4`)|
| `-SkipPush` | 否 | 仅创建本地提交和标签,不推送到远程 |
| `-Force` | 否 | 跳过所有确认提示 |

### 故障排除

#### 错误:"Tag 已存在"
```powershell
# 删除本地和远程标签
git tag -d v2.0.4
git push origin :refs/tags/v2.0.4

# 然后重新运行脚本
.\release.ps1 -Version 2.0.4
```

#### 错误:"执行策略"
在 Windows 上,您可能需要允许脚本执行:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```

#### 获取帮助
```powershell
Get-Help .\release.ps1 -Detailed
```

---

## See Also / 另见

- [RELEASE_AUTOMATION.md](RELEASE_AUTOMATION.md) - Complete release automation documentation
- [.github/VERSIONING.md](.github/VERSIONING.md) - Versioning guidelines
- [.github/RELEASE_GUIDE.md](.github/RELEASE_GUIDE.md) - Detailed release process guide
Loading