docs(readme): 將封面圖連結改為 GitHub Raw URL #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to NuGet | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: '' | |
| required: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| pack-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Determine version | |
| id: version | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.version }}" ]]; then | |
| echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT" | |
| else | |
| ref="${GITHUB_REF#refs/tags/}" | |
| version="${ref#v}" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build (Release) | |
| run: dotnet build NeoFileMagic -c Release -p:Version=${{ steps.version.outputs.version }} --no-restore | |
| - name: Pack | |
| run: | | |
| dotnet pack NeoFileMagic \ | |
| -c Release \ | |
| -p:PackageVersion=${{ steps.version.outputs.version }} \ | |
| -p:ContinuousIntegrationBuild=true \ | |
| -p:IncludeSymbols=true \ | |
| -p:SymbolPackageFormat=snupkg \ | |
| --no-build \ | |
| -o ./artifacts | |
| - name: Push to NuGet | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| if [ -z "$NUGET_API_KEY" ]; then | |
| echo "NUGET_API_KEY secret 未設定" >&2 | |
| exit 1 | |
| fi | |
| dotnet nuget push "artifacts/*.nupkg" \ | |
| --api-key "$NUGET_API_KEY" \ | |
| --source "https://api.nuget.org/v3/index.json" \ | |
| --skip-duplicate | |
| # 符號檔(snupkg)與 nuget.org 同站點 | |
| dotnet nuget push "artifacts/*.snupkg" \ | |
| --api-key "$NUGET_API_KEY" \ | |
| --source "https://api.nuget.org/v3/index.json" \ | |
| --skip-duplicate | |