Skip to content

优化打包发布

优化打包发布 #10

Workflow file for this run

name: Publish to NuGet
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build-and-publish:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --tags
- name: Show current tag
run: git describe --tags
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore -p:ContinuousIntegrationBuild=true
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack DynamicLocalization.Core
run: dotnet pack src/DynamicLocalization.Core/DynamicLocalization.Core.csproj --configuration Release --no-build --output artifacts
- name: Pack DynamicLocalization.Avalonia
run: dotnet pack src/DynamicLocalization.Avalonia/DynamicLocalization.Avalonia.csproj --configuration Release --no-build --output artifacts
- name: Pack DynamicLocalization.WPF
run: dotnet pack src/DynamicLocalization.WPF/DynamicLocalization.WPF.csproj --configuration Release --no-build --output artifacts
- name: List packages
run: Get-ChildItem artifacts -Filter *.nupkg
- name: Publish to NuGet
if: startsWith(github.ref, 'refs/tags/v')
run: |
Get-ChildItem artifacts -Filter *.nupkg | ForEach-Object {
dotnet nuget push $_.FullName --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*.nupkg
retention-days: 30