ci: 添加构建测试与 NuGet 发布流水线
大石头 authored at 2026-12-02 08:02:42
1.97 KiB
NewLife.Cube.ArcoVue
name: publish-beta

on:
  # OIDC Trusted Publishing 配置完成后,再恢复 master push 自动发布 beta:
  # 在 nuget.org 为 NewLifeX/NewLife.Cube.ArcoVue 的 publish-beta.yml 建策略。
  pull_request:
    branches: [ master ]
    paths:
      - 'NewLife.Cube.ArcoVue/**'
  workflow_dispatch:

permissions:
  contents: read
  packages: write
  id-token: write

jobs:
  build-publish:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v7
      with:
        fetch-depth: 0

    - name: Setup pnpm
      uses: pnpm/action-setup@v6
      with:
        version: 9

    - name: Setup node
      uses: actions/setup-node@v7
      with:
        node-version: 24
        cache: pnpm
        cache-dependency-path: NewLife.Cube.ArcoVue/web/pnpm-lock.yaml

    - name: Build web (wwwroot)
      working-directory: NewLife.Cube.ArcoVue/web
      run: |
        pnpm install --frozen-lockfile
        pnpm build

    - name: Setup dotNET
      uses: actions/setup-dotnet@v6
      with:
        dotnet-version: |
          8.x
          9.x
          10.x
          11.x

    - name: Get Version
      run: echo "VERSION=$(date '+%Y.%m%d-beta%H%M')" >> $GITHUB_ENV

    - name: Build
      run: dotnet build 魔方ArcoVue.slnx -c Release --version-suffix ${{ env.VERSION }}

    - name: Pack
      run: dotnet pack --no-build --version-suffix ${{ env.VERSION }} -c Release -o out NewLife.Cube.ArcoVue/NewLife.Cube.ArcoVue.csproj

    - name: NuGet login (OIDC)
      id: nuget-login
      if: github.event_name != 'pull_request'
      uses: NuGet/login@v1
      with:
        user: BigStone

    - name: Publish
      if: github.event_name != 'pull_request'
      run: |
        dotnet nuget push ./out/*.nupkg --skip-duplicate --source https://nuget.pkg.github.com/NewLifeX/index.json --api-key ${{ github.token }}
        dotnet nuget push ./out/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }}