Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@ name: NetDevPack Brasil - MASTER Deploy
on:
push:
branches: [ master ]
workflow_dispatch:
inputs:
version:
description: Existing release to publish again (e.g. 2.0.0). Builds tag v<version> and pushes it to nuget.org.
required: true

env:
REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
CURRENT_REPO_URL: https://github.com/${{ github.repository }}

permissions:
contents: write
issues: write
pull-requests: write
id-token: write # NuGet trusted publishing (OIDC)

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.version && format('v{0}', inputs.version) || github.sha }}

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -41,6 +54,7 @@ jobs:

- name: Semantic Release
id: semantic
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
Expand All @@ -49,8 +63,26 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Resolve version
id: version
if: github.event_name == 'workflow_dispatch' || steps.semantic.outputs.new_release_published == 'true'
env:
VERSION: ${{ inputs.version || steps.semantic.outputs.new_release_version }}
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "::error::Invalid version '$VERSION'"; exit 1; }
echo "value=$VERSION" >> "$GITHUB_OUTPUT"

- name: Generate Package
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
if: steps.version.outputs.value != ''
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.version.outputs.value }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}

- name: NuGet login (trusted publishing)
id: nuget
if: steps.version.outputs.value != ''
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}

- name: Publish the package to nuget.org
run: dotnet nuget push ./out/*.nupkg -n -d -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
if: steps.version.outputs.value != ''
run: dotnet nuget push ./out/*.nupkg --skip-duplicate -n -d -k ${{ steps.nuget.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
Loading