Skip to content

Commit 8fbd080

Browse files
committed
release version
1 parent 6ef9981 commit 8fbd080

3 files changed

Lines changed: 109 additions & 8 deletions

File tree

.github/workflows/README-RELEASE.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,33 @@ git push origin main
120120

121121
### 发布失败
122122

123-
1. **检查 NuGet API Key**:确保 `NUGET_APIKEY` secret 已正确设置
124-
2. **检查 commit message**:确保包含 `release version`(不区分大小写)
125-
3. **检查提交者邮箱**:确保 Git 配置的邮箱是 `lbhdr@outlook.com`(区分大小写)
123+
#### 常见错误:401 Unauthorized(API Key 问题)
124+
125+
如果看到以下错误:
126+
```
127+
error: Response status code does not indicate success: 401 (An API key must be provided...)
128+
```
129+
130+
**解决方法**
131+
132+
1. **检查 Secret 名称**:确保 GitHub Secret 名称是 `NUGET_APIKEY`(不是 `NUGET_API_KEY`
133+
- 进入:Settings → Secrets and variables → Actions
134+
- 检查是否存在 `NUGET_APIKEY` secret
135+
136+
2. **检查 API Key 有效性**
137+
- 访问 [NuGet.org](https://www.nuget.org/) → API Keys
138+
- 确认 API Key 未过期
139+
- 确认 API Key 有推送权限
140+
141+
3. **重新设置 Secret**
142+
- 删除旧的 `NUGET_APIKEY` secret
143+
- 创建新的 secret,名称:`NUGET_APIKEY`
144+
- 值:你的 NuGet API Key
145+
146+
#### 其他常见问题
147+
148+
1. **检查 commit message**:确保包含 `release version`(不区分大小写)
149+
2. **检查提交者邮箱**:确保 Git 配置的邮箱是 `lbhdr@outlook.com`(区分大小写)
126150
```bash
127151
# 查看当前 Git 邮箱
128152
git config user.email
@@ -133,7 +157,8 @@ git push origin main
133157
# 全局设置(可选)
134158
git config --global user.email "lbhdr@outlook.com"
135159
```
136-
4. **查看 workflow 日志**:在 Actions 页面查看详细的错误信息和检查结果
160+
3. **查看 workflow 日志**:在 Actions 页面查看详细的错误信息和检查结果
161+
4. **检查包是否已存在**:如果包已存在,workflow 会跳过(使用 `--skip-duplicate`
137162

138163
### 版本号格式错误
139164

.github/workflows/release-nuget.yml

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,95 @@ jobs:
173173
echo "Package count:"
174174
find Cyaim.WebSocketServer/artifacts -name "*.nupkg" -type f | wc -l
175175
176+
- name: Verify NuGet API Key
177+
if: steps.check_commit.outputs.trigger_release == 'true'
178+
run: |
179+
if [ -z "$NUGET_APIKEY" ]; then
180+
echo "❌ Error: NUGET_APIKEY secret is not set!"
181+
echo "Please set the NUGET_APIKEY secret in GitHub repository settings."
182+
echo "Go to: Settings → Secrets and variables → Actions → New repository secret"
183+
exit 1
184+
else
185+
echo "✅ NUGET_APIKEY secret is set (length: ${#NUGET_APIKEY} characters)"
186+
fi
187+
env:
188+
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
189+
190+
- name: Configure NuGet source
191+
if: steps.check_commit.outputs.trigger_release == 'true'
192+
run: |
193+
echo "Configuring NuGet source..."
194+
# 移除可能存在的默认源
195+
dotnet nuget remove source "nuget.org" 2>/dev/null || true
196+
# 添加正确的 NuGet 源
197+
dotnet nuget add source "https://api.nuget.org/v3/index.json" \
198+
--name "nuget.org" \
199+
--username "GitHubActions" \
200+
--password "$NUGET_APIKEY" \
201+
--store-password-in-clear-text || true
202+
echo "✅ NuGet source configured"
203+
env:
204+
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
205+
176206
- name: Push to NuGet
177207
if: steps.check_commit.outputs.trigger_release == 'true'
178208
working-directory: Cyaim.WebSocketServer/artifacts
209+
env:
210+
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
179211
run: |
180212
# 推送所有包到 NuGet
213+
PUSH_COUNT=0
214+
SUCCESS_COUNT=0
215+
FAIL_COUNT=0
216+
217+
# 确保只推送可发布的包(排除 Sample 和 Tests)
181218
for package in *.nupkg; do
182219
if [ -f "$package" ]; then
183-
echo "Pushing $package to NuGet..."
184-
dotnet nuget push "$package" \
220+
# 排除示例和测试包
221+
if [[ "$package" == *"Sample"* ]] || [[ "$package" == *"Tests"* ]] || [[ "$package" == *"Example"* ]]; then
222+
echo "⊘ Skipping (Sample/Tests): $package"
223+
continue
224+
fi
225+
226+
PUSH_COUNT=$((PUSH_COUNT + 1))
227+
echo ""
228+
echo "[$PUSH_COUNT] Pushing $package to NuGet..."
229+
echo " Source: https://api.nuget.org/v3/index.json"
230+
231+
# 使用环境变量中的 API Key 和明确的源
232+
if dotnet nuget push "$package" \
185233
--source "https://api.nuget.org/v3/index.json" \
186-
--api-key "${{ secrets.NUGET_APIKEY }}" \
187-
--skip-duplicate || echo "⚠️ Failed to push $package (may already exist)"
234+
--api-key "$NUGET_APIKEY" \
235+
--skip-duplicate \
236+
--no-symbols; then
237+
echo " ✅ Successfully pushed: $package"
238+
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
239+
else
240+
EXIT_CODE=$?
241+
if [ $EXIT_CODE -eq 0 ]; then
242+
echo " ⊘ Skipped (already exists): $package"
243+
else
244+
echo " ❌ Failed to push: $package (exit code: $EXIT_CODE)"
245+
FAIL_COUNT=$((FAIL_COUNT + 1))
246+
fi
247+
fi
188248
fi
189249
done
250+
251+
echo ""
252+
echo "=== Push Summary ==="
253+
echo "Total packages: $PUSH_COUNT"
254+
echo "Success: $SUCCESS_COUNT"
255+
echo "Failed: $FAIL_COUNT"
256+
257+
if [ $FAIL_COUNT -gt 0 ]; then
258+
echo "⚠️ Some packages failed to push. Check the errors above."
259+
echo "Common issues:"
260+
echo " 1. NUGET_APIKEY secret not set or incorrect"
261+
echo " 2. API Key expired or invalid"
262+
echo " 3. Package already exists (if not using --skip-duplicate)"
263+
exit 1
264+
fi
190265
191266
- name: Create GitHub Release
192267
if: steps.check_commit.outputs.trigger_release == 'true'

Cyaim.WebSocketServer/Tests/Cyaim.WebSocketServer.Tests.Injector/Cyaim.WebSocketServer.Tests.Injector.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<OutputType>Exe</OutputType>
8+
<IsPackable>false</IsPackable>
89
</PropertyGroup>
910
<ItemGroup>
1011
<ProjectReference Include="..\..\Cyaim.WebSocketServer\Cyaim.WebSocketServer.csproj" />

0 commit comments

Comments
 (0)