Workflow file for this run
This file contains 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 C# package to the NuGet registry | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to publish' | |
required: true | |
env: | |
# tag names are formatted like `v1.0.0`, nuget needs it without a `v` | |
PACKAGE_VERSION_PREFIXED: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.version }} | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yml | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
needs: | |
- test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Format nuget version | |
run: | | |
echo "PACKAGE_VERSION=${PACKAGE_VERSION_PREFIXED#v}" | tee -a $GITHUB_ENV | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --configuration Release | |
working-directory: Q42.Google.Cloud.Compute.Metadata.V1 | |
- name: Publish to github nuget registry | |
run: dotnet nuget push bin/Release/*.nupkg --api-key "${{ secrets.NUGET_KEY }}" --source "https://api.nuget.org/v3/index.json" | |
working-directory: Q42.Google.Cloud.Compute.Metadata.V1 |