Skip to content

Commit

Permalink
Update nuget_publish.yml strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
DrEsteban committed May 21, 2024
1 parent 3ce1ba4 commit 63f7565
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/nuget_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ name: NuGet Publish

on:
push:
branches: [ "master" ]
tags:
- v*
workflow_dispatch:
inputs:
version:
description: 'Version'
required: false
default: 'v'

jobs:
publish:
Expand All @@ -18,11 +24,37 @@ jobs:
dotnet-version: 8.0.x
- name: Build and Test
run: dotnet test --verbosity normal
- name: Generate Semantic Version
id: generate_semver
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version == 'v' }}
uses: zwaldowski/semver-release-action@v4
with:
github_token: ${{ secrets.GITHUBTOKEN }}
bump: patch
prefix: v
dry_run: true
- name: Set version
id: set_version
run: |
VERSION_TAG=${{ (inputs.version != 'v' && inputs.version) || steps.generate_semver.outputs.version_tag || github.ref_name }}
VERSION=${VERSION_TAG//v/}
echo "version=$VERSION" >> $GITHUB_ENV
echo "version_tag=$VERSION_TAG" >> $GITHUB_ENV
- name: Build release
run: dotnet build -c Release
run: dotnet build -c Release /p:Version=${{ steps.set_version.outputs.version }}
- name: Publish GitHub
run: |
dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUBTOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DrEsteban/index.json"
dotnet nuget push --skip-duplicate --api-key ${{ secrets.GITHUBTOKEN }} ./**/Release/*.nupkg --source github
- name: Publish NuGet
run: dotnet nuget push --skip-duplicate --api-key ${{ secrets.NUGETTOKEN }} ./**/Release/*.nupkg --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
uses: ncipollo/release-action@v1.14.0
with:
artifacts: ./**/Release/**/*
token: ${{ secrets.GITHUBTOKEN }}
tag: ${{ steps.set_version.outputs.version_tag }}
commit: ${{ github.sha }}
generateReleaseNotes: true
prerelease: false
allowUpdates: true
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.0.8</Version>
<Authors>DrEsteban</Authors>
<PackageProjectUrl>https://github.com/DrEsteban/DotNetDefer</PackageProjectUrl>
<RepositoryUrl>https://github.com/DrEsteban/DotNetDefer</RepositoryUrl>
Expand Down

0 comments on commit 63f7565

Please sign in to comment.