Skip to content

Commit

Permalink
Setup Github Actions to push nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjanye authored Jul 5, 2024
1 parent b63e998 commit 933ec6a
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 29 deletions.
136 changes: 108 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,114 @@
name: Publish SearchExtensions package to NuGet
name: Publish to NuGet

on:
push:
release:
types: [published]
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- main

jobs:
build-and-publish:
jobs:
build-and-test:
runs-on: ubuntu-latest

defaults:
run:
working-directory: NinjaNye.SearchExtensions
steps:
- uses: actions/checkout@v2

- name: Go to project directory
run: cd NinjaNye.SearchExtensions

- 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: Push to NuGet
# run: dotnet nuget push ../../nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate
# if: startsWith(github.ref, 'refs/tags/v')
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --verbosity minimal

deploy_searchextensions:
needs: [build-and-test]
runs-on: ubuntu-latest
defaults:
run:
working-directory: NinjaNye.SearchExtensions
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT

- name: Pack
run: dotnet pack NinjaNye.SearchExtensions.csproj -c Release -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output nuget-packages

- name: Log
run: ls -al ./nuget-packages

- name: Push to NuGet
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate

deploy_levenshtein:
needs: [build-and-test]
runs-on: ubuntu-latest
defaults:
run:
working-directory: NinjaNye.SearchExtensions.Levenshtein
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT

- name: Log
run: ls -al .

- name: Pack
run: dotnet pack NinjaNye.SearchExtensions.Levenshtein.csproj -c Release -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output nuget-packages

- name: Log
run: ls -al ./nuget-packages

- name: Push to NuGet
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate

deploy_soundex:
needs: [build-and-test]
runs-on: ubuntu-latest
defaults:
run:
working-directory: NinjaNye.SearchExtensions.Soundex
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT

- name: Pack
run: dotnet pack NinjaNye.SearchExtensions.Soundex.csproj -c Release -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output nuget-packages

- name: Log
run: ls -al ./nuget-packages

- name: Push to NuGet
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate
2 changes: 2 additions & 0 deletions BuildNugetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dotnet pack -c Release -o .

cd ..\NinjaNye.SearchExtensions.Soundex\
dotnet pack -c Release -o .

cd ../
2 changes: 1 addition & 1 deletion NinjaNye.SearchExtensions/NinjaNye.SearchExtensions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard2.1;net481;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard1.0;netstandard2.1;net481</TargetFrameworks>
<Description>A collection of extension methods to IQueryable and IEnumerable that enable easy searching and ranking. Searches can be performed against multiple properties and support a wide range of types</Description>
<Version>4.0.0.3</Version>
<PackageProjectUrl>https://ninjanye.github.io/SearchExtensions/</PackageProjectUrl>
Expand Down

0 comments on commit 933ec6a

Please sign in to comment.