diff --git a/.github/workflows/nuget_publish.yml b/.github/workflows/nuget_publish.yml index 75d6b93..a658387 100644 --- a/.github/workflows/nuget_publish.yml +++ b/.github/workflows/nuget_publish.yml @@ -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: @@ -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 diff --git a/Directory.Build.props b/Directory.Build.props index 48c9ac6..c8e7721 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,5 @@ - 1.0.8 DrEsteban https://github.com/DrEsteban/DotNetDefer https://github.com/DrEsteban/DotNetDefer