Merge pull request #2 from bcc-code:use-trusted-publishing #11
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 Nuget Package | |
| on: | |
| push: | |
| branches: [master, main] | |
| pull_request: | |
| branches: [master, main] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v1 | |
| with: | |
| dotnet-version: 7.0.x | |
| - name: Set Environment Variables | |
| uses: ./.github/actions/setvars | |
| with: | |
| varFilePath: ./.github/variables/version.env | |
| - name: Set package version | |
| run: | | |
| if [[ $GITHUB_REF == 'refs/heads/main' && $GITHUB_EVENT_NAME == 'push' ]]; then | |
| echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}" >> "$GITHUB_ENV" | |
| else | |
| echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}-beta" >> "$GITHUB_ENV" | |
| fi | |
| - name: Package | |
| working-directory: BccCode.Hailey.Client | |
| run: | | |
| dotnet pack -p:PackageVersion=${{ env.VERSION }} -c Release -o . BccCode.Hailey.Client.csproj -p:GeneratePackageOnBuild=false | |
| - uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{vars.NUGET_USER}} | |
| - name: Publish | |
| working-directory: BccCode.Hailey.Client | |
| run: | | |
| dotnet nuget push BccCode.Hailey.Client*.nupkg \ | |
| --api-key ${{ steps.login.outputs.NUGET_API_KEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate |