v1.4.0 #7
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: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Package version (leave empty to use csproj version)" | |
| required: false | |
| type: string | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write # Required for OIDC token exchange with NuGet | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| # Strip leading 'v' from tag (v1.0.2 → 1.0.2) | |
| VERSION="${{ github.event.release.tag_name }}" | |
| VERSION="${VERSION#v}" | |
| elif [[ -n "${{ inputs.version }}" ]]; then | |
| VERSION="${{ inputs.version }}" | |
| else | |
| # Read from csproj | |
| VERSION=$(grep -oP '<Version>\K[^<]+' src/ElBruno.HuggingFace.Downloader/ElBruno.HuggingFace.Downloader.csproj) | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "📦 Publishing version: $VERSION" | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build -c Release --no-restore -p:Version=${{ steps.version.outputs.version }} | |
| - name: Test | |
| run: dotnet test -c Release --no-build --verbosity normal | |
| - name: Pack | |
| run: | | |
| dotnet pack src/ElBruno.HuggingFace.Downloader/ElBruno.HuggingFace.Downloader.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o artifacts | |
| dotnet pack src/ElBruno.HuggingFace.Downloader.Cli/ElBruno.HuggingFace.Downloader.Cli.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o artifacts | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push to NuGet.org | |
| run: dotnet nuget push artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |