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
38 changes: 27 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

name: CI

permissions:
contents: write

on:
push:
branches:
Expand Down Expand Up @@ -33,10 +36,10 @@ jobs:

steps:
- name: checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: setup .net core sdk
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
Expand All @@ -54,13 +57,26 @@ jobs:

- name: Publish NuGet
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: alirezanet/publish-nuget@v3.1.0
with:
PROJECT_FILE_PATH: src/solrevdev.seedfolder.csproj # Relative to repository root
# VERSION_FILE_PATH: Directory.Build.props # Filepath with version info, relative to repository root. Defaults to project file
# VERSION_REGEX: <Version>(.*)<\/Version> # Regex pattern to extract version info in a capturing group
# TAG_COMMIT: true # Flag to enable / disable git tagging
# TAG_FORMAT: v* # Format of the git tag, [*] gets replaced with version
NUGET_KEY: ${{secrets.NUGET_API_KEY}} # nuget.org API key
PACKAGE_NAME: solrevdev.seedfolder
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
version=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' src/solrevdev.seedfolder.csproj)
package="src/nupkg/solrevdev.seedfolder.${version}.nupkg"
tag="v${version}"

if [[ -z "$version" || ! -f "$package" ]]; then
echo "Unable to find the package version or package file." >&2
exit 1
fi

dotnet nuget push "$package" \
--api-key "$NUGET_API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate

if git ls-remote --exit-code --tags origin "refs/tags/${tag}" >/dev/null 2>&1; then
echo "Tag ${tag} already exists; no tag update needed."
else
git tag "$tag"
git push origin "$tag"
fi