-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cdb562
commit 3039d4c
Showing
1 changed file
with
59 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,72 @@ | ||
name: Publish to NuGet | ||
name: Publish And Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
branches: | ||
- 'main' | ||
|
||
|
||
jobs: | ||
publish: | ||
permissions: | ||
packages: write # Permission to publish packages | ||
contents: read # Permission to read repository contents | ||
|
||
contents: write # For creating releases and uploading assets | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
# - name: Get version from tag | ||
# id: get_version | ||
# run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --no-restore --verbosity normal | ||
|
||
- name: Pack | ||
run: dotnet pack --configuration Release --no-build --output nupkgs | ||
|
||
# - name: Get version from tag | ||
# id: get_version | ||
# run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | ||
# Add source for GitHub Packages | ||
- name: Add GitHub Source | ||
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --no-restore --verbosity normal | ||
|
||
- name: Pack | ||
run: dotnet pack --configuration Release --no-build --output nupkgs | ||
|
||
# Add source for GitHub Packages | ||
- name: Add GitHub Source | ||
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
|
||
# Publish to GitHub Packages | ||
- name: Publish to GitHub Packages | ||
run: dotnet nuget push "./nupkgs/*.nupkg" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | ||
|
||
- name: Publish to NuGet | ||
run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
# Publish to GitHub Packages | ||
- name: Publish to GitHub Packages | ||
run: dotnet nuget push "./nupkgs/*.nupkg" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | ||
|
||
- name: Publish to NuGet | ||
run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
|
||
- name: Get Release Notes | ||
id: get_release_notes | ||
run: | | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
if [ -f README.md ]; then | ||
{ | ||
echo 'NOTES<<EOF' | ||
awk '/^- '"${VERSION#v}"'$/{getline; while($0 ~ /^ -/){print substr($0, 5); getline}}' README.md | ||
echo 'EOF' | ||
} >> "$GITHUB_OUTPUT" | ||
else | ||
echo "NOTES=No release notes available for ${VERSION}" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: nupkgs/*.nupkg | ||
name: ${{ steps.get_release_notes.outputs.VERSION }} | ||
draft: false | ||
prerelease: false | ||
body: | | ||
## Release Notes | ||
${{ steps.get_release_notes.outputs.NOTES }} |