Files
yunhai.netcore.tool/.gitea/workflows/ci.yml
T
wanghu be7112d08d
ci / build-test (push) Failing after 2s
ci / publish (push) Skipped
ci: 移除 GitHub actions 依赖,内网手动 clone + 系统 dotnet
内网无法访问 github.com,actions/checkout@v4 拉取失败导致 job 卡死。
改为与既有 build.yml 一致的手动 clone 本仓库方式,dotnet 用 runner 镜像预装。
2026-09-02 11:31:00 +08:00

75 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: ci
on:
push:
branches: [main, master]
pull_request:
jobs:
build-test:
runs-on: ubuntu-latest
steps:
# 内网无 GitHub,不能用 actions/checkout@v4;手动 clone 本仓库(Gitea Actions 已注入 GITHUB_TOKEN)
- name: 拉取源码(内网手动 clone)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clone --depth 1 --branch "$GITHUB_REF_NAME" "http://x-access-token:${GITHUB_TOKEN}@gitea.yunhaixingtong.com/${{ github.repository }}.git" /tmp/src
cp -a /tmp/src/. .
rm -rf /tmp/src
- name: 确认 dotnet SDK
run: dotnet --version
- name: Restore
run: dotnet restore BasePlatformDotnet/yh-platform-net.sln
- name: Build
run: dotnet build BasePlatformDotnet/yh-platform-net.sln --no-restore -c Release
- name: Test
run: dotnet test BasePlatformDotnet/yh-platform-net.sln --no-build -c Release --logger "console;verbosity=normal"
- name: Pack
run: dotnet pack BasePlatformDotnet/yh-platform-net.sln --no-build -c Release -o BasePlatformDotnet/artifacts
publish:
# 仅主分支 push 时发版到 Nexus 私服(PR 不触发)
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
needs: build-test
runs-on: ubuntu-latest
steps:
- name: 拉取源码(无内网 GitHub)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clone --depth 1 --branch "$GITHUB_REF_NAME" "http://x-access-token:${GITHUB_TOKEN}@gitea.yunhaixingtong.com/${{ github.repository }}.git" /tmp/src
cp -a /tmp/src/. .
rm -rf /tmp/src
- name: 确认 dotnet SDK
run: dotnet --version
- name: Pack
run: dotnet pack BasePlatformDotnet/yh-platform-net.sln -c Release -o BasePlatformDotnet/artifacts
- name: Push to Nexus
# Nexus 的 NuGet 推送认证走 HTTP Basic(账号+密码),不校验 api-key;
# 且 Nexus 为 http 源,SDK 8 需在 nuget.config 显式 allowInsecureConnections=true。
# 动态生成带凭据的 nuget.config 并指定 --configfile,避免凭据入 git。
run: |
cat > nuget-push.config <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nexus-nuget" value="${{ secrets.NEXUS_URL }}" allowInsecureConnections="true" />
</packageSources>
<packageSourceCredentials>
<nexus-nuget>
<add key="Username" value="${{ secrets.NEXUS_USER }}" />
<add key="ClearTextPassword" value="${{ secrets.NEXUS_PASS }}" />
</nexus-nuget>
</packageSourceCredentials>
</configuration>
EOF
dotnet nuget push "BasePlatformDotnet/artifacts/*.nupkg" --source nexus-nuget --configfile nuget-push.config --api-key nexus